PDA

Click to See Complete Forum and Search --> : Timing in Games


kl899
Aug 8th, 2000, 02:12 PM
Hello, I have come to realize that that internal timing mechanisms inside games are very important. For instance, a hack-and-slash approach would be to move your character so many pixels for every frame drawn. What happens when u develop for a compute that runs the game at 30 fps and then someone tries running it at 60 fps? Virtually unplayable speeds. My question to you folks is this: how to regulate the movement speed of characters so that future computers will still be able to play it? Here is how I was thinking about approaching the problem: Have directx render the screen as fast as the computer can, however, only update the character positions at set time intervals. So even though the screen is really being rendered at 60fps, since my character movement is being updated every 33ms when my timer fires, the character movement is locked to 30fps. Is this a valid solution to the problem? Any other methods to follow? Also, would this solution work for slower computers?

kedaman
Aug 8th, 2000, 05:20 PM
You should move between every frame update, and set a general speed you can change from options in your game, so you multiply each movement with this speed

kl899
Aug 8th, 2000, 05:58 PM
Hmm... anyone else have input? I'm not so convinced of your method, although it is an interesting method. One problem with it though: I can control movement speeds with it, but how would I adjust the sprite animations? Say if a computer was 1.5 times as fast, I could slow all movement to .667 times orginal speed. Though at the same time, the animation frame rate of the sprites would have to be changed but those can only be changed in whole numbers... for instance I would make the frame change once every 2 renders... and it would therefore become un-synced. Know what I'm saying? Do you have any rebuttal to my sprite frame-sync concerns?

kedaman
Aug 9th, 2000, 06:52 AM
You would only notice something at really low framerates, if you are above 30 you could have animations set to change each third frame or more. But well that depends what speed you want to have the animations to update.

Use Gettickcount with a dealy variable to each animation and you will have the animation update correctly

kl899
Aug 9th, 2000, 08:46 AM
I think I'll go with my original method and update character movements after a certain millisecond interval. However, I will use gettickcount since it's probably faster than a multimedia timer(but still gives 1ms resolution) and it doesn't require a .ocx or .dll. The problem is still glaring: say I develop for 30fps and each frame the character changes its animation frame(thus the fps and the animation is a perfect 1:1 ratio.) Now lets say computer B runs the program at 45 fps, now the fps:animation ratio is 1:1.5. In other words, in a perfect world I would animate the character every 1.5 frames but that's impossible. I would have to make a hack and basically have some animation frame change every render and then stagger every odd animation frame to skip a render. In other words, the animation would appear at an inconsistent rate which is a total turn-off to me. In order to look good, animation needs to be at a constant rate. I believe my method of using gettickcount to update the animation rather than relying solely on the fps(directx renders) will provide the best answer to this problem. It's more accurate and requires no fancy logic. No matter if that game is running at 30 fps or 1000 fps, the user will still have the same intended experience.

kedaman
Aug 9th, 2000, 09:22 AM
That's excatly the problem, i suggested, and suggest again that you leave this method. You won't probably notice on fast computers but the difference matters as you said. It's definitelty not more fancy than to add a constant speed to each movement. Also you will notice a faster fps always is better upto 120 fps.

Sastraxi
Aug 9th, 2000, 09:31 AM
Search for the Timers, Timers, TIMERS!!! Post I made in the general VB questions. The last post (with code) from Sastraxi has a DirectDraw method of updating with a certain interval. Change the MoveAllUnits to something like Animate, or whatever you want to do when it reaches the interval. You can also change the interval