A fully playable Frogger-style arcade game built from scratch using vanilla JavaScript (ES6 modules) and HTML5 Canvas.
This project focuses on game fundamentals, including game loops, collision detection, sprite animation, and state management โ without using any external game engines or build tools.
- Classic Frogger gameplay
- Multi-layer canvas rendering (background, sprites, UI)
- Custom game loop and timing system
- Collision detection (vehicles, logs, river)
- Score, lives, and countdown timer
- Start screen and end-game screen (win / game over)
- Sprite atlas rendering
- JavaScript (ES6 Modules)
- HTML5 Canvas
- CSS
- No external libraries or frameworks
- No build tools required
Because the game uses ES6 modules, it must be served over HTTP (not opened directly as a file:// URL).
- Install the Live Server extension.
- Right-click
sources/index.htmlโ Open with Live Server.
cd sources
python3 -m http.server 8080Then open http://localhost:8080 in your browser.
npx serve sources| Action | Key |
|---|---|
| Move Up | Arrow โ |
| Move Down | Arrow โ |
| Move Left | Arrow โ |
| Move Right | Arrow โ |
Click Start to begin or Play Again after game over.
The game is split into ES6 modules inside sources/modules/ for a clean separation of concerns:
sources/
โโโ index.html # HTML shell with three canvas layers
โโโ index.js # Entry point โ wires event listeners and boots the game
โโโ assets/
โ โโโ sprites.png # Sprite atlas (all game graphics)
โ โโโ dead.png # Death animation image
โโโ modules/
โโโ Sprite.js # Sprite class (position, size, atlas coordinates)
โโโ Lane.js # Lane constructor (direction, speed, sprites, river flag)
โโโ entities.js # All sprite and lane instances
โโโ state.js # Shared mutable state (frog, player, canvases, images)
โโโ collision.js # Point and box collision detection helpers
โโโ renderer.js # All canvas drawing functions
โโโ game.js # Game loop, input handling, win/lose logic
| Layer | Canvas ID | Purpose |
|---|---|---|
| Background | backgroundCanvas |
Static environment, HUD |
| Sprites | spriteCanvas |
Moving vehicles and logs |
| Interface | interfaceCanvas |
Frog, overlays, start/end screen |
- Manual game loop via
setInterval - State-based game flow (
startโplayingโend) - Axis-aligned bounding box (AABB) collision detection
- Sprite atlas rendering with source-rectangle slicing
- Object movement with screen-edge wrapping
Planned improvements include:
-
๐ Rewrite the game in C++
- Implement the same mechanics using C++ and a lightweight graphics library (SFML or SDL)
- Recreate the game loop, collision detection, and entity system
- Compare architectural differences between JavaScript and C++
- Explore memory management, ownership, and performance considerations
-
๐งฑ Improve architecture
- Introduce a
Gameclass to own global state - Convert entities (Frog, Vehicles, Logs) into reusable components
- Introduce a
-
๐ฎ Gameplay improvements
- Difficulty scaling
- Level progression
- Improved collision precision
- Sound effects and animations
The goal is to use this project as a cross-language gameplay engineering exercise.