Static FramesPS physic engine

Started by
6 comments, last by uncutno 21 years, 8 months ago
I want to have a static FPS (frames per second, NOT first person shooter) physic engine inside my game... The drawing FPS is going to be as many as posible (free/variating). This is because i want to be able to record a game, and be sure that exactly the same game is played at another computer. (also rather complex physics, so i dont want to ensure the same game by complex physics) If i set the physic FPS (PFPS) to 40, it will be good for the slow machines, but bad for the fast... if i set it to 100, it will be a little bad for the slow, and great for the fast) Anyone done something like this before? What PFPS did you use? [edited by - uncutno on July 25, 2002 11:17:18 AM]
-Anders-Oredsson-Norway-
Advertisement
Frame rates and physics are two entirely different things. Could you please clarify what exactly you are trying to do?
Frames Per Second, as in how many times the physic code is ran in one second... as in code often goes in loops, one loop per frame, then the FPS depends on the machine speed, BUT i want my own loop witch always goes at 40(or 80) FPS( or Loops per second) to go inside the computer speed dependent loop!

Frame is not always a graphic term, and since a fully analog physic engine is imposible to calculate on a digital computer, it must also have frames! ( or ticks or hertz or loop_counts or whatever you like to call it!) :-)

My question is if somebody have done something like this?
What was your experiense?
Did you set the FixedFPS higher or lower then the ComputerFPS?

Its posible to have your FixedFPS higher then the ComputerFPS, since you then skip the Rendering in the extra "frames"!

By ComputerFPS i mean, the FPS you get when all of your code is ran at the same FPS and at maximum speed!
-Anders-Oredsson-Norway-
Well, you could simply use a counter to see when an update needs to be called and call your physics engine then.

psuedo code:

  Draw{BOOL bTrue;int count = GetTickCount();int pass = 0;while(bTure){	if((GetTickCount - count) == (1000/30))	{		count = getTickCount();		Update();	}		Draw();}  
It depends on the complexity of the physics simulation. If its not all that much, just reading in input, moving a few entities around and some fast collision checks, you could do updates 100 times a second and then draw as fast as possible. If you need to use a lower frequency of updates you can do that too. Since all changes in velocity, position, etc...are only going to happen at each physics update, simple linear interpolation of position and animations between frames will give users with a fast machine a smoother view.

There already has been a lot written about this on both on the forusms and the web. I suggest you do some searching for "frame rate independant movement". Some of it may not be exactly what you are looking for but does relate to what you are trying to do.
if you want ANY computer program to run the same EVERY time, always give it the same input. this means, settings, and random number seeds. you shouldnt need to record all that crap -just make sure u keep track of the input.
Thanks!

jermz: I forgot about that! Frame Interpolation! Thats great, and solves all of my problems! The engime must be 1 frame ahead of what you see then, but thats no problem!

EvilCrap: Thats what i want! :-)

7 buttons = 7 bits
1 bit = message or input flag..
message = 7 bit (for example exit aplication)

This leavs one byte(8 bit) per frame! :-)
Could also have every other byte as a timer on how many frames until next input change... this would result in < 1 byte per frame
= ( < 1) * 60 * 60 * 2(minutes) = ( < 7 ) kbs for a 2 min game recording :-)


once again: jermz , you solved my problem. Only heard about Frame Interpolation used to handle Internet Lag...
-Anders-Oredsson-Norway-
Is there any way of not locking the physics engine to a specific fps? I mean, let the physics run as fast as your computer can handle?

=> Arfa <=
=> Arfa <=

This topic is closed to new replies.

Advertisement