ramorris3 / minor-miner

HTML5 platformer game (original, unlicensed version).
https://littlegames.dev/minor-miner
23 stars 8 forks source link

In-game timer is unaffected by lag in scrolling levels #3

Open friedev opened 5 years ago

friedev commented 5 years ago

Issue

Levels that scroll horizontally or vertically (level 11 and 18 in normal mode) tend to play at a noticeably lower FPS on lower end hardware, but from what I can tell, the timer is unaffected by this lag. So even though the game becomes impossible to play at full speed, the timer counts as if you were. You can see an example of this on my speedrun. This problem, of course, makes it much harder to speedrun the game on slower computers or while recording.

Solution

The ideal fix would be some form of optimization for scrolling levels. As far as I can tell, the bottleneck seems to be CPU. An easier fix would probably be making the timer dependent on FPS by incrementing an internal timer for each frame and dividing by the target framerate to get the actual time to display.

EDIT: Another option would be to make the game skip frames instead of slowing down, if that's somehow possible. It wouldn't appear to run as well, but it would fix the issue in the context of speedrunning.

I've never used phaser.js so I'm not sure how easy this is to fix, but I would be very grateful if you could implement either of these solutions.

ramorris3 commented 4 years ago

Hey, thanks so much for reaching out! Sorry it's taken so long for me to respond.

I didn't realize this game has any kind of following, and didn't discover the speed-run leaderboard until last week, even. I'd love to add more support for speed-runners, starting with this issue you mentioned.

The collision detection in this game needs optimization in general. It was one of my first projects, and I've learned a lot since then. I'd love to tackle optimization as a first priority, so I think i'll go with that, and keep updates here. If that doesn't work out, I can work on the timer code to make it more accurate when frames are skipped.

Are there any other ways I could improve the speed-running experience? Other small features that would reduce friction?