Move objects slower than value 1?

Started by manny.p, Sun 19/06/2005 21:39:10

Previous topic - Next topic

manny.p

I'm using this :

object[0].Move(0, 67, 1, eBlock);

but need it to go slower.

scotch on irc said:

<scotch> hmm, that is slightly tough... you'd need to move it by 1 pixel every few frames, which means you'd have to code that specially in repeatedly execute

<scotch> I'd write out how but I am busy trying to work out something of my own and I'll get confused


can anyone help me with this script?

i just need it for 1 room.

ilSilente

#1
if the animation is blocking (i.e. the player can't do anything while the object is moving, just use tha wait function:

while ( the object hasn't reached the position ) {
  object[0].Move( put correct parameters here );
  wait( # of gamecycles );
}

where # of gamecycle is the time to wait before the next movement. Remeber that by default 1 second = 40 gamecycles. Look for the function Wait in the manual for further information.

--

If the animation is non-blocking, try this:

In global script:

Code: ags
int gamecycle = 0;

export gamecycle;


In global header:

Code: ags
import int gamecycle;


In your room's Repeatedly execute:

Code: ags

gamecycle++;
if (gamecycle == 40 && (object hasn't reached his position)) { // 1 movement per second
  object[0].Move( move the object by 1 pixel at time );
  gamecycle = 1;
  }


markbilly

Quote from: ilSilente link=topic=21417.msg261599#msg261599

code]
gamecycle++;
if (gamecycle == 40 && (object hasn't reached his position)) { // 1 movement per second
  object[0].Move( move the object by 1 pixel at time );
  gamecycle = 1;
  }
[/code]

This is an old topic, but I didn't want to start a new one, this script still works, but how do you "move object 1 pixel at a time" I only know how to move it to a set position. Which overrides all this and it zips there really quickly.

Thanks.
 

Khris


markbilly

 

Khris

You don't need the .Move command; the line will increase the object's x-coordinate i.e. move it one pixel to the right.

I've used oObject to demonstrate the use, you'll have to use object[0].X++; or the Script-o-name (more readable).

Similarly, use .Y++; to move it down or .X--; / .Y--; to move it to the left / up.

So given there's an object called ROCK which you want to move to the right until it's at position (200;150), use:
Code: ags
  gamecycle++;
  if (gamecycle==40 && oRock.X<200) {
    oRock.X++;
    gamecycle=1;
  }

markbilly

Quote from: KhrisMUC on Mon 26/03/2007 20:32:41
You don't need the .Move command; the line will increase the object's x-coordinate i.e. move it one pixel to the right.

I've used oObject to demonstrate the use, you'll have to use object[0].X++; or the Script-o-name (more readable).

Similarly, use .Y++; to move it down or .X--; / .Y--; to move it to the left / up.

So given there's an object called ROCK which you want to move to the right until it's at position (200;150), use:
Code: ags
  gamecycle++;
  if (gamecycle==40 && oRock.X<200) {
    oRock.X++;
    gamecycle=1;
  }


That what I did in the end. Thanks for confirming.
 

SMF spam blocked by CleanTalk