---
name: spawn-arcade-gamedev
description: Complete Beginner-to-Advanced browser game engineering curriculum, vetted primary sources, architecture rules, and Spawn Arcade SDK/publishing standards.
source: https://spawnarcade.com/learn
---

# Spawn Arcade — Browser Game Development Mastery Skill

Use this knowledge pack whenever building, polishing, testing, or publishing an HTML5, Canvas 2D, Phaser 3, Three.js, WebGL2, WebGPU, or Godot HTML5 browser game for **Spawn Arcade** (`https://spawnarcade.com`).

## Non-Negotiable Engineering & Publishing Rules
1. **60fps Clean Loop:** Use `requestAnimationFrame` with clamped delta-time (`Math.min(dt, 0.05)`) or Glenn Fiedler's fixed-timestep accumulator (`dt = 1/60`). Never await network calls in the render loop.
2. **Zero-Friction Start:** Level 1 / core gameplay must be playable immediately on load with keyboard + mouse/touch controls and instant restart.
3. **Relative Asset Paths:** Always use relative paths (`./assets/...`, Vite `base: './'`) so builds run cleanly on isolated `*.spawnarcade.app` subdomains.
4. **Sandbox-Safe Storage & Audio:** Wrap `localStorage` calls in try/catch with in-memory fallback (for opaque preview frames) and resume Web Audio `AudioContext` on the first user gesture.
5. **Spawn Arcade SDK Integration:** Wire `window.playforge` (`auth.getPlayer`, `saves.get/set`, `leaderboard.submit/top`, `commerce.isUnlocked/requestUnlock/openTipJar`) using `https://spawnarcade.com/SDK_PROMPT.md`.
6. **Security & Bundle Hygiene:** Keep builds self-contained (no external untrusted script CDNs, no `window.top.location`, no `<input type="password">`), and pass `playforge check` before publishing.
## Level 1 · Beginner: HTML5 Canvas, Game Loops & Your First Browser Game
- **Level:** Beginner · **Price:** 100% Free · **Estimated Time:** 3 hrs
- **Vetted Sources:** MDN Web Docs (Mozilla), Harvard CS50G
- **Outcome:** Build and publish a crisp 60fps HTML5 arcade game with sound, touch support, and a live Spawn Arcade leaderboard.

### 1. Anatomy of a Video Game & requestAnimationFrame Loop (20 min)
- **Authoritative Source:** [MDN Web Docs (Mozilla)](https://developer.mozilla.org/en-US/docs/Games/Anatomy) — Official web platform documentation maintained by Mozilla engineers and W3C contributors.
- **Objective:** Understand how update(), render(), and requestAnimationFrame keep browser games smooth at 60fps without freezing the tab.
- **Key Engineering Rules:**
  - Separate game state update(dt) from canvas draw(ctx) inside requestAnimationFrame.
  - Clamp delta-time (e.g. Math.min(dt, 0.05)) so switching browser tabs never teleports entities.
  - Never run blocking loops or await network calls inside the render loop.
- **Implementation Steps:**
  1. Read MDN's game loop architecture section to see why setInterval drifts while requestAnimationFrame syncs with display refresh.
  2. Structure your game into init(), update(dt), render(), and reset() functions.
  3. Add a clean Game Over state that pauses physics while keeping the restart hotkey responsive.
- **Starter Prompt:** `Create a clean single-file HTML5 Canvas starter using requestAnimationFrame with clamped delta-time (max 50ms), separate update(dt) and render(ctx) functions, and an instant Space/click restart state machine.`
- **Deliverable:** A single-file Canvas loop running smoothly at 60fps with zero tab-switch glitches.

### 2. Build a Complete 2D Arcade Game in Pure JavaScript (40 min)
- **Authoritative Source:** [MDN Web Docs (Mozilla)](https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript) — The most widely taught, peer-reviewed introductory HTML5 Canvas tutorial on the web.
- **Objective:** Follow the gold-standard MDN step-by-step tutorial to build a complete paddle, ball, brick grid, lives, and score counter from scratch.
- **Key Engineering Rules:**
  - Canvas coordinate system (top-left 0,0), clearRect per frame, and crisp devicePixelRatio scaling.
  - Paddle velocity & reflection angles based on hit offset instead of flat 45-degree bounces.
  - State transitions: Playing → Life Lost → Win / Game Over with score tracking.
- **Implementation Steps:**
  1. Walk through MDN's 10 mini-chapters covering canvas setup, ball movement, wall bounce, paddle input, brick grid, and win/loss states.
  2. Upgrade the visual polish with neon color palettes, particle sparks on brick hits, and combo multipliers.
  3. Export as a standalone index.html and test directly in Spawn Arcade's uploader.
- **Starter Prompt:** `Build a complete single-file HTML5 Canvas 2D Breakout game following MDN best practices: angled paddle rebound, 5-row neon brick grid, 3 lives, combo multiplier, and responsive canvas scaling.`
- **Deliverable:** A playable 2D arcade game with full win/loss loop and score HUD.

### 3. 2D Collision Detection (AABB, Circle & Hitbox Forgiveness) (25 min)
- **Authoritative Source:** [MDN Web Docs (Mozilla)](https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection) — Reference implementation maintained by Mozilla with interactive live code examples.
- **Objective:** Implement reliable rectangle (AABB) and circle collision math—plus the indie secret of slightly forgiving player hitboxes.
- **Key Engineering Rules:**
  - Axis-Aligned Bounding Box (AABB) overlap check for rectangular sprites and platforms.
  - Circle-to-circle distance squared check (dx*dx + dy*dy < (r1+r2)^2) avoids slow Math.sqrt calls.
  - Shrink the player's damage hitbox by 15–20% inside the visual sprite so near-misses feel fair and exciting.
- **Implementation Steps:**
  1. Study MDN's AABB, circle collision, and Separating Axis Theorem overview.
  2. Keep collision checks pure and unit-testable outside your canvas renderer.
  3. Add debug hitbox rendering behind a toggle key (e.g., H) while tuning game feel.
- **Starter Prompt:** `Add pure AABB and circle-vs-circle collision helper functions to my HTML5 game, using a 15% forgiving player hurtbox and a debug hitbox toggle on key 'H'.`
- **Deliverable:** Bug-free collision helpers with unit tests covering edge overlaps and near-misses.

### 4. Zero-Asset Web Audio SFX & Desktop/Mobile Controls (30 min)
- **Authoritative Source:** [MDN Web Docs (Mozilla)](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API) — Authoritative W3C Web Audio API & browser input standard documentation.
- **Objective:** Synthesize crisp retro jump, coin, and explosion sounds directly in JavaScript with zero MP3 files, and support keyboard + touch + pointer controls.
- **Key Engineering Rules:**
  - Unlock AudioContext on the first user gesture (click/keydown) to satisfy browser autoplay policies.
  - Synthesize arcade SFX using OscillatorNode + GainNode exponential ramps—zero external asset loading errors.
  - Use Pointer Events (pointerdown/pointermove) + keyboard listeners so desktop and mobile work out of the box.
- **Implementation Steps:**
  1. Review MDN's Web Audio API guide and MDN Control Mechanisms (https://developer.mozilla.org/en-US/docs/Games/Techniques/Control_mechanisms).
  2. Create a tiny sfx.ts helper with playJump(), playCoin(), and playHit() plus a Mute toggle.
  3. Verify touch dragging and tapping inside a narrow mobile viewport.
- **Starter Prompt:** `Add a zero-dependency Web Audio synthesizer (playJump, playScore, playHit, with mute button and first-click AudioContext resume) plus responsive pointer/touch controls so my game works on phones and desktop.`
- **Deliverable:** Synthesized SFX + smooth mobile touch & keyboard input verified on resize.

### 5. Game Design Foundations & Publishing to Spawn Arcade (45 min)
- **Authoritative Source:** [Harvard University CS50G](https://cs50.harvard.edu/games/2018/) — Open-access university game-development course from Harvard University covering Pong, Flappy Bird, Breakout, Match-3, and Mario.
- **Objective:** Learn classic game-design principles from Harvard's open CS50G curriculum and wire the Spawn Arcade SDK to ship your game live.
- **Key Engineering Rules:**
  - Core loop first: make 15 seconds of movement/interaction feel great before adding menus or extra levels.
  - Juice: hit-stop frames, micro screen-shake, easing curves, and particle feedback amplify satisfaction.
  - Wire Spawn Arcade SDK (leaderboard.submit + saves.get/set) via SDK_PROMPT.md before uploading.
- **Implementation Steps:**
  1. Watch CS50G Lectures 0–2 (Pong, Flappy Bird, Breakout) for timeless state-machine and game-feel fundamentals.
  2. Paste Spawn Arcade's SDK_PROMPT.md into your AI coding tool to add global leaderboards and cloud saves.
  3. Drop your finished .html or .zip into /studio/upload and share your live play link.
- **Starter Prompt:** `Polish my HTML5 game with micro screen-shake, particle bursts, and wire Spawn Arcade's browser SDK using https://spawnarcade.com/SDK_PROMPT.md so high scores submit on game over.`
- **Deliverable:** A live published browser game on Spawn Arcade with working leaderboard scores.
