Advertisement

Bomberman FPS/Movement speed

Started by November 25, 2002 05:43 PM
11 comments, last by WoolyUK 22 years, 3 months ago
Hi guys In my bomberman game I move my character in a certain direction by 0.01 per frame when moving in a direction. The problem being, when I start the game it runs a lot slower than later on in the game when most of the blocks have been destroyed and therefore less information needs to be displayed. This means my character gets a little bit faster each block he destroys How do I fix this please? I want my character to move the same speed/amount of distance at all times no matter how many blocks are on the screen? I''ve read about locking frames per second etc but surerly this wont help as its moving slower then faster? How do I go about this please? Im totaly confused Thanks a lot! Adam
call that a .01 at (say) 200 fps

then actually move them by

.01 * (200 / current_fps)

How to get current fps with SDL:

static int frames=0,t0=SDL_GetTicks(),fps=150; // Decent starting values
......
frames++;
if(SDL_GetTicks()-t0 > 100)
{
fps = frames / (SDL_GetTicks()-t0);
t0 = SDL_GetTicks();
frames=0;
}



[edited by - C-Junkie on November 25, 2002 7:32:34 PM]
Advertisement
Hmmm dont really understand what u r saying there, but thanks for the comments

Can anyone clear it up please?
Thanks!

you say you move at .01 per frame

at what fps is this a decent speed?

okay, call that fps T(arget)FPS

Now we also came up with C(urrent)FPS in my previous example

so you say that moving at .01 per frame looks nice at 200 fps.

so at 200 fps you get

.01 * (200/200) = .01

and at 400 fps you get

.01 * (200/400) = .005

Which is half as far, when its being updated twice as fast
Ah right I sort of understand that now, thanks

Only problem is that would mess up some of my movement code, I can only move by the same amount each time.

Hmmmm... Is that the only way of doing it?



[edited by - WoolyUK on November 25, 2002 9:25:39 PM]
Thinking about it... wouldnt it work If I just limited fps to say 30fps therfore only updating every 33ms and by a set ammount that I know works well for my situation?

Cus then no matter how much is on screen at a time, every 33s I move by the right ammount?

Does that sound like it would work?

Thanks!
Advertisement
Have you thought of making your game realtime?

1. GetTime at the begining of your frame
2. GetTime at the end of your frame
3. Find the time displacement and use it as a factor to multiply your speed in the next frame.

Thats a simple algoritm for a realtime game.
Hope it helps.

For example set up a speed for the bomber man. Say 10 units a sec. Once you find your time displacement let say its 1 millisecond. So then you say aha my guy is only gonna move a distance = Speed * time (10 units * 0.00000001 seconds)
Solved it now, thanks a lot guys

Adam
Is there even a tutorial here on gamedev that talks about moving stuff independent of your FPS? I couldn''t find anything skimming through the tutorials.
Yep there is! In facts its the one that helped me fix it

Here''s the link

http://www.gamedev.net/reference/articles/article1382.asp

Adam

This topic is closed to new replies.

Advertisement