Urgent.News

What's breaking now, across hundreds of outlets.

Tech

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

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…

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.

Firstly, 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.

Secondly, 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.

Lastly, 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.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

One Proxy Timeout Took Out Our Entire Search Console Pipeline

For three days we could not read our own Search Console data. The API was fine. The credentials were fine. Our laptop could not reach Google at all — every TLS handshake to www.googleapis.com timed…

  • Proxy client halted TLS connections to Google properties
  • Search Console pipeline disrupted for three days
  • Data pipeline moved to stable server in Hong Kong

What Is a Chatbot? Explained Simply for Beginners

Originally published on CodingCush . It is 11 at night. You message a small tea shop to ask the price of a cup of chai, and a reply pops up in two seconds. No one is awake at the shop.

  • Chatbot is a computer program communicating through messages
  • Simple bot uses rule-based approach with keyword matching
  • AI chatbots learn patterns from extensive example conversations

What Is TypeScript? Explained Simply for Beginners

Originally published on CodingCush . TypeScript is JavaScript with syntax for types. That is the official one line definition.

  • TypeScript adds a type system to JavaScript, enabling variable labeling with data types.
  • TypeScript compiles into plain JavaScript, ensuring compatibility with any JavaScript runtime.

More from Saturday, 28 November 2026 →