Skip to content

ylureault/WorldWar

Repository files navigation

Pixel War World ๐ŸŽจ

A massively multiplayer real-time pixel war game where players join clans to conquer a pixelated world map.


๐Ÿš€ QUICK START - 3 EASY METHODS

Method 1: Visual Guide (Recommended for beginners)

Open setup.html in your web browser - Beautiful step-by-step installation guide!

Method 2: Automatic Installation

# Linux/Mac
bash install.sh

# Windows
install.bat

Method 3: One Command

npm run install-all
npm start

Then open: http://localhost:5173

๐Ÿ“– Having issues? See TROUBLESHOOTING.md or START_HERE.md


โœจ Features

  • ๐ŸŽฏ Real-time gameplay: Place 1 pixel every 30 seconds
  • โš”๏ธ Clan warfare: Join or create clans with unique colors
  • ๐ŸŽฎ Custom wars: Create your own war with customizable parameters
  • ๐Ÿ“Š Live statistics: Real-time tracking of territory, momentum, and activity
  • ๐Ÿ”— Invitation system: Share wars and clan invites via unique codes
  • โšก Optimized performance: Chunked canvas loading, WebSocket updates, Redis caching
  • ๐Ÿ“ฑ Responsive design: Works on desktop and mobile browsers

๐Ÿš€ Quick Start

# Install dependencies
npm install

# Start Redis
docker-compose up -d

# Start development servers
npm run dev

Visit http://localhost:5173 to play!

๐Ÿ› ๏ธ Tech Stack

Backend

  • Node.js + TypeScript - Server runtime
  • Express - Web framework
  • Socket.io - Real-time WebSocket communication
  • Redis - In-memory data store (no database!)
  • JWT - Authentication

Frontend

  • React + TypeScript - UI framework
  • HTML5 Canvas - High-performance map rendering
  • Zustand - State management
  • Vite - Lightning-fast build tool
  • Socket.io Client - Real-time updates

๐Ÿ“ Project Structure

WorldWar/
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ backend/              # Node.js API server
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config/      # Redis configuration
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ routes/      # API endpoints
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ services/    # Business logic
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ websocket/   # WebSocket handlers
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ index.ts     # Server entry
โ”‚   โ”‚   โ””โ”€โ”€ package.json
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ frontend/            # React web app
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ api/        # API client
โ”‚       โ”‚   โ”œโ”€โ”€ components/ # React components
โ”‚       โ”‚   โ”œโ”€โ”€ pages/      # Page components
โ”‚       โ”‚   โ”œโ”€โ”€ stores/     # Zustand stores
โ”‚       โ”‚   โ””โ”€โ”€ hooks/      # Custom hooks
โ”‚       โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ docs/                    # Documentation
โ”‚   โ”œโ”€โ”€ INSTALLATION.md     # Setup guide
โ”‚   โ”œโ”€โ”€ DEVELOPMENT.md      # Dev guide
โ”‚   โ””โ”€โ”€ API.md              # API documentation
โ”œโ”€โ”€ docker-compose.yml       # Redis service
โ””โ”€โ”€ README.md

๐Ÿ“– Documentation

๐ŸŽฎ Game Rules

Pixel Placement

  • Place 1 pixel every 30 seconds
  • Claim neutral pixels or convert enemy pixels
  • Cannot change your own clan's pixels

War Configuration

  • Duration: 1-168 hours (1 hour to 7 days)
  • Map Sizes: Small (1500x1000), Medium (3000x1500), Large (4500x2250)
  • Clans: 2-16 clans per war
  • Adjacency Rule: (Optional) Pixels must be adjacent to clan territory

Victory

  • Clan with most territory at war end wins
  • Live tracking of:
    • Territory percentage
    • Momentum (pixels/minute)
    • Efficiency (conversion rate)
    • Active players

๐Ÿ—๏ธ Installation

Prerequisites

Development Setup

# 1. Clone repository
git clone <repository-url>
cd WorldWar

# 2. Install dependencies
npm install

# 3. Start Redis (Docker)
docker-compose up -d

# 4. Copy environment files
cp packages/backend/.env.example packages/backend/.env
cp packages/frontend/.env.example packages/frontend/.env

# 5. Start dev servers
npm run dev

Frontend: http://localhost:5173 Backend: http://localhost:3000

Production Build

npm run build
npm start

๐Ÿงช Testing the Game

  1. Register a user account
  2. Create a new war with 2+ clans
  3. Open multiple browser windows/tabs
  4. Join different clans in each window
  5. Start the war
  6. Place pixels and watch real-time updates!

๐Ÿ”‘ Key Features Implementation

Real-time Updates

  • WebSocket broadcasts pixel placements to all connected clients
  • Automatic stats refresh every 10 seconds
  • Instant visual feedback

Chunked Map Loading

  • Map divided into 64x64 pixel chunks
  • Only loads visible chunks
  • Optimized for large maps (up to 4500x2250 pixels)

Cooldown System

  • Server-side enforcement (30s default)
  • Redis-based with TTL
  • Client receives countdown updates

Adjacency Rule

  • Optional rule requiring pixels adjacent to clan territory
  • Prevents isolated pixel spam
  • First pixel always allowed

๐Ÿ›ฃ๏ธ Roadmap / Future Features

  • War replay/timelapse system
  • Permanent user profiles & statistics
  • War seasons with global leaderboards
  • Custom map shapes (not just rectangles)
  • Power-ups and special pixels
  • Mobile PWA with touch controls
  • Discord bot integration
  • War templates and presets

๐Ÿค Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

๐Ÿ“ License

MIT License - feel free to use for your own projects!

๐Ÿ› Troubleshooting

Redis connection error?

redis-cli ping  # Should return PONG

Port already in use?

# Change PORT in packages/backend/.env
# Change port in packages/frontend/vite.config.ts

Module not found?

rm -rf node_modules packages/*/node_modules
npm install

๐Ÿ“ง Support

  • Open an issue on GitHub
  • Check the documentation
  • Review closed issues for solutions

Built with โค๏ธ for the pixel art community

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors