moving object acceleration

Started by KiraHaraReturns, Fri 17/02/2017 20:11:41

Previous topic - Next topic

KiraHaraReturns

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?

dayowlron

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.
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

KiraHaraReturns

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

Khris

I wouldn't use Move() at all but rather directly change the object's coordinates.

Code: ags
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.

SMF spam blocked by CleanTalk