Timers

I use a timer to move pieces when you roll the dice on my Board Game Construction Kit Player. I developed it on an older iMac but I noticed on a new M1 Mac that the pieces move too quick. How do I combat that?

BGCK Player

Change the period of the timer to a higher value.

I’m not so sure…

This is a common issue for games.
You don’t want a tank flying across a screen on a new machine when it was meant to trundle because it was designed on an old one.
Animation needs to be aware of how long it has been since the last frame was displayed.

If the dice has 20 frames to display, and the timer is 1/20 second, the animation should take 1 second on any machine.

What is it inside the timer code that runs faster now?

1 Like

If you base movement on timer only, say 20fps, then when playback doubles on a faster machine, say now 40fps, everything moves twice as fast.

Instead, base movement on elapsed time since last update, ie: store time of last update, now subtract that from current time, then multiply by a desired piece speed per second and use that. Then store time into time of last update, etc etc.

You should get more consistent results. Regards, Charlie

1 Like

All depends on how you move the dice. If it depended on the timer period, a faster machine should not change it. Review your code and make sure to rely on the timer, rather than on close loops.

2 Likes

Ok thanks for the suggestions, there a few things to think on there and try.