New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to set FPS #24
Comments
What situations would changing the FPS be useful? |
Each game has its own update speed, usually depending on the level. For instance, your Tetris speeds up the falling of the bricks. Instead of counting the delay in the game code, one could simply change the FPS like this:
This is probably not the only one approach, but similar mechanism would be handy for game developers. |
Hmm, there could maybe be a memory register for it, although for simplicity I feel like it should remain a constant 60 FPS and leave it up to the game to handle. It doesn't seem like that much boilerplate. Note that tone() durations are measured in "frames" (1/60th of a second), so redefining the length of a frame might create some confusion there. |
Maybe is changing FPS not ideal, I agree. Still, I believe some out-of-the-box mechanism for controlling the game speed provided by the platform would be really handy. All in all, it is a problem every game must deal with. Why not solve it once and use it everywhere? As feedback from other users would be helpful. It'd make sense to postpone this. |
I think at very least the speed should be limited. Playing the examples on my main monitors is difficult because it runs at 144 Hz, which makes the games much faster. |
Documentation is currently a bit misleading:
For instance on my mac plugging and unplugging the power cord changes the frame rate from 60 to 30. I think there are 2 possible approaches:
|
@FaberVitale Thanks for clearing things up! When the platform cannot call update in a constant interval it should provide a way to get the current FPS to ensure consistent speed. The first option proposed by you makes sense to me. Alternatively, A workaround would be using a timer in the game's code and performing (or not performing) update based on the time (number of milliseconds) since the previous update. |
Sorry to trouble you @FaberVitale , but could you share how you were able to overlay the frame rate? It may be helpful for an issue I'm running into. Thanks :) |
|
Another use case (for either setting a lower bound FPS or reading the current time between frames, etc) could be for running on low-power devices. I'm using wasm4-aot to make a GameBoy Advance ROM out of a wasm-4 game. Using that approach is difficult to hit 60fps but it's still amazing it works at all! Can see the difference between running the wasm-4 build in the browser and running in an online gba emulator (just click "Run Anyway" if it complains about the ROM format). The GBA rom isn't hitting 60 fps in the emulator so the game feels slow. I ended up scaling all tick oriented constants (by eye-balling the movement speed) and the time scaled ROM in a gba emulator at least moves a little better even if the FPS is lower. |
It would be handy to set FPS from the game code. This would save developers some boilerplate code.
What do you think?
The text was updated successfully, but these errors were encountered: