We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Dear all, hello!
I have to admit, I found out about p5.js few days ago and I'm very impressed with it :-)
Yet still, I have currently one question that bugs me, and I find it very hard to find the answer to.
Ok so - when I look at p5.js as an library where I can build awesome presenting or interactive projects, everything is ok, but the moment I kinda think it as a way of programming a small game, questions pop up.
The biggest at the moment is - the connection between the frame rate and the processing speed. A lot of game examples that Daniel Shiffmann does in his tutorials rely on the frame rate. Meaning like, if the frame rate is 60 FPS, so 60 frames is one second. And if he wants his example to be slower (lets say, the "snake is too fast" or something else), well he lowers the frame rate and problem solved.
Ok but what IF I want to build an game that works on 60 FPS, but when dealing with "lag spikes" or better said - frame rate drops to 40 FPS - the user experience stays the same. I don't really want the game to be "slower" that if someone has 60 frames to react, which is usually one second (at 60 FPS) and suddenly has a fps drop (due performance) to 40 FPS and so has 1,5 second to react.
You know what I mean?
What is the correct approach here? Using some "millis" boundaries, or so? What approach is recommended here, so when the game lags (performance issues on old systems) the users still have the "same game" just laggy?
And is there some paper / tutorial for this?
Thank you
Oliver
Answers
Just adding that: Daniel coded a snake game and found out, he has to limit the frame rate to make it playable (was way too fast) so he went to 5 FPS. Ok but, even if he would not limit the FPS to 5, but would set up a counter that updates the snakes position every 12th FRAME (same speed as 5 FPS, but still on 60), would not solve the issue, since still, when the user would have a laggy old system the true frame rate, must not be 60FPS for him, what if his HW can provide maximum 20 FPS? The game would be 3x slower and so 3x easier to play?
Frame based animation in games sucks. Instead use time-based animation.
Hi @blindfish
A good point about this two different animation models...