Menu

Deterministic 60–144Hz Rotating-Pin Collision & Zero-Ghosting 2P Input in HTML5 Canvas
📰

Deterministic 60–144Hz Rotating-Pin Collision & Zero-Ghosting 2P Input in HTML5 Canvas

DEV Community: html·haitengli·3 days ago
#r86IH8Eb
#devto2#devto#dev#math#delta
Long article (830 words) — no AI summary yet.
Reading 0:00
15s threshold

Building fast, deterministic timing and local 2-player games in vanilla HTML5 <canvas> looks deceptively simple—until a player on a 144Hz ProMotion display experiences double-speed rotation, or two players sharing one laptop keyboard get hit by membrane key ghosting.

While shipping a 100-level rotating-target timing game and same-screen duel mode, we ran into three subtle physics and input bugs. Here are the clean math and DOM patterns that solved them with zero external libraries.

1. Exact Chord-to-Angle Collision ( 2 * Math.asin(r / R) )

In rotating-pin games (inspired by classic aa / Coreball mechanics), pins stick into a spinning central wheel at orbit radius R , each with a circular pinhead of radius r .

If you integrate (x, y) positions frame-by-frame, floating-point rounding causes attached pins to subtly drift apart over long levels.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.