2
M1sf3t
46d

Ok so generally I try to avoid asking these on here, but I've ran into a problem that I can't figure out how to word in order to find a solution.

I cloned the vanilla breakout game from mdn a while back then made a svelte version removing the canvas api for svg's. It runs pretty smoothly using an animation frame, there's just one tiny problem. I used my old macbook for testing and have the ball speed set to what it would be for the first level if played on there. But play it on my new machine and it's like starting on level 100 (metaphorically, I haven't actually plugged in levels yet).

Is there a way to mediate the variation between the two? Without making the slower machine choppy. As it stands now anyone playing on a modestly performant machine is goin to have a significant disadvantage.

Comments
  • 4
    Introduce a throttle. That's similar to a problem on dos games where the clock determines the rate of the game. Only allow render updates n times a second.
  • 2
    As requestAnimationFrame is specified to be called on each screen refresh, you get twice the speed for a 120 Hz display than for a 60 Hz one.
    Decouple physics calculation from the drawing and trigger it via setInterval.
    The actual drawing may still be triggered by requestAnimationFrame.
  • 0
    @SortOfTested ok, thanks. I just found some stuff on how to set one up.
  • 0
    @Oktokolo so that's why the difference is so drastic? I was wondering, my macbook is slow but I didn't think it was that slow 😅
  • 0
    @M1sf3t
    So you actually have a 120+ Hz display on the new machine?
  • 0
    @Oktokolo no, i was just assuming. I don't even see it listed in the specs. not by Hz anyway, what the hell is a nit?
  • 0
    @M1sf3t
    Nit is a measurement of brightness. Like candela.
  • 0
    @SortOfTested ah ok.

    Lenovo didn't list it then, just said that it's an ips display.
  • 0
    @M1sf3t
    Most of their ips displays are 60hz, save one oddball monitor that's 75hz
  • 0
    @SortOfTested oh, duh. I was using the vm I had set up on my mac. That probably had a lot to do with it 🤦‍♂️
Add Comment