A beginner-friendly 2D game engine for browsers with a visual editor. No build step required - just pure ES modules!
-
Run the visual editor:
bun run dev # or just open index.html in your browser
-
Try the examples:
examples/games/platformer/
- Full platformer gameexamples/games/vanilla/
- Vanilla game loop exampleexamples/demos/
- Simple demo
kap/
├── src/ # Source code
│ ├── core/ # Core engine systems
│ │ ├── engine.js # Scene management
│ │ ├── renderer.js # Canvas rendering
│ │ ├── input.js # Input handling
│ │ ├── assets.js # Asset loading
│ │ └── utils.js # Utility functions
│ ├── systems/ # Game systems
│ │ ├── sprite.js # Sprite animation
│ │ ├── tilemap.js # Tile-based maps
│ │ ├── physics.js # Physics system
│ │ └── entity.js # Entity management
│ ├── engine/ # Simplified API
│ │ └── index.js # Main engine entry point
│ ├── editor/ # Visual editor
│ │ └── index.js # Editor interface
│ └── game/ # Game-specific code
│ ├── index.js # Game entry point
│ ├── scenes.js # Scene definitions
│ ├── player.js # Player logic
│ └── level.js # Level/tilemap setup
├── examples/ # Example projects
│ ├── games/ # Complete games
│ │ ├── platformer/ # Platformer example
│ │ └── vanilla/ # Vanilla game loop
│ ├── demos/ # Simple demos
│ └── templates/ # Code templates
├── assets/ # Game assets
│ ├── images/ # Sprites and images
│ ├── audio/ # Sound effects and music
│ └── fonts/ # Custom fonts
├── docs/ # Documentation
├── tests/ # Test files
└── config/ # Configuration files
import { setBackground, addPlatform, addPlayer, movePlayer, jumpPlayer, onKey, engine } from './src/engine/index.js'
// Set up your game
setBackground('#87ceeb')
addPlatform(0, 448, 640, 32, '#228B22')
addPlayer(64, 416, 32, 32, 'player.png')
// Add controls
onKey('ArrowLeft', () => movePlayer(-120, 0))
onKey('ArrowRight', () => movePlayer(120, 0))
onKey(' ', () => jumpPlayer())
// Start the game
engine.start('game')
import { Engine } from './src/core/engine.js'
import { Renderer } from './src/core/renderer.js'
import { Input } from './src/core/input.js'
import { Assets } from './src/core/assets.js'
import { Sprite } from './src/systems/sprite.js'
// Create engine instances
const canvas = document.getElementById('game')
const engine = new Engine()
const renderer = new Renderer(canvas)
const input = new Input()
const assets = new Assets()
// Define scenes
engine.addScene('game', (dt) => {
renderer.clear('#87ceeb')
// Your game logic here
})
// Start the engine
engine.start('game')
The visual editor provides:
- Drag & Drop: Place objects visually
- Property Panel: Edit object properties
- Grid System: Snap to grid for precision
- Templates: Quick-start templates
- Export: Generate standalone HTML files
- Undo/Redo: Full history support
- Bun (recommended) or any modern browser
- No build tools required!
# Start development server
bun run dev
# Or open examples directly in browser:
open examples/games/platformer/index.html
open examples/games/vanilla/index.html
open examples/demos/index.html
- Use ES modules (
import
/export
) - 2 or 4 spaces for indentation (be consistent)
- No semicolons required
- Use
camelCase
for variables/functions - Use
PascalCase
for classes
A complete platformer with:
- Player movement and jumping
- Tile-based collision
- Sprite animation
- Multiple scenes (menu, game, gameover)
Shows how to build a game without the engine:
- Custom game loop
- Manual collision detection
- Direct canvas rendering
Interactive editor with:
- Drag & drop object placement
- Real-time property editing
- Code generation and export
- Fork the repository
- Create a feature branch
- Make your changes
- Test with
bun run dev
- Submit a pull request
MIT License - see LICENSE file for details
- Built for educational purposes
- Inspired by classic 2D game engines
- Designed to be approachable for beginners