Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: KiraHaraReturns on Fri 17/02/2017 20:11:41

Title: moving object acceleration
Post by: KiraHaraReturns on Fri 17/02/2017 20:11:41
I want to make an object fall down with proper physics. My approach was to put the object-move function into a while loop and alter the speed. Something like this:
while(speed < someValue){
object.Move(x,y,speed,...)
speed = incremented speed
}
but the object is still moving with the initial speed anyway, any ideas what went wrong?
Title: Re: moving object acceleration
Post by: dayowlron on Fri 17/02/2017 20:51:31
On initial look is it set to blocking? If so then the moving is being blocked and waiting to complete before it moves on then when it comes back through the loop it is moving to the same place so basically not moving at all. be sure you have it set to "eNoBlock" on the correct parameter.
Title: Re: moving object acceleration
Post by: KiraHaraReturns on Fri 17/02/2017 21:51:20
Quote from: dayowlron on Fri 17/02/2017 20:51:31
On initial look is it set to blocking? If so then the moving is being blocked and waiting to complete before it moves on then when it comes back through the loop it is moving to the same place so basically not moving at all. be sure you have it set to "eNoBlock" on the correct parameter.

thanks, eNoBlock works as I've expected
Title: Re: moving object acceleration
Post by: Khris on Fri 17/02/2017 22:48:57
I wouldn't use Move() at all but rather directly change the object's coordinates.

float x, y, mx, my;

  // repeatedly_execute
  my += 0.2; // gravity;
  // hit floor?
  if (y >= 200.0) {
    y = 200.0; my = 0.0
  }
  x += mx;
  y += my;
  object.X = FloatToInt(x, eRoundNearest);
  object.Y = FloatToInt(y, eRoundNearest);


This will result in very smooth movement.