Page 1 of 1
Action list, delay between functions, and repete # of times.
Posted:
Sat Nov 15, 2008 8:02 pm
by Rux
How do you make a list of functions, have a delay in between each function, and then repete it a number of times in script?
like this?
- Code: Select all
do action
wait 500 ms
do action
200 ms
do action
repeat 2 times
Re: Action list, delay between functions, and repete # of times.
Posted:
Sat Nov 15, 2008 8:43 pm
by DilloDude
Draw Actor:
- Code: Select all
//state, loop and counter are any integers.
switch(state)
{
case 0:
//action 1;
state = 1;
counter = 0;
break;
case 1:
counter ++;
if (counter >= 15)//in frames - at 30 fps, 15 frames will be one half a sec
{
//action 2
state= 2;
counter = 0;
}
break;
case 2:
state++;
if(counter >= 6)
{
//action 3
if (loop < 2)//number of times to loop - you can use a variable
{
loop ++;
state = 0;
}
else
{
state = 3;
}
}
}
I use that sort of thing lots. It's good for setting up all sorts of stuff - enemies, switches scenes etc.
Re: Action list, delay between functions, and repete # of times.
Posted:
Sun Nov 16, 2008 11:50 pm
by j2graves
timers work, right?
Re: Action list, delay between functions, and repete # of times.
Posted:
Mon Nov 17, 2008 1:10 am
by DilloDude
You can use a timer, but It's more convenient to have it all nicely in one script. Also when the game lags and the framerate drops, timers keep real time, wheras a counter still keeps game time.
Re: Action list, delay between functions, and repete # of times.
Posted:
Mon Nov 17, 2008 4:32 am
by Kalladdolf
I've made some bad experiences with timers.
Re: Action list, delay between functions, and repete # of times.
Posted:
Tue Nov 18, 2008 12:43 am
by Rux
I tried timers, but it didnt workout.
Re: Action list, delay between functions, and repete # of times.
Posted:
Tue Nov 18, 2008 1:25 am
by BlarghNRawr
when my FPS randomly changed to 1, th timers stayed the same, 30sec
Re: Action list, delay between functions, and repete # of ti
Posted:
Mon Jan 21, 2013 10:45 pm
by ProtectionIsland
are state, loop and counter all variables?