slice icon Context Slice

Core Game Loop

Implement completely:

  • requestAnimationFrame loop with proper deltaTime
  • Separate update(dt) and render() functions
  • Frame-rate independent movement (velocity * dt)
  • Game state machine (menu, playing, paused, gameover)

Player System

Build the full system:

  • Player object with: x, y, width, height, vx, vy, speed, state
  • Smooth keyboard input with keydown/keyup tracking (keys object)
  • Acceleration-based movement, not instant (feels better)
  • Screen boundary clamping or wrapping
  • Player rendering with multiple visual states (normal, invincible, damaged)
  • Hitbox visualization option for debugging

Entity System

Build a proper system, not ad-hoc:

  • Base entity structure: { x, y, width, height, vx, vy, type, state, ... }
  • Entity update loop that handles all entities uniformly
  • Entity removal via filter, not splice-in-loop
  • At least 3-4 different entity types (enemies, projectiles, powerups, effects)

Implementation Depth

Write complete implementations. Each function should be 15-40 lines, not stubs.