Repository navigation
Add slam mechanic to break agents and improve input handling - #3
Merged
Merged
Conversation
The controls were mirrored. The egg runs towards +z and the chase camera sits behind it looking the same way, which mirrors the picture: world +x draws on the *left* of the screen. `laneX` ascended, so lane 0 sat on the right, and `left` moved the egg right. It now descends, and slab extents go through `laneBounds`, which sorts the two edges that swap with it. Nothing in the core could see that mistake, so the camera framing moved out to `render/rig.js` as plain arithmetic, and `test/rig.test.js` projects a lane through the real rig and checks which half of the frame it lands on. It fails against the old mapping. Four more bugs behind it: - A frame shorter than the 1/120 physics step runs no tick, and intent was handed to the first tick or dropped — so a 144Hz display threw away roughly one press in six. The game now holds intent until a tick spends it, and lane presses accumulate, so a double tap inside one frame crosses two lanes. - Falling with nowhere left to land set `state` to 'over' without emitting it: no overlay, no best score, an egg standing still. There is one `finish()` now and both routes go through it. - Tapping `audio on` also jumped the egg. `click` can be stopped from bubbling; the pointer events under it are separate and reached the window anyway. Pointer events that land on the page's own controls are now left alone, and `dispose()` removes the pointercancel listener it had been leaking. - The camera eased after a respawn that teleports the egg metres up the course, so a life was spent watching the void. It cuts instead, and `reset()` no longer carries the last run's ground level into the next. The slam was the one control with no answer to anything. Come down on an agent with it on and the landing goes through the deck and breaks it — its own lane, a couple of metres of it, sixty points. It has to be aimed: a ~300ms window at running speed, and only from the air. Also: the rain lost the remainder of every tick it spent, costing it a fifth of its speed at 60fps, and the HUD rewrote four nodes sixty times a second to say the same thing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S79HqfuYJ6UNuQp6LeLJ1N
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a slam mechanic that allows the player to break agents by landing on them while diving, adds proper input buffering to prevent dropped presses on high-refresh displays, and refactors camera positioning into a testable module.
Key Changes
Slam Mechanic
SMASHconstant defining the shockwave area (2.2m deep, 1.2m wide, 1m tall) that breaks agents on landingshockwave()function to detect and shatter hazards in the slam radiusInput Buffering
hold()function to accumulate input intent across frames until a physics tick consumes itCamera Refactoring
src/render/rig.jsmodule withseat()andfocus()functionsWIDEandTALLrig configurations for different aspect ratiostest/rig.test.js) to verify camera framing and lane orderingGame State Management
smashedcounter to track broken agentsfinish()function as the single exit point for runssnap()method to cut camera to egg position on respawn (prevents blind running)Player Movement
step = right_presses - left_pressesTuning & Balance
laneX()function to correctly map lanes to screen positions (descending to account for mirrored camera view)laneBounds()helper for slab collision detectionSCORE.perAgent = 60for slam killsBug Fixes
Implementation Details
https://claude.ai/code/session_01S79HqfuYJ6UNuQp6LeLJ1N