You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each dt self.y increases. Particularly if FPS is 60 then after 2 seconds (120 frames) self.y == (VIRTUAL_HEIGHT / 2 - 8) + 2420. In case of having 144 FPS after 2 seconds (288 frames) self.y == (VIRTUAL_HEIGHT / 2 - 8) + 5780.
I opened a pull request #5 fixing the issue in Bird.lua. Will add another one (if there's none) for the mario project once I finish the module.
FYI, here's the formula of the original self.y: (VIRTUAL_HEIGHT / 2 - 8) + (GRAVITY / FRAME_RATE) * (FRAMES * (FRAMES - 1) / 2). I made it like this: (VIRTUAL_HEIGHT / 2 - 8) + (GRAVITY * 60/ FRAME_RATE^2) * (FRAMES * (FRAMES - 1) / 2). This way self.y should change the same over the same period of time with different frame rates. I also multiplied the "anti-gravity" burst by 60 (the original frame rate). I tested it with different refresh rates (30, 60, 144, 155) and it seems to work the same now.
The text was updated successfully, but these errors were encountered:
Example in Bird.lua 23:32
Each
dt
self.y increases. Particularly if FPS is 60 then after 2 seconds (120 frames)self.y == (VIRTUAL_HEIGHT / 2 - 8) + 2420
. In case of having 144 FPS after 2 seconds (288 frames)self.y == (VIRTUAL_HEIGHT / 2 - 8) + 5780
.I opened a pull request #5 fixing the issue in
Bird.lua
. Will add another one (if there's none) for themario
project once I finish the module.FYI, here's the formula of the original
self.y
:(VIRTUAL_HEIGHT / 2 - 8) + (GRAVITY / FRAME_RATE) * (FRAMES * (FRAMES - 1) / 2)
. I made it like this:(VIRTUAL_HEIGHT / 2 - 8) + (GRAVITY * 60/ FRAME_RATE^2) * (FRAMES * (FRAMES - 1) / 2)
. This wayself.y
should change the same over the same period of time with different frame rates. I also multiplied the "anti-gravity" burst by 60 (the original frame rate). I tested it with different refresh rates (30, 60, 144, 155) and it seems to work the same now.The text was updated successfully, but these errors were encountered: