Skip to content
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

games/apps are fps dependent #71

Open
Trickiy opened this issue May 16, 2024 · 1 comment
Open

games/apps are fps dependent #71

Trickiy opened this issue May 16, 2024 · 1 comment
Labels
bug Something isn't working Requires testing Requires more testing

Comments

@Trickiy
Copy link

Trickiy commented May 16, 2024

Everything is fps dependent meaning when the fps is low the physics is slowed down but when the fps is high like 60 or more the physics is sped up a lot. What should happen is when the fps is lowered the physics get sped up but when the fps increases the physics should slow down. This is very apparent in elementGame.js as when on new 3ds I get arrround 20 pigeons but on old I barely get 10.

@Wolfyxon
Copy link
Owner

Wolfyxon commented May 17, 2024

What should happen is when the fps is lowered the physics get sped up but when the fps increases the physics should slow down

Yes, that's what happens (or what should). All dynamic games are specifically designed to work in the speed no matter the FPS by taking time from the previous frame then calculating the offset (delta) then multiplying all the speed values.
Example:

const speed = 10;
var prevFrameTime = Date.now();

setInterval(function() {
    const delta = (Date.now() - prevFrameTime);
    prevFrameTime = Date.now();
   
   if(isBtnPressed("right")) player.moveXY(speed * delta, 0);
   if(isBtnPressed("left")) player.moveXY(-speed * delta, 0);
});

I tested many games and forced them to run at lower FPS, but couldn't replicate the issue, they run at the same speed.

This is very apparent in elementGame.js as when on new 3ds I get arrround 20 pigeons but on old I barely get 10.

Pigeon spawning doesn't use the delta system, but it's just for testing so I don't think it's that important.

@Wolfyxon Wolfyxon added bug Something isn't working Requires testing Requires more testing labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Requires testing Requires more testing
Projects
None yet
Development

No branches or pull requests

2 participants