|
||||||||||||||||||
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 |
|
![]() Anonymous Poster |
||||
|
||||
| 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) |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
So big article for so simple equation: ds = v * dt (v - velocity, dt - time since last rendering) |
||||
|
||||
![]() seaWidget Member since: 11/17/2001 From: USA |
||||
|
|
||||
| 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. |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| well said m8 |
||||
|
||||
![]() Billy Lee Member since: 7/15/2002 |
||||
|
|
||||
| I get this error when I compile the code: main.obj : error LNK2001: unresolved external symbol __imp__timeGetTime@0 |
||||
|
||||
![]() Billy Lee Member since: 7/15/2002 |
||||
|
|
||||
| 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? |
||||
|
||||
![]() Brad8383 Member since: 12/10/1999 |
||||
|
|
||||
| link to winmm.lib |
||||
|
||||
![]() Grellin Member since: 5/11/2001 From: Virginia Beach, USA |
||||
|
|
||||
| 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 |
||||
|
||||
![]() OutAxDx Member since: 8/11/2000 From: USA |
||||
|
|
||||
| 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. |
||||
|
||||
![]() hplus0603 Moderator - Multiplayer and Network Programming Member since: 6/3/2003 |
||||
|
|
||||
| Better yet: use the canonical game loop for all your frame-rate independence, physics fixed-timestep needs. |
||||
|
||||
![]() adumr Member since: 5/11/2006 From: Manchester, United Kingdom |
||||
|
|
||||
| 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. |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|