Design and implement gameplay mechanics that feel good. Finding the core verb and loop, movement and jumping with acceleration, coyote time and jump buffering, shooting and cooldowns, dashes, health with invincibility frames, pickups, enemies and waves, scoring and combos, timers, difficulty curves, juice (screen shake, hit-stop, squash, particles, sound), and tuning every value from config. Us...
Download skill (.zip) Files on GitHubGame mechanics
Code recipes are in references/recipes.md. Every number they use lives in config.js.
Design: before code
- Core verb: the one thing the player does most (jump, shoot, match, steer, aim). Everything else supports it.
- Core loop (seconds): verb → immediate feedback → small reward or risk → repeat. Write it in one sentence.
- Meta loop (minutes): what makes them start another run (best score, unlocks, next level, daily seed).
- One new idea at a time. Introduce a mechanic safely, then test it, then combine it with others.
- Every mechanic answers: what does the player decide? If there’s no decision, it’s decoration.
Record mechanics in the design doc (game-design-document): name, what it does, its controls, tuning values, and why it exists.
Feel: the difference between “works” and “fun”
| Mechanic | Must-haves |
|---|---|
| Movement | Acceleration + friction (not instant max speed), separate air control, max speed cap |
| Jump | Coyote time (~0.1 s after leaving a ledge), jump buffer (~0.12 s before landing), variable height (release = cut velocity), stronger gravity when falling |
| Shooting | Cooldown, small spread or kick, muzzle flash, hit flash on enemy, sound on every shot |
| Damage | Invincibility frames (~0.6–1 s) with blinking, knockback, hit-stop (40–80 ms), health shown clearly |
| Pickups | Magnet range, pop and sound, number floating up |
| Enemies | Readable windup before attacks (telegraph), consistent hitboxes slightly smaller than sprites |
Juice, in order of payoff: sound on every action → hit flash → particles → screen shake (small, short, with a setting to turn it off) → hit-stop → squash and stretch → camera lead or smoothing. Add juice after the mechanic works.
Fairness: player hitboxes slightly smaller than art, enemy hitboxes not bigger than art, no off-screen deaths, a moment of safety after respawn, and the input that killed you should be the player’s mistake.
Difficulty
- Ramp one variable at a time (speed, count, spawn rate), with a gentle curve:
value = base + (max - base) * (1 - Math.exp(-t / k)). - Teach → test → twist: show the mechanic safely, require it, then combine it.
- First 30 seconds: almost impossible to lose. First death should feel like “one more try”.
- Offer an easier option rather than making everything harder. Never punish with long replays.
Scoring
- Points for the core verb, multipliers for skill (combos, no-hit streaks, speed).
- Show the score change where it happened (floating number) and in the HUD.
- Save the best and show it on the title and results screens.
Tuning workflow
- Put every value in
config.js(speeds in units per second, times in seconds). - Play it. Change one value. Play again. Prefer big jumps (×2, ×0.5) to find the range, then fine-tune.
- Record the final values and why in the design doc.
- Optional: a debug panel (behind a key like
F1) with sliders for live tuning. Remove it or hide it before shipping.
Implementing
- Mechanics live in entities or systems (game-architecture), triggered by actions (input), using
dt. - Each mechanic gets keyboard and touch controls. Touch: a large area or button, never a tiny target.
- Test each mechanic in isolation (a test scene or debug spawn key), then in the real level.
- After adding one: play through, try to break it (spam the button, hold it through a state change, do it at walls and edges), and check the frame rate.