{
  "id": 22314100,
  "title": "Deterministic 60–144Hz Rotating-Pin Collision & Zero-Ghosting 2P Input in HTML5 Canvas",
  "url": "https://urgent.news/2026/11/28/deterministic-60-144hz-rotating-pin-collision-zero-ghosting-2p-input",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-28T06:20:32.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/lht916304584/deterministic-60-144hz-rotating-pin-collision-zero-ghosting-2p-input-in-html5-canvas-130l"
  },
  "original_language": "en",
  "account": "In the realm of fast, deterministic 2-player games built using vanilla HTML5 Canvas, developers faced three subtle physics and input bugs. To solve these issues without relying on external libraries, they employed clean math and DOM patterns.\n\nFirstly, when creating rotating-pin games inspired by classic aa/Crabie mechanics, pins attach to a spinning central wheel at orbit radius R, each featuring a circular pinhead of radius r. To ensure precise collision detection, the developers stored each attached pin as a relative polar angle θ rather than integrating (x, y) positions frame-by-frame. This approach prevents floating-point rounding errors from causing attached pins to drift apart over time. By calculating the shortest angular distance between angles using the chord triangle, they achieved pixel-perfect collision thresholds across 100 speed-changing stages and split-screen duel mode in their browser build of Coreball Game on 2P Duel.\n\nSecondly, to address sub-frame arrival interpolation on high-refresh screens, developers introduced a method for sub-frame interpolation when projectiles travel upward at high velocities. At a speed of 1100 px/s, a single 16.67ms frame moves the pin 18.3 pixels forward. By checking the collision only at the end of each frame, the core rotated an extra ω * dt after the pin actually crossed the impact boundary, rendering tight gaps unfair on different refresh rates. To combat this, they computed the exact fractional sub-frame tImpact ∈ [0, 1] when the pin crosses the impactY position, ensuring identical impact angles for 60Hz Chromebooks and 144Hz desktops.\n\nLastly, to avoid membrane keyboard ghosting in local 2-player games, developers encountered issues where shared matrix traces could silently drop keydown events when players pressed multiple keys simultaneously. To resolve this, they followed three rules: bind KeyboardEvent.code instead of event.key to ensure consistent mapping across keyboards, split the keyboard matrix into two distinct zones for each player, and track active keys using a Set<string> to avoid OS key-repeat delays. By implementing these strategies, they successfully maintained responsive responsiveness in same-screen browser multiplayer experiences, such as in their 2P Duel platform and knockback physics arenas like Shove Kings.",
  "summary": "Building fast, deterministic timing and local 2-player games in vanilla HTML5 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…",
  "summary_source": "publisher",
  "key_points": [
    "Developers solved three physics and input bugs in HTML5 Canvas 2P games without external libraries",
    "Stored rotating pins as polar angle θ to prevent drifting due to floating-point errors"
  ],
  "editors_take": "Prioritizing polar coordinates and sub-frame interpolation allows vanilla HTML5 Canvas developers to bypass floating-point drift and refresh rate discrepancies, ensuring competitive fairness in high-speed browser-based multiplayer games.",
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}