I am working on a top down tile based rpg and when I lock the frame rate to 30fps it is kind of choppy and I don''t like it. Currently I have just been letting it run free. Is there a way to compensate for slower machines so that they get the most optimized frame rate possible? I would also have to compensate for the chracters walking speed for different frame rates.
Or is this just too much work and I should just lock it at 50 frames a second and say heck with those who can''t run it that fast? Also is it dumb to allow the user to change resolutions in a tile game?
Don't want to lock frame rate
June 03, 2001 05:19 PM
I am also working on a 2D tile-based RPG. I just let the framerate run free, but I make sure everything is timed well. Just make a variable to use as a timer and then every frame increment the variable by the amount of time it takes to render the frame. So, at the beginning of the loop, you get the time from whatever method, then at the end of the loop, you get the time again, subtract the two times, and then take that value and add it onto the timer variable. If the timer variable exceeds a specific value, you check keyboard input, do physics etc., and then decrement the timer. Its not too much work. Here''s an example:
That''s basically the way I would do it. If you have a fast machine, you get a high framerate, and if you have a slow machine, everything in the game runs at the same speed no matter what no matter how low the framerate is (it just looks choppy). Anyway, was that the problem you were having, or was I misunderstood? And, no, I don''t think it''s dumb to allow the user to change resolution in a tile game. My game does it.
|
That''s basically the way I would do it. If you have a fast machine, you get a high framerate, and if you have a slow machine, everything in the game runs at the same speed no matter what no matter how low the framerate is (it just looks choppy). Anyway, was that the problem you were having, or was I misunderstood? And, no, I don''t think it''s dumb to allow the user to change resolution in a tile game. My game does it.
Hmm, that code looks like it would limit the frame rate to me, and run slow on a bad computer, not choppy, since it waits the same amout of time between frames nomatter what, so if it can''t render a frame in that amount of time, it starts to slow down. Here''s my timing code, which is probably even worse for slow computers:
Basically that keeps track of the current time and the time on the last frame, then subtracts the last from the current to get the time between frames, and divides that by 1000, which gets the portion of a second since the last frame, which I multiply character speed values and such by to get the distance to move or whatever. So, if a character''s speed is 2 (2 px/sec), and the time since the last frame is .5 sec, you''ll move 1 pixel per frame, or if it''s .25 sec, you move you move half a pixel per frame. The problem is all the multiplies take quite a bit of processing power. Not a problem on my 1.2GHz computer, but on a slower one (or if I slow mine down on purpose), you start moving a large distance every frame, which is hard to control. I''m thinking about putting a limit on incVal (the thing all the speeds get multiplied by), so you can only move so far every frame, but I''m not sure if it will mess up animation timing or not.
-Deku-chan
DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)
|
Basically that keeps track of the current time and the time on the last frame, then subtracts the last from the current to get the time between frames, and divides that by 1000, which gets the portion of a second since the last frame, which I multiply character speed values and such by to get the distance to move or whatever. So, if a character''s speed is 2 (2 px/sec), and the time since the last frame is .5 sec, you''ll move 1 pixel per frame, or if it''s .25 sec, you move you move half a pixel per frame. The problem is all the multiplies take quite a bit of processing power. Not a problem on my 1.2GHz computer, but on a slower one (or if I slow mine down on purpose), you start moving a large distance every frame, which is hard to control. I''m thinking about putting a limit on incVal (the thing all the speeds get multiplied by), so you can only move so far every frame, but I''m not sure if it will mess up animation timing or not.
-Deku-chan
DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)
|
Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Cool, an article came up about this on gamedev''s main page...I didn''t know I was flooding the board, I really couldn''t find the info anywhere else
That might be because I didn''t quite know how to word it properly in a search. Thanks for all the suggestions. I am now happy that I can implement it into my game.
![](smile.gif)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement