MODULE: Slow movement v1.1 (new dl site)

Started by SSH, Tue 20/09/2005 16:53:18

Previous topic - Next topic

SSH

OK, good old built-in cEgo.Walk doesn't go very slow. Amaze your firends with your snail-like pace on both objects and characters:

Download here (Requires AGS v2.71!)
Mirror

--
Edit by strazer: Not needed anymore since AGS v2.72 Beta 3:
* Added ability to use movement speeds slower than 1 (-2 is now 1/2, -3 is 1/3, etc)
--

There are two functions:

slowmove.obj(Object *o, int x, int y, int delay, optional BlockingStyle)

Moves an object from current position to x,y with delay game cycles between each pixel moved

slowmove.cha(Character *c, int x, int y, int delay, optional BlockingStyle)

Moves a character from current position to x,y with delay game cycles between each pixel moved

Default blocking style for both functions is non-blocking

Have fun!

EDIT: Fixed small buglets, documentation, added blocking option and we have version 1.1
12

Pumaman

Good stuff, a handy workaround for AGS not supporting this :)

fovmester


Wretched

Just a suggestion but now floats are allowed wouldn't a

slowmove.obj(Object *o, int x, int y, float speed, optional BlockingStyle)

be better, more in line with original move function and more versatile.

SSH

#4
Well, if you can tell me how to wait 2.3 game cycles, I'll do it. I call it delay rather than speed, because it is the number of cycles between pixel movements.
12

Wretched

Keep a track of the fractional part. Sort of like

Speed=2.3;

and do this every frame

d+=Speed;
delay=FloatToInt(d);   // your integer delay for this frame
d-=IntToFloat(delay); 

Gilbert

In that case I think it's just more sensible to do just something like:

function UniversalMove(Character *c, int x, int y, float speed, BlockingStyle bs=eNoBlock) {
  int sptmp;
  if (speed>=1.0) {
    sptmp=FloatToInt(speed);
    c.SetWalkSpeed(sptmp, sptmp);
    c.Walk(x,y,sptmp,bs);
  } else if (speed>=0){
     sptmp=FloatToInt(1/speed);
    slowmove.cha(c, x, y, sptmp, bs);
  } else return 1;
}

SSH

Good points: actually, I realised the fractional part stuff myself... and Gil, because my code doesn't do walkable areas, I think you'd maybe say WalkDirect and UniversalMoveDirect. But great idea! I'll get around to coding it up sometime...
12

Janik

#8
I ran into an issue: If you sent a "Move" command to the object before it has completed the slow move, this causes an error ("SetPosition can't be set on a moving object").

So perhaps a check to Object.Moving is in order?
Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

SMF spam blocked by CleanTalk