Skip to content

Welcome to the Battle Simulator, a real-time strategy game where two armies clash on a battlefield. Customize your soldiers, manage resources, and watch the action unfold as your troops battle for victory. This game is built using React, featuring dynamic animations and custom AI behaviors.

License

Notifications You must be signed in to change notification settings

dimitarbez/battle-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

27 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โš”๏ธ Battle Simulator - Strategic Warfare Game

Welcome to Battle Simulator - an interactive, real-time strategy game where you command armies in epic battles! Built with modern React and featuring a mobile-first responsive design, this project showcases advanced web development techniques while providing endless entertainment.

๐ŸŽฎ Play Live Demo | ๐Ÿ“ฑ Mobile Optimized | ๐ŸŒŸ Open Source

Battle Simulator Screenshot

โœจ What Makes This Special

  • ๐ŸŽฏ Real-time Combat Simulation - Watch armies battle with intelligent AI behavior
  • ๏ฟฝ Mobile-First Design - Optimized for all devices from phones to desktops
  • โš™๏ธ Customizable Army Stats - Fine-tune health, damage, speed, morale, and more
  • ๐ŸŽจ Modern UI/UX - Beautiful gradients, animations, and intuitive controls
  • ๐Ÿš€ High Performance - Hardware-accelerated animations and optimized rendering
  • โ™ฟ Accessible - Keyboard navigation, screen reader support, and proper contrast

๐Ÿš€ Quick Start

Get the battle simulator running on your machine in under 2 minutes:

# Clone the repository
git clone https://github.com/dimitarbez/battle-simulator.git
cd battle-simulator

# Install dependencies
npm install

# Start the development server
npm start

Open http://localhost:3000 and start commanding your armies! ๐ŸŽ‰

๐ŸŽฎ How to Play

1. Deploy Your Forces

  • Select Army 1 (Blue) or Army 2 (Red) from the sidebar
  • Click and drag on the battlefield to place soldiers
  • Create strategic formations and positioning

2. Configure Your Army

Customize your army's capabilities:

  • โค๏ธ Health: Hit points per soldier (1-100)
  • โš”๏ธ Damage: Attack power (1-100)
  • ๐Ÿƒ Speed: Movement speed (1-100)
  • ๐Ÿ›ก๏ธ Morale: Combat effectiveness (1-100)
  • โฑ๏ธ Attack Rate: Time between attacks (100-2000ms)
  • ๐ŸŽฏ Range: Attack distance (1-150)

3. Command the Battle

  • Click "Start Battle" to begin the real-time simulation
  • Watch your armies engage with intelligent combat AI
  • Analyze the battle with live statistics and HUD

4. Victory Conditions

  • Eliminate all enemy soldiers
  • Force enemy retreat through morale damage
  • Strategic positioning and army composition matter!

๐Ÿ› ๏ธ Tech Stack & Architecture

This project demonstrates modern web development best practices:

Frontend Framework

  • React 18 - Latest features with concurrent rendering
  • Custom Hooks - Modular state management and game logic
  • React Spring - Smooth, performant animations

Styling & Design

  • Tailwind CSS - Utility-first CSS framework
  • Mobile-First Responsive Design - Works on all screen sizes
  • CSS Grid & Flexbox - Modern layout techniques
  • Hardware Acceleration - Optimized for 60fps animations

Game Architecture

  • Custom Physics Engine - Collision detection and movement
  • AI Behavior System - Intelligent soldier decision-making
  • Real-time Simulation Loop - Efficient game state updates
  • Performance Optimizations - Minimized re-renders and memory usage

๐ŸŽจ Features & Highlights

User Experience

  • ๐Ÿ“ฑ Mobile Optimized - Touch gestures and responsive layout
  • โŒจ๏ธ Keyboard Shortcuts - Power user features
  • ๐ŸŽฏ Intuitive Controls - Drag-to-place soldiers, easy army switching
  • ๐Ÿ“Š Live Statistics - Real-time battle analytics and army status
  • ๐Ÿ’ก Interactive Help - Built-in tutorials and guidance

Visual Design

  • ๐ŸŒˆ Modern Gradients - Beautiful color schemes and visual depth
  • โœจ Smooth Animations - Engaging soldier movements and battle effects
  • ๐ŸŽญ State-Based Animations - Soldiers react to combat situations
  • ๐Ÿ–ผ๏ธ Dynamic Backgrounds - Immersive battlefield environments
  • ๐ŸŽช Victory Celebrations - Satisfying win conditions

Technical Excellence

  • โšก High Performance - Optimized for smooth 60fps gameplay
  • ๐Ÿ”ง Modular Architecture - Clean, maintainable code structure
  • ๐Ÿงช Modern React Patterns - Hooks, context, and best practices
  • ๐Ÿ“ฑ PWA-Ready - Installable web app capabilities
  • ๐Ÿ›ก๏ธ Type Safety - JSDoc annotations and prop validation

๐Ÿค Contributing - We Want You!

Battle Simulator is an open-source project that thrives on community contributions! Whether you're a seasoned developer or just starting out, there are many ways to get involved:

๐ŸŒŸ Easy First Contributions

Perfect for newcomers to open source:

  • ๐ŸŽจ Add new army presets (Archer armies, Tank formations, etc.)
  • ๐ŸŒ Improve responsive design for specific devices
  • ๐Ÿ“ Enhance documentation and add code comments
  • ๐Ÿ› Report bugs or suggest UI/UX improvements
  • ๐ŸŽญ Create new soldier animations or visual effects

๐Ÿ”ง Intermediate Features

Great for developers wanting to dive deeper:

  • ๐ŸŽต Add sound effects and background music
  • ๐Ÿž๏ธ Create different battlefield terrains and environments
  • ๐Ÿ“Š Implement battle statistics and replay system
  • ๐ŸŽฎ Add keyboard shortcuts and accessibility features
  • ๐ŸŽฏ Improve AI behavior and battle strategies

๐Ÿš€ Advanced Challenges

For experienced developers looking for exciting projects:

  • ๐ŸŒ Multiplayer Mode - Real-time battles between players
  • ๐Ÿค– Advanced AI - Machine learning for smarter armies
  • ๐Ÿ—บ๏ธ Campaign Mode - Story-driven battles and progression
  • ๐Ÿฐ Formations & Tactics - Complex military strategies
  • โš”๏ธ Unit Types - Cavalry, archers, siege weapons, heroes

๐Ÿ’ก How to Contribute

  1. ๐Ÿด Fork the Repository

    # Click the "Fork" button on GitHub, then:
    git clone https://github.com/YOUR_USERNAME/battle-simulator.git
    cd battle-simulator
  2. ๐ŸŒฟ Create a Feature Branch

    git checkout -b feature/amazing-new-feature
    # or
    git checkout -b fix/important-bug-fix
  3. ๐Ÿ’ป Make Your Changes

    • Write clean, commented code
    • Follow the existing code style
    • Test your changes thoroughly
    • Update documentation if needed
  4. ๐Ÿงช Test Everything

    npm test          # Run the test suite
    npm run build     # Test production build
    npm start         # Test in development mode
  5. ๐Ÿ“ Commit and Push

    git add .
    git commit -m "โœจ Add amazing new feature that does X"
    git push origin feature/amazing-new-feature
  6. ๐Ÿš€ Create a Pull Request

    • Go to your fork on GitHub
    • Click "New Pull Request"
    • Describe what you changed and why
    • Link any relevant issues

๐Ÿ“‹ Contribution Guidelines

  • Code Style: We use Prettier and ESLint - run npm run lint to check
  • Commit Messages: Use descriptive messages with emojis (see examples above)
  • Testing: Add tests for new features when possible
  • Documentation: Update README or add comments for complex features
  • Responsive: Ensure changes work on mobile and desktop
  • Performance: Keep the 60fps target in mind for animations

๐ŸŽ‰ What We Offer Contributors

  • ๐ŸŒŸ Recognition - Your name in our contributors list
  • ๐Ÿ“š Learning - Gain experience with modern React patterns
  • ๐Ÿค Community - Join our friendly developer community
  • ๐Ÿ’ผ Portfolio - Great project to showcase your skills
  • ๐Ÿš€ Impact - Your code will be used by players worldwide!

๐Ÿ› ๏ธ Available Scripts

In the project directory, you can run:

npm start

Runs the game in development mode with hot reload. Open http://localhost:3000 to view it in your browser.

npm run build

Builds the app for production to the build folder. Optimized and minified for best performance.

npm test

Launches the test runner in interactive watch mode. Helps ensure game logic works correctly.

npm run lint

Checks code style and finds potential issues. Run this before submitting pull requests!

๐ŸŒ Deployment & Hosting

The game is automatically deployed to production on every push to main branch. You can deploy your own version easily:

GitHub Pages (Recommended)

npm run build
npm run deploy  # If you have gh-pages configured

Netlify (Drag & Drop)

  1. Run npm run build
  2. Drag the build folder to Netlify Drop
  3. Your game is live! ๐ŸŽ‰

Vercel (One Click)

  1. Connect your GitHub repo to Vercel
  2. Automatic deployments on every push
  3. Perfect for React applications

๐Ÿ“š Project Structure

battle-simulator/
โ”œโ”€โ”€ ๐Ÿ“ public/                 # Static assets and HTML template
โ”œโ”€โ”€ ๐Ÿ“ src/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ components/         # React components
โ”‚   โ”‚   โ”œโ”€โ”€ Battlefield.js     # Main game area
โ”‚   โ”‚   โ”œโ”€โ”€ BattlefieldControls.js  # Army selection & controls
โ”‚   โ”‚   โ”œโ”€โ”€ ArmyStatsPanel.js  # Army configuration
โ”‚   โ”‚   โ”œโ”€โ”€ Soldier.js         # Individual soldier rendering
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ hooks/              # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ useBattlefield.js  # Battlefield state management
โ”‚   โ”‚   โ”œโ”€โ”€ useArmyStats.js    # Army statistics
โ”‚   โ”‚   โ””โ”€โ”€ useBattleSimulation.js  # Game simulation logic
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ utils/              # Utility functions
โ”‚   โ”‚   โ””โ”€โ”€ battleUtils.js     # Game mechanics & physics
โ”‚   โ”œโ”€โ”€ App.js                 # Main application component
โ”‚   โ”œโ”€โ”€ index.js              # React app entry point
โ”‚   โ””โ”€โ”€ index.css             # Global styles and animations
โ”œโ”€โ”€ package.json              # Dependencies and scripts
โ”œโ”€โ”€ tailwind.config.js        # Tailwind CSS configuration
โ””โ”€โ”€ README.md                 # You are here! ๐Ÿ“

๐ŸŽฏ Game Mechanics Deep Dive

Combat System

  • Damage Calculation: Base damage ยฑ random variance for realism
  • Morale System: Soldiers retreat when morale drops below threshold
  • Range Mechanics: Different weapons have different effective ranges
  • Attack Cooldowns: Balanced timing prevents spam attacks

AI Behavior

  • Target Selection: Closest enemy prioritization
  • Movement AI: Pathfinding around obstacles and other soldiers
  • State Machine: Idle โ†’ Moving โ†’ Attacking โ†’ Retreating โ†’ Celebrating
  • Group Dynamics: Soldiers influence each other's morale

Physics Engine

  • Collision Detection: Circular collision bounds for all entities
  • Boundary Checking: Soldiers stay within battlefield limits
  • Smooth Movement: Interpolated animations for fluid gameplay
  • Performance Optimization: Spatial partitioning for large armies

๐ŸŒŸ Community & Support

Get Help

  • ๐Ÿ’ฌ Discussions - Ask questions in GitHub Discussions
  • ๐Ÿ› Bug Reports - Create detailed issues with reproduction steps
  • ๐Ÿ’ก Feature Requests - Share your ideas for new features
  • ๐Ÿ“ง Direct Contact - Reach out to maintainers for urgent matters

Show Your Support

  • โญ Star this repo if you enjoyed the project
  • ๐Ÿฆ Share on social media - Help others discover the game
  • ๐Ÿ’ Contribute code - Any improvement is welcome
  • ๐Ÿ“ Write about it - Blog posts and tutorials appreciated

๐Ÿ† Acknowledgments & Credits

Built With Love Using

Inspired By

  • Classic RTS games like Age of Empires and StarCraft
  • Modern web-based strategy games
  • The joy of watching armies clash in epic battles! โš”๏ธ

Special Thanks

  • All our amazing contributors ๐Ÿ™
  • The open-source community for tools and inspiration
  • Players who provide feedback and suggestions

๐Ÿ“„ License

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

TL;DR: Feel free to use, modify, and distribute this code. Just give credit where it's due! ๐Ÿ˜Š


๐Ÿš€ Ready to Build Something Amazing?

Start Contributing Today!

Made with โค๏ธ by developers who love strategy games

About

Welcome to the Battle Simulator, a real-time strategy game where two armies clash on a battlefield. Customize your soldiers, manage resources, and watch the action unfold as your troops battle for victory. This game is built using React, featuring dynamic animations and custom AI behaviors.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •