I guess that what you want to look into is the wait() function. If you say you've made wind speed to mechanically climb up, then you've already figured out how to increment the wind value in a while loop

Code:

wind=100;
while (wind<150)
{
wind+=1;
}



but since you don't get to see every iteration of the while loop slowly, wind goes instantly from 100 to 150 in the screen. If you have the program wait for one tenth of a second though after every iteration, the number will gradually go up as u want it

Code:

wind=100;
while (wind<150)
{
wind+=1;
wait(-0.1);
}




Copy paste and run the program below and try to figure out how everything works:

Code:

#include <acknex.h>
#include <default.c>

var vGlobal_Wind_Speed;

STRING* sMessage = "";



PANEL* pDisplay =
{
digits (35, 10, "Global Wind Speed: = %0.f", "Arial#16b", 1, vGlobal_Wind_Speed);
digits (35, 70, "Object 1: = %s", "Arial#16b", 1, sMessage);
flags=VISIBLE;
}


#define LOW_WIND 100
#define HIGH_WIND 150

#define TENTH_OF_SECOND 0.1


function main()
{
// initialize display
video_mode = 6;
screen_color.blue = 150;

while (1)
{
for (vGlobal_Wind_Speed=LOW_WIND; vGlobal_Wind_Speed<HIGH_WIND; vGlobal_Wind_Speed++)
wait(-TENTH_OF_SECOND);
str_cpy(sMessage,"Reached High Wind");


for (vGlobal_Wind_Speed=HIGH_WIND; vGlobal_Wind_Speed>LOW_WIND; vGlobal_Wind_Speed--)
wait(-TENTH_OF_SECOND);
str_cpy(sMessage,"Reached Low Wind");
}

}



Some new things I've included:

While(1): This while loop will go on forever, because its expression (1) is taken as being always true. You could have also written another always true statement, like (10>5) for example, but while(1) is more customary.

#define: Some variables, i declared with #define instead of var, and typed them in all caps. These are numbers that aren't really variable, but always stay the same throughout the whole program, so it's better coding to use define for all those. The same way, it would be preferred to use define to declare pi, as #define PI 3.14 than use var pi=3.14, although it would have worked all the same. I could have also used the numbers 100 and 150 themselves and not use defines or vars at all, but avoid hardcoding numbers as much as you can. If you decide later that high wind is 170 instead of 150, but you've already used the number 150 many times in your program, it would be harder to replace them all one by one.


for(...): For loops are cleaner than while loops and sometimes preferred, in cases such as yours. The above could have been written with while loops, but i would have used more lines for it. The shorter you make your program, the quicker you, some one else and the compiler will read it

good luck,
Aris


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!