groverburger / lovecraft

minecraft clone written with love <3
MIT License
103 stars 12 forks source link

Frame cap #1

Closed muyyii closed 5 years ago

muyyii commented 5 years ago

This is not exactly an issue but I guess a report situation, I'm experimenting fast FPS(120) while I'm running the game on a Macbook (non retina 2012), which difficults the movement and jumps.

the same version appears to run normally on 60 fps on my I3 + gtx 1050 , without movement issues

so I didn't took proper time to read slowly all the code, just been testing and looking the versions. any suggestions on how to code myself the frame limit ?

(you are doing an amazing job in this game by the way)

groverburger commented 5 years ago

if i'm understanding your problem correctly, the player physics becomes weird when you raise the frame cap to 120 fps instead of 60. this is because i havn't delta timed the player movement physics, so physics is currently linked directly to framerate. when the framerate gets raised 2x (from 60 to 120), the physics also becomes 2x faster.

to be honest i'm not currently sure on how to properly delta time player physics at the moment. i need to do more research on the topic, and i will get around to it eventually but it is currently not a priority. one simple albeit temporary fix would be to just run the player physics less often (every 2 frames at 120 fps) to simulate 60 fps movement at a higher framerate.

thanks for the feedback and compliments!

nico-abram commented 5 years ago

Is there a way to cap fps? I'm trying this and I get about 990-1000 fps which makes every action be pretty much instant

groverburger commented 5 years ago

that's strange. i have love2d's vysnc option turned on which has capped the framerate to 60 on all the machines i've tested on so far. i'll implement a manual frame cap in the meantime while i figure out how to properly delta time physics.

thanks for the feedback!

groverburger commented 5 years ago

fixed!

added frame independent physics