Re: Difference between frames and milliseconds?

[cont]
But converting from MS to frames is something I generally avoid. I still track movement and actions in seconds, partly because when I was working in Java, I got wildly different framerates on different versions / computers (which is why you had to specify frame length and units when running my java games from command line).
So I just save the frame length, preferably as a constant but sometimes it has to be a variable (as with the Java issues). For clock.bgt, iirc, this is saved in the clock object's delay property. With pygame.time.clock, you are on your own. I've been saving the framerate as a global variable.
Anyway, framerate is in frames/seconds. If you want the number of seconds, do 1/framerate.
60fps = 60f / 1s, or 60f / 1000ms.
so the time per frame is 1/60s, or 1000/60ms, or 16ms / 17ms (depending on how you round, and fwict, Pygame likes to round up).
I prefer to calculate how much time passes once, in the main update function, then have individual methods for updating game-objects take the time as a parameter. That way, if anything screwy happens, or we need to do something weird like fast-forward or rewind, we still get the benefits of frames.
So I usually define an action's duration in seconds, and the update function takes how much time passes between frames as a parameter, and I just update it in that way.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector

Reply via email to