Skip to content

PixelRPG/map-editor

Repository files navigation

PixelRPG Map Editor

A modern, cross-platform tile-based map editor for creating 2D RPG games, built with cutting-edge web technologies and native desktop integration. Combines the power of Excalibur.js game engine with GTK/Adwaita for a seamless development experience across web and desktop platforms.

โœจ Features

  • Cross-Platform: Native desktop app (GTK/GJS) and web browser support
  • Real-time Engine: Live preview with Excalibur.js game engine integration
  • Tile-based Editing: Intuitive tilemap creation and editing tools
  • Project Management: Organized project structure with asset management
  • RPC Communication: Bidirectional communication between UI and game engine
  • Type Safety: Full TypeScript support for reliable development
  • Modern UI: GTK 4 with Adwaita design language for desktop, responsive web interface
  • Live Development: Hot-reload development workflow

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ with npm or yarn
  • For Desktop App: GNOME development environment with GJS
  • For Web App: Modern web browser with WebGL support

Installation

# Clone the repository
git clone https://github.com/your-org/pixelrpg-map-editor.git
cd pixelrpg-map-editor

# Install dependencies
yarn install

Launch Desktop Application

# Start the GJS/GTK desktop application
yarn workspace @pixelrpg/maker-gjs start

Launch Web Application

# Start the web development server
yarn workspace @pixelrpg/maker-web dev

๐Ÿ“ Project Structure

pixelrpg-map-editor/
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ maker-gjs/           # Primary GTK/GJS desktop application
โ”‚   โ”œโ”€โ”€ maker-web/           # Web browser version for testing
โ”‚   โ””โ”€โ”€ storybook-gjs/       # Component library and documentation
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ engine-core/         # Core engine interfaces and types
โ”‚   โ”œโ”€โ”€ engine-excalibur/    # Web-based game engine implementation
โ”‚   โ”œโ”€โ”€ engine-gjs/          # GTK/GJS engine integration
โ”‚   โ”œโ”€โ”€ message-channel-core/# Core messaging infrastructure
โ”‚   โ”œโ”€โ”€ message-channel-gjs/ # GJS messaging implementation
โ”‚   โ”œโ”€โ”€ message-channel-web/ # Web messaging implementation
โ”‚   โ”œโ”€โ”€ message-channel-webview/ # WebView messaging implementation
โ”‚   โ”œโ”€โ”€ data-core/           # Core data structures and utilities
โ”‚   โ”œโ”€โ”€ data-gjs/            # GJS data layer implementation
โ”‚   โ”œโ”€โ”€ data-excalibur/      # Web data layer implementation
โ”‚   โ””โ”€โ”€ ui-gjs/              # GTK UI components
โ”œโ”€โ”€ games/
โ”‚   โ””โ”€โ”€ zelda-like/          # Sample game project
โ””โ”€โ”€ docs/                    # Documentation and guides

๐Ÿ› ๏ธ Development

Development Workflow

# Install all dependencies
yarn install

# Start desktop development
yarn workspace @pixelrpg/maker-gjs dev

# Start web development
yarn workspace @pixelrpg/maker-web dev

# Build all packages
yarn build

# Run tests
yarn test

# Type checking
yarn type-check

Development Commands

# Desktop Application
yarn workspace @pixelrpg/maker-gjs start    # Launch application
yarn workspace @pixelrpg/maker-gjs build   # Build for distribution

# Web Application
yarn workspace @pixelrpg/maker-web dev     # Development server
yarn workspace @pixelrpg/maker-web build   # Production build
yarn workspace @pixelrpg/maker-web preview # Preview production build

# Engine Packages
yarn workspace @pixelrpg/engine-excalibur dev    # Engine development
yarn workspace @pixelrpg/engine-excalibur build  # Engine build

# Utilities
yarn workspace @pixelrpg/storybook-gjs start     # Component documentation

๐ŸŽฎ Architecture

Desktop Architecture (GJS/GTK)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     RPC      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   GTK UI        โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚   WebKit        โ”‚
โ”‚   (Adwaita)     โ”‚             โ”‚   WebView       โ”‚
โ”‚                 โ”‚             โ”‚                 โ”‚
โ”‚ โ€ข Project View  โ”‚             โ”‚ โ€ข Excalibur.js  โ”‚
โ”‚ โ€ข Asset Browser โ”‚             โ”‚ โ€ข Game Canvas   โ”‚
โ”‚ โ€ข Property      โ”‚             โ”‚ โ€ข Live Preview  โ”‚
โ”‚   Inspector     โ”‚             โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Web Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     RPC      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Web UI        โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚   iframe        โ”‚
โ”‚   (React/HTML)  โ”‚             โ”‚   WebView       โ”‚
โ”‚                 โ”‚             โ”‚                 โ”‚
โ”‚ โ€ข Project View  โ”‚             โ”‚ โ€ข Excalibur.js  โ”‚
โ”‚ โ€ข Asset Browser โ”‚             โ”‚ โ€ข Game Canvas   โ”‚
โ”‚ โ€ข Property      โ”‚             โ”‚ โ€ข Live Preview  โ”‚
โ”‚   Inspector     โ”‚             โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“– Usage Examples

Creating a New Project

import { Engine } from '@pixelrpg/engine-gjs';
import { RpcEngineType } from '@pixelrpg/engine-core';

// Create engine instance
const engine = new Engine();

// Initialize and load project
await engine.initialize();
await engine.loadProject('/path/to/project.json');

// Handle engine events
engine.connect(RpcEngineType.PROJECT_LOADED, (source, projectId) => {
  console.log('Project loaded:', projectId);
});

Working with Maps

// Load a specific map
await engine.loadMap('overworld');

// Start the game engine
await engine.start();

// Handle map events
engine.connect(RpcEngineType.MAP_LOADED, (source, mapId) => {
  console.log('Map loaded:', mapId);
});

๐Ÿ› Troubleshooting

Common Issues

WebKit/WebView Issues

If you encounter WebKit-related errors:

# Check WebKit installation (Ubuntu/Debian)
sudo apt install webkit2gtk-4.1-dev

# For Fedora/CentOS
sudo dnf install webkitgtk4.1-devel

Permission Errors

If you see bwrap: setting up uid map: Permission denied:

# Solution for Ubuntu 24.04+
sudo systemctl enable --now systemd-userdbd
sudo loginctl enable-linger $USER

Build Errors

# Clear node_modules and reinstall
rm -rf node_modules yarn.lock
yarn install

# Clear build cache
yarn workspace @pixelrpg/maker-gjs clean
yarn build

Development Tips

  • Use yarn workspace <package> <command> for package-specific operations
  • Enable TypeScript strict mode for better development experience
  • Use the Storybook for component development and testing
  • Check the console for detailed error messages in WebKit WebView

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Make your changes with proper TypeScript types
  4. Add tests for new functionality
  5. Ensure all tests pass: yarn test
  6. Submit a pull request

Development Guidelines

  • Use TypeScript for all new code
  • Follow the established project structure
  • Add JSDoc comments for public APIs
  • Write tests for new features
  • Update documentation for API changes

๐Ÿ“š Documentation

๐Ÿงช Testing

# Run all tests
yarn test

# Run tests for specific package
yarn workspace @pixelrpg/engine-core test

# Run tests in watch mode
yarn test:watch

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

  • Excalibur.js - 2D game engine
  • GTK - GNOME UI toolkit
  • GJS - JavaScript bindings for GNOME
  • WebKit - Web rendering engine

๐Ÿ“ž Support

About

Experimental tile based map editor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages