6 ms·
Background: I am working on a live music competition game (with video) for freestyle rap. We require an accurate tick in order to synchronize the beat playback
by jamespitts 14y ago
Background: I am working on a live music competition game (with video) for freestyle rap. We require an accurate tick in order to synchronize the beat playback across many clients during a freestyle rap battle.
When developing client-side javascript I get the impression that time is running on a thin sheet of rubber. I have also wanted to have a more reliable tick but I often have to move onto other parts of what I am working on.
One useful technique is to try to create a fixed tick that all clients can receive, at least you can use this to nail down some of the rubber sheet. I use a shared tick emitting from the websocket server, and then calculate -- every sec -- how that differs from client time. In order to give clients a synchronized event I "schedule ahead" using setTimeout and this client-server time diff.