Browse all 51 game development snippets
This plain list stays available when interactive filters are unavailable.
- Basic Game Loop — The fundamental structure of any HTML5 Canvas game.
- Delta Time — Frame-rate independent movement using delta time.
- Fixed Timestep — Consistent physics updates independent of render speed.
- Pause & Resume — Toggle game pause state with keyboard.
- Draw Rectangles — Fill, stroke, and clear rectangles on canvas.
- Draw Circles — Draw circles and arcs using the arc() method.
- Draw Lines & Paths — Draw lines, polygons, and complex paths.
- Draw Text — Render text with custom fonts and alignment.
- Draw Images & Sprites — Load and render images on canvas.
- Sprite Animation — Animate sprites from a sprite sheet.
- AABB Collision — Axis-Aligned Bounding Box rectangle collision.
- Circle Collision — Distance-based circle collision detection.
- Point in Rectangle — Check if a point (mouse click) is inside a rectangle.
- Circle vs Rectangle — Collision between circle and rectangle.
- Keyboard Input — Track multiple simultaneous key presses.
- Mouse Tracking — Track mouse position and clicks on canvas.
- Touch Controls — Mobile touch input for games.
- Gamepad API — Support for game controllers.
- Play Sound Effects — Load and play audio files.
- Web Audio Synth — Generate sounds programmatically.
- Vector2D Class — Essential 2D vector operations.
- Linear Interpolation — Smooth transitions between values.
- Clamp & Map Range — Constrain values within bounds.
- Random Utilities — Random numbers, ranges, and choices.
- Easing Functions — Smooth animation curves.
- Follow Player AI — Simple enemy that chases the player.
- Patrol AI — Enemy that patrols between waypoints.
- MCTS AI Engine — Monte Carlo Tree Search for strategy games.
- Save/Load Game — Persist game state to localStorage.
- High Score System — Track and display top scores.
- Particle System — Create explosions and effects.
- Screen Shake — Add impact feel with camera shake.
- Basic Camera — Follow player with camera offset.
- Smooth Camera — Lerp-based smooth camera following.
- Gravity & Jump — Basic platformer physics with gravity.
- Friction & Drag — Slow down objects over time.
- Wall Bounce — Bounce objects off walls.
- Basic Tilemap — Render a 2D tile-based map.
- Tile Collision — Check collision with solid tiles.
- State Machine — Manage game states (menu, play, pause).
- Entity States — State machine for enemies/players.
- Object Pool — Reuse objects to avoid garbage collection.
- Game Timer — Frame-based timers for delays.
- Flash Effect — Screen flash on hit or power-up.
- Motion Trail — Leave fading trail behind moving object.
- Flocking (Boids) — Group behavior for swarms.
- A* Pathfinding — Find shortest path on grid.
- Gradients — Linear and radial gradients.
- Shadows & Glow — Add shadow and glow effects.
- FPS Counter — Display frames per second.
- Debug Hitboxes — Visualize collision boxes.