A modern, interactive web-based map builder designed for Dungeon Masters to create stunning custom maps for their tabletop RPG campaigns.
- Grid-based Canvas: Clean, scalable grid system with smooth pan and zoom controls
- Terrain Painting: Paint different terrain types (grass, water, sand, stone) with brush tools
- Object Placement: Place and position various objects (trees, rocks, buildings) on your map
- Multi-tool Interface: Seamlessly switch between paint, place, and pan tools
- Real-time Rendering: HTML5 Canvas with optimized performance for large maps
- Auto-save: Automatic local storage persistence - never lose your work
- Responsive Design: Works seamlessly across desktop and tablet devices
- Keyboard Shortcuts: Efficient workflow with hotkey support
- Server-Side Rendering: Next.js 14+ with App Router for optimal performance
- Type Safety: Full TypeScript implementation with strict type checking
- State Management: Zustand for predictable and performant state updates
- Styling: Tailwind CSS for consistent, utility-first styling
๐ Live Demo: https://zhuzh.dev - Try it now!
Map Creation Interface
Terrain Painting in Action
Interactive Demo: Watch the terrain painting functionality in action! The demo shows painting different terrain types (grass, water, sand, stone) with smooth brush interactions on the grid-based canvas.
- Node.js 18.0 or higher
- npm 9.0 or higher
-
Clone the repository
git clone https://github.com/zac-computer/dnd-map-builder.git cd dnd-map-builder -
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
| Tool | Action | Description |
|---|---|---|
| ๐๏ธ Paint | Click & Drag | Paint terrain on grid cells |
| ๐ Place | Click | Place objects on the map |
| โ Pan | Click & Drag | Move around the map |
| ๐ Zoom | Mouse Wheel | Zoom in/out of the map |
- ๐ฑ Grass - Basic ground terrain
- ๐ง Water - Rivers, lakes, oceans
- ๐๏ธ Sand - Beaches, deserts
- ๐ฟ Stone - Rocky terrain, pathways
- ๐ณ Trees - Forest elements
- ๐ชจ Rocks - Natural obstacles
- ๐ Buildings - Structures and settlements
- Setting: Cozy tavern by a river with a small village
- Features: Stone roads connecting buildings, grassy areas, flowing river with sandy banks
- Objects: Main tavern building, village houses, scattered trees, riverside rocks
- Use Case: Perfect for starting adventures, NPC interactions, or safe haven
- Setting: Narrow mountain pass with rocky terrain
- Features: Stone mountain walls, grassy valley path winding through
- Objects: Large boulder formations for cover, scattered rocks, hardy mountain trees
- Use Case: Perfect for ambushes, tactical encounters, or dangerous travel
src/
โโโ app/ # Next.js App Router
โ โโโ (dashboard)/ # Dashboard route group
โ โโโ globals.css # Global styles
โ โโโ layout.tsx # Root layout
โ โโโ page.tsx # Home page
โโโ components/
โ โโโ core/ # Core application components
โ โ โโโ Canvas.tsx # Main canvas component
โ โ โโโ Toolbar.tsx # Tool selection interface
โ โโโ ui/ # Reusable UI components
โ โโโ Button.tsx # Button component
โ โโโ Tooltip.tsx # Tooltip component
โโโ lib/
โ โโโ hooks/ # Custom React hooks
โ โ โโโ useMapStore.ts # Map store hook
โ โ โโโ useMapPersistence.ts # Persistence hook
โ โโโ utils.ts # Utility functions
โโโ stores/
โโโ mapStore.ts # Zustand state management
# Development
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
# Code Quality
npm run lint # Run ESLint
npm run type-check # Run TypeScript compiler
npm run format # Format code with Prettier
npm run format:check # Check code formattingThis project is optimized for development with Claude Code, Anthropic's CLI tool for AI-assisted coding. Claude Code has full context of this project through the CLAUDE.md file.
-
Install Claude Code (if not already installed)
npm install -g @anthropic-ai/claude-code # Ref: https://docs.anthropic.com/claude-code -
Navigate to project directory
cd dnd-map-builder -
Start Claude Code
claude
- Feature Development: "Add a new terrain type for mountains"
- Bug Fixes: "The canvas isn't responding to mouse events on mobile"
- Code Refactoring: "Extract the canvas rendering logic into separate functions"
- Component Creation: "Create a new sidebar component for map settings"
- State Management: "Add undo/redo functionality to the map store"
- Testing: "Add unit tests for the map utilities"
- Performance: "Optimize the canvas rendering for large grids"
# Add new features
"Add a grid size selector to the toolbar"
"Implement keyboard shortcuts for tool switching"
# Fix issues
"The terrain colors aren't showing correctly"
"Objects are not positioning properly when zoomed"
# Code improvements
"Add TypeScript interfaces for the canvas events"
"Refactor the map store to use immer for immutable updates"
# Documentation
"Update the component documentation with JSDoc comments"
"Create a troubleshooting section for common issues"Claude Code understands:
- Architecture: Next.js 15+ with App Router, TypeScript, Zustand
- Components: Canvas, Toolbar, UI components structure
- State: Map store with terrain, objects, and view state
- Persistence: Local storage implementation
- Styling: Tailwind CSS patterns used throughout
- Be Specific: Instead of "fix the canvas", say "fix the canvas zoom not centering properly"
- Provide Context: Mention which files are involved when reporting issues
- Ask for Explanations: Request explanations of complex implementations
- Request Tests: Ask for unit tests when adding new functionality
- Code Review: Have Claude Code review your changes for best practices
๐๏ธ Next.js 14+ with App Router
- Server-side rendering for better SEO and performance
- Modern React features with Server Components
- Optimized bundling and code splitting
๐ฏ Zustand for State Management
- Lightweight alternative to Redux
- Excellent TypeScript support
- Minimal boilerplate with maximum flexibility
๐จ HTML5 Canvas for Rendering
- High-performance graphics rendering
- Precise control over drawing operations
- Scalable for large grid systems
๐พ Local Storage Persistence
- Instant save/load without server requirements
- Perfect for prototype and MVP phase
- Seamless user experience
- Layer System - Multiple map layers for complex designs
- Custom Objects - Import and use custom object sprites
- Advanced Terrain - More terrain types and textures
- Undo/Redo - Full action history management
- Real-time Collaboration - Multiple users editing simultaneously
- Cloud Storage - Save maps to the cloud
- Map Sharing - Share maps with the community
- User Authentication - Personal map libraries
- Map Export - Export to PNG, PDF, or print-ready formats
- Dynamic Lighting - Light sources and shadow effects
- Fog of War - Reveal areas during gameplay
- Token Management - Player and NPC token placement
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow the existing TypeScript and React patterns
- Use Prettier for code formatting
- Write meaningful commit messages
- Add tests for new features
| Category | Technology | Purpose |
|---|---|---|
| Framework | Next.js 14+ | React framework with SSR |
| Language | TypeScript | Type-safe JavaScript |
| Styling | Tailwind CSS | Utility-first CSS framework |
| State | Zustand | Lightweight state management |
| Canvas | HTML5 Canvas | High-performance 2D rendering |
| Storage | LocalStorage | Client-side data persistence |
| Linting | ESLint | Code quality and consistency |
| Formatting | Prettier | Code formatting |
This project is licensed under the MIT License - see the LICENSE file for details.
- Dungeons & Dragons - For inspiring countless adventures
- Next.js Team - For the amazing React framework
- Tailwind CSS - For making styling enjoyable
- Zustand - For elegant state management
- The D&D Community - For continuous inspiration and feedback
Zac - GitHub: @zac-computer
Project Link: https://github.com/zac-computer/dnd-map-builder
โญ Star this repo if you found it helpful! โญ
Made with โค๏ธ for the D&D community

