https://github.com/myounesdev/hexaclash
A turn-based battle simulator featuring a hexagonal grid, dynamic unit interactions, and epic clashes between Humans and Orcs
https://github.com/myounesdev/hexaclash
c c-language consle cpp curl-library game sfml
Last synced: about 2 months ago
JSON representation
A turn-based battle simulator featuring a hexagonal grid, dynamic unit interactions, and epic clashes between Humans and Orcs
- Host: GitHub
- URL: https://github.com/myounesdev/hexaclash
- Owner: MYounesDev
- Created: 2024-10-10T10:32:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-21T18:28:06.000Z (over 1 year ago)
- Last Synced: 2025-07-05T02:25:47.212Z (about 1 year ago)
- Topics: c, c-language, consle, cpp, curl-library, game, sfml
- Language: C
- Homepage:
- Size: 30.8 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# HexaClash - Battle Simulation Project
## Overview
**HexaClash** is a battle simulation project that simulates a turn-based battle between two teams: the **Human Empire** (`insan_imparatorlugu`) and the **Orc Legion** (`ork_legi`). The project includes a graphical interface built with **SFML (Simple and Fast Multimedia Library)** and uses JSON files to define unit types, heroes, monsters, and research levels. The simulation calculates damage, critical hits, and other battle mechanics, and logs the results to a file.
---
## Features
- **Turn-Based Battle Simulation**: Simulates battles between two teams with attack, defense, and critical hit mechanics.
- **Graphical Interface**: Renders a hexagonal grid with unit images, health bars, and main characters (heroes and monsters).
- **Dynamic Unit Placement**: Units are randomly placed on the grid based on their team.
- **Health Bars and Stats**: Displays health percentages and unit stats in real-time.
- **Interactive UI**: Click on units to enlarge or shrink their images.
- **Sound Effects**: Plays background music during the welcome screen.
- **Logging**: Logs battle results to a file (`savas_sim.txt`).
---
## Prerequisites
Before running the project, ensure you have the following installed:
1. **C/C++ Compiler**:
- GCC (Linux/Mac) or MinGW (Windows).
2. **SFML Library**:
- Download and install SFML from [SFML's official website](https://www.sfml-dev.org/).
- Make sure SFML is properly linked to your project.
3. **CURL** (for downloading scenario files):
- Ensure `curl` is installed on your system.
4. **Windows API** (for sound and system commands):
- Required for `PlaySound` and `system` commands.
---
## Installation
### Step 1: Clone the Repository
```bash
git clone https://github.com/your-username/HexaClash.git
cd HexaClash
```
### Step 2: Install Dependencies
#### On Windows:
-
Download and install
SFML.
-
Add SFML's include and lib directories to your
compiler's search paths.
-
Ensure sfml-audio-2.dll, sfml-graphics-2.dll,
and other SFML DLLs are in the bin/Debug or
bin/Release folder.
#### On Linux/Mac:
Install SFML using your package manager:
```bash
sudo apt-get install libsfml-dev # For Ubuntu/Debian
brew install sfml # For Mac
```
### Step 3: Compile the Project
#### Using GCC:
```bash
g++ -std=c++11 main.c gameInterface.cpp -o HexaClash -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
```
#### Using Code::Blocks
1. open `HexaClash.cbp` using Code::Blocks
2. click "Build and run" or press F9
## Usage
-
Run the Program
-
Enter a Scenario Number:
-
The program will prompt you to enter a scenario number (1-10).
-
The scenario file will be downloaded automatically if it doesn't exist
locally.
-
View the Battle:
-
The graphical interface will display the battle grid, units, and
health bars.
Click on units to enlarge or shrink their images.
-
Battle Simulation:
-
The battle is simulated automatically, and the results are logged to
savas_sim.txt.
-
Replay or Exit:
-
After the battle, you can choose to replay the simulation or exit the
program.
## Project Structure
```mathematica
HexaClash/
├── bin/ # Compiled binaries and SFML DLLs
├── fonts/ # Font files (e.g., Arial.ttf)
├── images/ # Unit, hero, monster, and background images
├── json/ # JSON files for unit types, heroes, monsters, and research
├── music/ # Background music (music.wav)
├── obj/ # Object files (generated during compilation)
├── src/ # Source code files
│ ├── classes.h # Data structures for units, heroes, monsters, and teams
│ ├── fightFunction.h # Battle simulation logic
│ ├── functions.h # Utility functions for file handling and user interaction
│ ├── gameInterface.cpp # Graphical interface implementation
│ ├── main.c # Entry point of the program
├── README.md # Project documentation
```
## JSON File Format
The project uses JSON files to define scenarios. Here's an example structure:
```json
{
"insan_imparatorlugu": {
"birimler": [
{"isim": "piyade", "sayi": 100},
{"isim": "okcu", "sayi": 50}
],
"kahramanlar": [
{"isim": "Alparslan", "bonus_turu": "saldiri", "bonus_degeri": 10, "etkilenen": "piyade"}
],
"canavarlar": [
{"isim": "Ejderha", "etki_turu": "savunma", "etki_degeri": 5, "etkilenen": "okcu"}
],
"arastirma_seviyesi": {
"isim": "savunma_ustaligi",
"seviye": 1,
"oran": 10
}
},
"ork_legi": {
"birimler": [
{"isim": "ork_dovuscu", "sayi": 120},
{"isim": "trol", "sayi": 30}
],
"kahramanlar": [
{"isim": "Goruk_Vahsi", "bonus_turu": "kritik", "bonus_degeri": 15, "etkilenen": "ork_dovuscu"}
],
"canavarlar": [
{"isim": "Tepegoz", "etki_turu": "saldiri", "etki_degeri": 8, "etkilenen": "trol"}
],
"arastirma_seviyesi": {
"isim": "elit_egitim",
"seviye": 2,
"oran": 20
}
}
}
```
.bmp)
.bmp)
## Collaborators
-
MYounes: JSON file parsing and unit data management.
-
Merve Sevim: SFML integration and UI design.
# Enjoy the HexaClash simulation! 🎮