Skip to content

zac-computer/dnd-map-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—บ๏ธ DnD Map Builder

Next.js TypeScript Tailwind CSS Zustand License: MIT Live Demo Deploy with Vercel

A modern, interactive web-based map builder designed for Dungeon Masters to create stunning custom maps for their tabletop RPG campaigns.

โœจ Features

๐ŸŽจ Intuitive Map Creation

  • 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

๐Ÿ”ง Advanced Functionality

  • 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

๐Ÿš€ Modern Architecture

  • 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

๐ŸŽฏ Demo

๐Ÿš€ Live Demo: https://zhuzh.dev - Try it now!

Screenshots

Map Creation Interface

๐Ÿ–ผ๏ธ Screenshot placeholder - Main interface with toolbar and canvas

Terrain Painting in Action

Terrain Painting Demo

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.

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18.0 or higher
  • npm 9.0 or higher

Installation

  1. Clone the repository

    git clone https://github.com/zac-computer/dnd-map-builder.git
    cd dnd-map-builder
  2. Install dependencies

    npm install
  3. Start the development server

    npm run dev
  4. Open your browser Navigate to http://localhost:3000

๐ŸŽฎ Usage Guide

Basic Controls

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

Terrain Types

  • ๐ŸŒฑ Grass - Basic ground terrain
  • ๐Ÿ’ง Water - Rivers, lakes, oceans
  • ๐Ÿ–๏ธ Sand - Beaches, deserts
  • ๐Ÿ—ฟ Stone - Rocky terrain, pathways

Objects

  • ๐ŸŒณ Trees - Forest elements
  • ๐Ÿชจ Rocks - Natural obstacles
  • ๐Ÿ  Buildings - Structures and settlements

Available Demo Maps

1. ๐Ÿจ The Riverside Tavern (30ร—25 grid)

  • 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

2. โ›ฐ๏ธ Treacherous Mountain Pass (25ร—20 grid)

  • 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

๐Ÿ—๏ธ Project Structure

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

Available Scripts

# 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 formatting

๐Ÿค– Working with Claude Code

This 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.

Quick Start with Claude Code

  1. Install Claude Code (if not already installed)

    npm install -g @anthropic-ai/claude-code
    # Ref: https://docs.anthropic.com/claude-code
  2. Navigate to project directory

    cd dnd-map-builder
  3. Start Claude Code

    claude

What Claude Code Can Help With

  • 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"

Example Commands

# 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"

Project Context

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

Best Practices with Claude Code

  • 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

Architecture Decisions

๐Ÿ—๏ธ 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

๐Ÿ”ฎ Roadmap

Version 1.1 - Enhanced Features

  • 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

Version 2.0 - Collaboration

  • 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

Version 3.0 - Advanced Tools

  • 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

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style

  • Follow the existing TypeScript and React patterns
  • Use Prettier for code formatting
  • Write meaningful commit messages
  • Add tests for new features

๐Ÿ† Tech Stack

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

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • 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

๐Ÿ“ž Contact

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

About

A modern, interactive web-based map builder for D&D campaigns

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •