Page 1 of 1

Pausing Script code

PostPosted: Wed Aug 24, 2005 5:27 am
by Conqueran
I'd like to pause the script for a few secs. For instance I want my character to slow down a little bit every second. So what I'd do is run a for loop like this

xvelocity=10;
int a;

for(a=0;a<10;a++)
{
xvelocity--;
pause(1 second); // lol
}

I need some type of pause command or else my char goes from xvelocity=10 to 0 instantly. Anyone know of such a command?

PostPosted: Wed Aug 24, 2005 1:10 pm
by willg101
If you want your player to slow down slowy, use this code in 'Draw Actor':

Code: Select all
xvelocity*=.95;
if (xvelocity < .1) xvelocity=0;


That's what I always do..

Otherwise, make a 1000ms timer, and reduce xvelocity every time it goes off, then destory it when xvelocity is 0.

PostPosted: Wed Aug 24, 2005 1:36 pm
by Conqueran
Good idea. Thanks

PostPosted: Wed Aug 24, 2005 2:42 pm
by makslane
Avoid try slow down actors by using loops.
This will freeze all game.

More: If you use a code like this:

xvelocity=10;
int a;

for(a=0;a<10;a++)
{
xvelocity--;
}

The final result will be xvelocity = 0.
You don't will see the intermediate velocities.

To gradually make changes in an actor, use the Draw Actor event.

So, the code will look like this:
xvelocity=10; (in a Create Actor event)
if(xvelocity > 0) xvelocity--; (in a Draw Actor event)