← Back to Academy

Level 1 · Beginner: HTML5 Canvas, Game Loops & Your First Browser Game

Build and publish a crisp 60fps HTML5 arcade game with sound, touch support, and a live Spawn Arcade leaderboard.

AI Agent Curriculum Installer · 100% Free

Teach your AI agent this Beginner track

Run this in your game project folder to install all vetted lessons, architecture rules, and Spawn Arcade SDK patterns straight into .claude/skills/spawn-arcade-gamedev/SKILL.md.

View raw SKILL.md ↗/llms.txt ↗
Zero-install shell one-liner (works immediately)
mkdir -p .claude/skills/spawn-arcade-gamedev && curl -fsSL "https://spawnarcade.com/api/learn/skill.md?track=beginner-browser-game-foundations" -o .claude/skills/spawn-arcade-gamedev/SKILL.md
Or via Spawn Arcade CLI
npx @playforge/cli learn --track beginner-browser-game-foundations --agent claude
Unit 1 / 5 · 20 minutes · Free

1. Anatomy of a Video Game & requestAnimationFrame Loop

Understand how update(), render(), and requestAnimationFrame keep browser games smooth at 60fps without freezing the tab.

Vetted Full Tutorial: MDN Web Docs (Mozilla)Open Full Tutorial

Credibility check: Official web platform documentation maintained by Mozilla engineers and W3C contributors.

Key concepts to master

  • 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.

Step-by-step practice path

  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.

AI starter prompt for this unit

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.

Mastery checkpoint