game "lags" instead of slows down

Non-platform specific questions.

game "lags" instead of slows down

Postby Hblade » Wed Sep 28, 2011 9:59 pm

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:
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: game "lags" instead of slows down

Postby Game A Gogo » Wed Sep 28, 2011 10:05 pm

Code: Select all
x+=5*(60/max(1,real_fps));

I believe this should work
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: game "lags" instead of slows down

Postby skydereign » Wed Sep 28, 2011 10:57 pm

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?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: game "lags" instead of slows down

Postby Hblade » Wed Sep 28, 2011 11:05 pm

Sky:
Motion Compensation never works for me for some reason.

@gag: Thanks! :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: game "lags" instead of slows down

Postby Game A Gogo » Wed Sep 28, 2011 11:29 pm

motion compensation tends to break things up for me S:
I haven't tried my code, maybe it does the same
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: game "lags" instead of slows down

Postby skydereign » Wed Sep 28, 2011 11:34 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: game "lags" instead of slows down

Postby Hblade » Wed Sep 28, 2011 11:53 pm

Yup, not to mention if it did skip, your looking at collision errors too.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest