Skip to content

gratis-katze/GeometryWar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Geometry War

A geometric tower defense game built with Phaser.js and Node.js, featuring both single-player and real-time multiplayer modes.

๐ŸŽฎ Game Overview

Geometry War is a strategic tower defense game where players control geometric units (squares, triangles, rectangles) and defensive turrets to battle against enemy forces. The game features:

  • Single Player Mode: Battle against AI enemies with progressive difficulty
  • Multiplayer Mode: Real-time PvP battles with friends over the network
  • Unit Types: Square (tank), Triangle (ranged), Rectangle (heavy melee)
  • Turret Defense: Rock Thrower and Archer Tower defensive structures
  • Resource Management: Gold-based economy system

๐Ÿ“‹ Prerequisites

Before running the game, ensure you have:

  • Node.js (v16.0.0 or higher)
  • npm (comes with Node.js)
  • Modern web browser (Chrome, Firefox, Safari, Edge)

๐Ÿš€ Installation

  1. Clone or download the project to your local machine
  2. Navigate to the project directory:
    cd geometrywar
  3. Install dependencies:
    npm install

๐ŸŽฏ Game Modes & Startup Instructions

1. Single Player Mode (Development)

Best for: Testing gameplay mechanics, learning controls, development

npm run dev
  • Access: Open your browser to http://localhost:3000
  • Features: Full single-player campaign, all units and turrets available
  • Network: No server required, runs entirely in browser

2. Multiplayer Mode (Local Network)

Best for: Playing with friends on the same network

npm run dev:multiplayer

This command starts both:

  • Game server on http://localhost:3001
  • Client on http://localhost:3000

How to Play Multiplayer:

  1. Host Player:

    • Go to http://localhost:3000
    • Click "Multiplayer"
    • Click "Create Room"
    • Share the room code with your friend
  2. Joining Player:

    • Go to http://localhost:3000 (or http://[HOST-IP]:3000 if on different computer)
    • Click "Multiplayer"
    • Enter the room code
    • Click "Join Room"
  3. Both players click "Ready" to start the game

3. Network Multiplayer (Multiple Computers)

Best for: Playing across different computers on the same network

npm run network

This will:

  • Start the multiplayer server accessible to other devices
  • Display network IP addresses for remote access
  • Show connection URLs for other players

Connection URLs will be shown like:

  • Local: http://localhost:3000
  • Network: http://192.168.1.138:3000 (example IP)

4. Server Only Mode

Best for: Dedicated server hosting

npm run server
  • Runs only the multiplayer server on port 3001
  • Players connect using separate client instances
  • Useful for persistent game hosting

5. Production Build

Best for: Deploying the game

# Build the game
npm run build

# Preview the built game
npm run preview

๐Ÿงช Development & Testing

Run Tests

# Run all tests
npm test

# Run tests with UI
npm run test:ui

Development with Hot Reload

# Single player with hot reload
npm run dev

# Multiplayer with hot reload (both server and client)
npm run dev:multiplayer

๐ŸŽฎ Game Controls

Single Player

  • Unit Spawning: Click unit buttons (Square, Triangle, Rectangle)
  • Turret Placement: Click turret button, then click turret slot
  • Turret Selling: Click "Sell Turret", then click the turret to sell

Multiplayer

  • Player Side (Blue): Controls on top of screen
  • Enemy Side (Red): Controls on bottom of screen
  • Same controls as single player, but for your assigned side only

Unit Types

  • Square ($15): Tank unit, high health, melee attack
  • Triangle ($35): Ranged unit, projectile attack, moderate health
  • Rectangle ($30): Heavy melee unit, high damage and health

Turret Types

  • Rock Thrower ($50): Basic defensive turret
  • Archer Tower ($75): Advanced ranged defense

๐ŸŒ Network Configuration

Firewall Settings

If playing across computers, ensure port 3001 is accessible:

Windows:

netsh advfirewall firewall add rule name="Geometry War Server" dir=in action=allow protocol=TCP localport=3001

macOS:

  • Go to System Preferences โ†’ Security & Privacy โ†’ Firewall
  • Add Node.js to allowed applications

Linux:

sudo ufw allow 3001/tcp

Finding Your Network IP

Windows:

ipconfig | findstr "IPv4"

macOS/Linux:

ifconfig | grep "inet "

๐Ÿ”ง Troubleshooting

Common Issues

"Cannot connect to server"

  • Ensure the server is running (npm run server or npm run dev:multiplayer)
  • Check if port 3001 is available and not blocked by firewall
  • Verify the correct IP address for network play

"Room not found"

  • Make sure both players are connected to the same server
  • Verify the room code is entered correctly
  • Try creating a new room

Units not spawning

  • Check if you have sufficient gold (displayed at top of screen)
  • Ensure you're in an active game (both players ready)
  • Look for error messages in browser console (F12)

Performance issues

  • Close other browser tabs
  • Ensure stable network connection for multiplayer
  • Try refreshing the page

Debug Mode

Open browser console (F12) to see detailed game logs including:

  • Unit spawning attempts and results
  • Network connection status
  • Gold transactions
  • Turret placement and selling events

Getting Help

  1. Check the browser console for error messages
  2. Verify network connectivity and firewall settings
  3. Ensure all players are using the same game version
  4. Try restarting the server and reconnecting

๐Ÿ› ๏ธ Development

Project Structure

geometrywar/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ scenes/          # Game scenes (Menu, Game, Multiplayer)
โ”‚   โ”œโ”€โ”€ units/           # Unit classes and configurations
โ”‚   โ”œโ”€โ”€ turrets/         # Turret classes and configurations
โ”‚   โ”œโ”€โ”€ network/         # Network management
โ”‚   โ””โ”€โ”€ test/           # Test files
โ”œโ”€โ”€ server.js           # Multiplayer server
โ”œโ”€โ”€ package.json        # Dependencies and scripts
โ””โ”€โ”€ README.md          # This file

Available Scripts

  • npm run dev - Development mode (single player)
  • npm run dev:multiplayer - Development mode (multiplayer)
  • npm run server - Server only
  • npm run network - Network multiplayer
  • npm run build - Production build
  • npm run preview - Preview production build
  • npm test - Run tests
  • npm run test:ui - Run tests with UI

๐ŸŽฏ Tips for Best Experience

  1. Start with single player to learn the game mechanics
  2. Use local network for the smoothest multiplayer experience
  3. Ensure stable internet when playing across different networks
  4. Check console logs if you encounter any issues
  5. Both players should ready up to start multiplayer games

Enjoy playing Geometry War! ๐ŸŽฎโœจ

About

AgeOfWar inspired Game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors