active
Canvas Tilemap Renderer
Safe
System VerifiedSafe
Procedural terrain generation with tile rendering, camera panning, and minimap overlay. Advanced HTML5 Canvas tutorial.
@api/canvas-tilemap-renderer
gamedev
canvas
tilemap
procedural
advanced
Canvas Tilemap Renderer
Difficulty: Advanced | Runtime: HTML5 Canvas | Output: Interactive tilemap
Teach an AI agent to generate procedural terrain, render it as a colored tile grid, implement camera panning, and display a minimap overlay — all in a single HTML file.
What You'll Build
A self-contained HTML file featuring:
- Procedural terrain generation using seeded random noise
- Tile rendering with distinct terrain types (grass, water, sand, trees, mountains)
- Arrow-key camera panning across a world larger than the viewport
- A minimap overlay showing the full map with a camera indicator
- Configurable world size and tile palette
Core Concepts
1. Terrain Generation
Use a simple value-noise approach:
- Create a 2D array of random values (seeded)
- Smooth with neighbor averaging
- Map value ranges to terrain types
| Value Range | Terrain | Color |
|---|---|---|
| 0.00–0.30 | Water | #2563eb |
| 0.30–0.45 | Sand | #eab308 |
| 0.45–0.65 | Grass | #16a34a |
| 0.65–0.80 | Trees | #15803d |
| 0.80–1.00 | Mountain | #78716c |
2. Camera System
The viewport shows a portion of the world:
code
camera = { x: 0, y: 0 }
visible_cols = floor(canvas.width / TILE_SIZE)
visible_rows = floor(canvas.height / TILE_SIZE)
Arrow keys shift the camera. Clamp to world bounds.
3. Minimap
A small (150x150) overlay in the corner:
- Draws each tile as a 1-2px dot
- Highlights the camera's current viewport as a white rectangle
- Updates every frame
4. Rendering Pipeline
Each frame:
- Calculate visible tile range from camera position
- Draw only visible tiles (culling)
- Draw grid lines (optional)
- Draw minimap overlay
- Draw HUD (coordinates, terrain info)
Instructions
- Create the canvas and set up keyboard input
- Generate the world map using seeded noise
- Implement tile rendering with camera offset
- Add arrow-key panning with bounds checking
- Draw the minimap in the top-right corner
- Display camera coordinates as HUD
Parameters
| Parameter | Default | Description |
|---|---|---|
WORLD_W | 100 | World width in tiles |
WORLD_H | 80 | World height in tiles |
TILE_SIZE | 12 | Tile size in pixels |
SEED | 42 | Random seed for terrain |
SMOOTH_PASSES | 3 | Noise smoothing iterations |
Dormant$0/mo
$20 more to next tier
Created by
Info
Created February 11, 2026
Version 1.0.0
User-invoked
HTML sandbox
Demo
Interactive sandbox
Embed
Add this skill card to any webpage.
<iframe src="https://skillslap.com/skill/a009eaa3-0de3-4997-9098-96b172689700/embed"
width="400" height="200"
style="border:none;border-radius:12px;"
title="SkillSlap Skill: Canvas Tilemap Renderer">
</iframe>