Skip to content

Repository files navigation

""" README.md - Documentation for 2D RTS Game """

2D RTS Game

A 2D Real-Time Strategy game built with Python and Pygame.

Features

  • Strategic gameplay with resource management and base building
  • Multiple unit types with different abilities and strengths
  • Combat system with different attack and defense types
  • Advanced AI opponent with adaptive strategies
  • Economy system with resource gathering and production
  • Inventory system for items and equipment
  • Save/load functionality to continue your progress
  • Content editor for customizing game elements
  • Pathfinding system for intelligent unit movement

Requirements

  • Python 3.6 or higher
  • Pygame 2.0.0 or higher

Installation

  1. Clone or download this repository
  2. Install the required dependencies:
    pip install pygame
    
  3. Run the game:
    python main.py
    

How to Play

Basic Controls

  • Left-click: Select units or buildings
  • Left-click and drag: Select multiple units
  • Right-click: Move selected units or attack enemy units/buildings
  • WASD or Arrow keys: Move camera
  • Mouse wheel: Zoom in/out
  • ESC: Open game menu

Game Mechanics

  • Resource Gathering: Use worker units to gather gold, wood, and stone
  • Base Building: Construct buildings to produce units and research upgrades
  • Unit Production: Train different types of units from production buildings
  • Combat: Command your units to attack enemy forces and structures
  • Economy: Manage your resources to sustain your army and expand your base

Unit Types

  • Worker: Gathers resources and constructs buildings
  • Soldier: Basic combat unit with balanced stats
  • Tank: Heavy combat unit with high health and damage
  • Helicopter: Fast aerial unit that can fly over obstacles

Building Types

  • Command Center: Main building, produces workers
  • Barracks: Produces soldiers
  • Factory: Produces tanks and other vehicles
  • Mine: Increases gold production
  • Lumber Mill: Increases wood production

Game Systems

Economy System

The game features a comprehensive economy system where players must gather and manage resources:

  • Gold: Used for training units and researching technologies
  • Wood: Used for constructing buildings and some units
  • Stone: Used for advanced buildings and upgrades

Combat System

The combat system includes:

  • Different attack types (melee, ranged, explosive, siege)
  • Different defense types (light, medium, heavy, building)
  • Attack and defense modifiers based on type matchups
  • Visual effects for attacks and unit destruction

AI System

The AI opponent features:

  • Multiple difficulty levels
  • Adaptive strategy based on game state
  • Resource gathering and base expansion
  • Military unit production and tactical combat

Inventory System

Units and buildings can store and use items:

  • Resource items that can be gathered and stored
  • Equipment items that provide bonuses when equipped
  • Consumable items with one-time effects

Save/Load System

The game allows players to:

  • Save their progress at any time
  • Load previously saved games
  • Autosave functionality to prevent progress loss

Development

Project Structure

  • main.py: Entry point for the game
  • core/: Core game systems and logic
    • game.py: Main game class
    • map.py: Map generation and rendering
    • entity_manager.py: Entity management
    • input_handler.py: User input processing
    • resource_manager.py: Resource management
    • combat_system.py: Combat mechanics
    • economy_system.py: Economy mechanics
    • ai_controller.py: AI behavior
    • animation_system.py: Sprite animations
    • inventory_system.py: Item management
    • save_load_system.py: Game state persistence
    • pathfinding_system.py: Unit movement AI
    • game_tester.py: Automated testing
    • game_optimizer.py: Performance optimization
  • ui/: User interface components
    • ui_manager.py: UI management
    • resource_display.py: Resource UI
    • building_menu.py: Building selection UI
    • unit_info_panel.py: Unit information UI
    • content_editor_panel.py: Game content editor
  • data/: Game data files
    • units.json: Unit definitions
    • buildings.json: Building definitions
    • transport.json: Transport definitions
    • items.json: Item definitions
  • assets/: Game assets
    • sprites/: Game sprites and images

Extending the Game

The game is designed to be easily extendable:

  1. Add new unit types in data/units.json
  2. Add new building types in data/buildings.json
  3. Add new items in data/items.json
  4. Modify game parameters in config.json

Troubleshooting

If you encounter any issues:

  1. Make sure you have the correct Python and Pygame versions installed
  2. Check the console for error messages
  3. Try running the game with the --debug flag for more information:
    python main.py --debug
    

Credits

This 2D RTS game was created as a demonstration of game development with Python and Pygame.

License

This project is available for personal and educational use.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages