Home » Community » Forums » » Achieving Frame Rate Independent Game Movement
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Achieving Frame Rate Independent Game Movement
Post Reply 
It is good that someone took the tome to write a comprehensive article for the people who haven't done frame rate independent movement before... but to be making programs shouldn't a person be able to figure out that sort of stuff by themself?

(I am not complaining about the Author, they did a good job)

 User Rating: 1015    Report this Post to a Moderator | Link


So big article for so simple equation:

ds = v * dt

(v - velocity, dt - time since last rendering)


 User Rating: 1015    Report this Post to a Moderator | Link

I feel I should stick up for the beginner's point of view. I'm working on a breakout clone - my first game and also first real programming project - and a lot of these issues (like framerate independent movement) I hadn't even thought of. I found the article very useful, and, given how much of the time I'm feeling my way in the dark, appreciate a little hand-holding now and again. I've found that there isn't alot of respect for that kind of approach, but I find it the most useful and enjoyable.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

well said m8

 User Rating: 1015    Report this Post to a Moderator | Link

I get this error when I compile the code:

main.obj : error LNK2001: unresolved external symbol __imp__timeGetTime@0



 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I get this error when I compile the code:

main.obj : error LNK2001: unresolved external symbol __imp__timeGetTime@0

Anyone know what could be causing this?

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

link to winmm.lib

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Nice article. Very easy to read and understand.




Steven Bradley .:Personal Journal:. .:WEBPLATES:. .:CGP Beginners Group:.

"Time is our most precious resource yet it is the resource we most often waste." ~ Dr. R.M. Powell


 User Rating: 1057   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

The way started doing it a few years ago, and the way I believe all the professional first person shooters do it is this: (although I'm sure most people know this already)

The gameplay code is completely separate from the rendering (drawing) code.

It is ALWAYS good to decide upon a SPECIFIC gameplay framerate (I guess you could call it frame rate), regardless of the actual visual frame rate. For example, the old nintendo games had a gameplay framerate of 60 fps. The graphics also refreshed at 60 fps. Thus, it was very easy to do both at the same time. However, if you're playing it on an emulator on a PC, you may only be running at 45 graphic frames per second, while the game play frame rate is STILL 60 fps. If you want to see why its a good idea to have a game frame rate, (and it should stay the same no matter what computer its running on, fast or slow), try programming a recordable and playback demo feature on your game. You may notice the playback is all screwed up, or it doesn't end up happening the same way each time you play it back, if you don't have a proper game frame rate.... In OTHER WORDS: The gameplay, with movement of characters, and other entities, and of EVERYTHING ELSE, should NEVER be dependent upon the sytem clock. Pick a frame rate, like 60 or 85 or 120, or something, and then STICK TO IT, and then put a delay (using GetCurrentTime()) or whatever, inbetween... for example:

void MainGameLoop()
{
while(1)
{
GamePlay();
///RENDER CODE GOES BELOW
Render();
}
}

Forget it, I didn't feel like finishing the code... anyways, put a delay. Only use the "GamePlay" function every 30 milliseconds or something... use GetCurrentTime, or some crap like that. Then the rendering should be separate, and align it on VSYNC, or whatever you want. But don't mix the two functions together.

TIP FOR BEGINNERS OR UNREALIZING PERSONS:

Never have the gameplay and rendering code together, and ALWAYS have a fixed gameplay framerate, independent of the rendering framerate, and NOT dependent upon the system clock, although you will delay it by the sytem clock if its too fast. I think I confused a lot of people, but some people might know what I'm talking about.

 User Rating: 966   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Better yet: use the canonical game loop for all your frame-rate independence, physics fixed-timestep needs.

 User Rating: 1944   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

I'm not sure i fully understand this method as i'm experiencing oddities when i implement this in my Space Invaders style project. Basically I have aliens going left and right across the top of the screen, previously I had this based on the frame rate (the alien would move a couple of pixels each frame). When Iimplemented this though there seems to be a jump in speed when the aliens hit the right hand side of the screen and start going left. All that happens when this occurs is I negate my alienSpeed variable.and the alienspeed is multiplied by the movementval. I also notice something similar with people i have randomly running round in panic at the bottom of the screen, when i implemented this method on them they always seemed bunched up on the left hand side of the screen. If anyone understands what i'm tryin to say and can explain to me what i am missing it would be much appreciated.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: