Page 1 of 1

game "lags" instead of slows down

PostPosted: Wed Sep 28, 2011 9:59 pm
by Hblade
Can anybody tell me some sort of scripting that will allow something to.. say, the game is 60FPS, and theres a lot going on the game will slow down making everything slow, instead, I want the velocity (yvelocity, x+=x, etc) to not be based off a single number, but like.. well I want everything to be the same speed always, regardless of the framerate, I just don't know the mathmatics behind that. An example of what I'm trying to do would be:
Code: Select all
//Original with slowdown
x+=5;
//now this would make it where
//the player would move at 5, but if 60FPS slows down to 30
//it will appear as if he's going 2.5, you know?


//what I want:
x+=5(/60);


I know /60 will NOT work and makes no sense but you get the point right? D:

Re: game "lags" instead of slows down

PostPosted: Wed Sep 28, 2011 10:05 pm
by Game A Gogo
Code: Select all
x+=5*(60/max(1,real_fps));

I believe this should work

Re: game "lags" instead of slows down

PostPosted: Wed Sep 28, 2011 10:57 pm
by skydereign
Yeah, Game A Gogo's code would work. But, there is also motion compensation, which should end up doing the same thing. Any reason you aren't using that?

Re: game "lags" instead of slows down

PostPosted: Wed Sep 28, 2011 11:05 pm
by Hblade
Sky:
Motion Compensation never works for me for some reason.

@gag: Thanks! :D

Re: game "lags" instead of slows down

PostPosted: Wed Sep 28, 2011 11:29 pm
by Game A Gogo
motion compensation tends to break things up for me S:
I haven't tried my code, maybe it does the same

Re: game "lags" instead of slows down

PostPosted: Wed Sep 28, 2011 11:34 pm
by skydereign
Yeah, motion compensation has its problems, but I don't think that code will help any. Motion compensation is able to do what it is supposed to do, more or less, but the problem with lag is that it interrupts the flow of the draw cycles. So while the actor will move at the right speed more or less, it will still draw it at slower or erratic intervals.

Re: game "lags" instead of slows down

PostPosted: Wed Sep 28, 2011 11:53 pm
by Hblade
Yup, not to mention if it did skip, your looking at collision errors too.