Pausing Script code

Non-platform specific questions.

Pausing Script code

Postby Conqueran » Wed Aug 24, 2005 5:27 am

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?
User avatar
Conqueran
 
Posts: 21
Joined: Fri Aug 19, 2005 4:55 pm
Score: 0 Give a positive score

Postby willg101 » Wed Aug 24, 2005 1:10 pm

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.
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Postby Conqueran » Wed Aug 24, 2005 1:36 pm

Good idea. Thanks
User avatar
Conqueran
 
Posts: 21
Joined: Fri Aug 19, 2005 4:55 pm
Score: 0 Give a positive score

Postby makslane » Wed Aug 24, 2005 2:42 pm

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)
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest