From cdd419daeb91fb2b979f86978d82f5a579fd7d24 Mon Sep 17 00:00:00 2001 From: David Hermann <redeagle.private@gmail.com> Date: Mon, 10 Feb 2025 02:14:52 +0100 Subject: [PATCH] Adding and refactoring author comments. Adding and refactoring to Readme.md --- CMakeLists.txt | 1 + README.md | 109 +++++++++++++++---------- src/game/combat/CombatEngine.cpp | 12 +-- src/game/combat/CombatEngine.hpp | 11 ++- src/game/combat/Weapon.cpp | 8 +- src/game/combat/Weapon.hpp | 10 ++- src/game/core/Config.cpp | 10 ++- src/game/core/Config.hpp | 10 ++- src/game/core/GameManager.cpp | 6 ++ src/game/core/GameManager.hpp | 6 ++ src/game/effect/Effect.cpp | 1 + src/game/entities/Bullet.cpp | 6 ++ src/game/entities/Bullet.hpp | 6 ++ src/game/entities/Unit.cpp | 7 +- src/game/entities/Unit.hpp | 5 +- src/game/level/Level.cpp | 6 +- src/game/level/Level.hpp | 3 +- src/game/physics/PhysicsBody.cpp | 8 +- src/game/physics/PhysicsBody.hpp | 8 +- src/game/physics/PhysicsEngine.cpp | 6 ++ src/game/physics/PhysicsEngine.hpp | 6 ++ src/game/ui/context/ContextMenu.cpp | 5 +- src/game/ui/context/ContextMenu.hpp | 5 +- src/game/ui/context/RecruitingMenu.cpp | 2 +- src/game/ui/context/RecruitingMenu.hpp | 2 +- src/game/ui/menu/Menu.cpp | 6 ++ src/game/ui/menu/Menu.hpp | 6 ++ src/util/Dimensions.hpp | 6 ++ 28 files changed, 193 insertions(+), 84 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index baeb663..8621445 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,4 @@ +# @author David Hermann cmake_minimum_required(VERSION 3.15) # Projektname und Sprache diff --git a/README.md b/README.md index e25f3b4..74cbf6d 100644 --- a/README.md +++ b/README.md @@ -4,51 +4,56 @@ - Um `clang-tidy` für eine einzelne Datei (z.B. `main.cpp`) auszuführen: - `clang-tidy src/game/main.cpp -header-filter="src/game/main\.cpp" -p build/` + `clang-tidy src/game/main.cpp -header-filter="src/game/main\.cpp" -p build/` - Um `clang-tidy` für das ganze Projekt auszuführen und die Warnings in die Datei `clang-tidy-warnings.txt` zu schreiben: - `find src/game -name '*.cpp' -o -name '*.hpp' | xargs clang-tidy -header-filter="src/game/.*" -p build/ 1> clang-tidy-warnings.txt` + `find src/game -name '*.cpp' -o -name '*.hpp' | xargs clang-tidy -header-filter="src/game/.*" -p build/ 1> clang-tidy-warnings.txt` + ## Build-Anleitung ### Linux/MacOS 1. Repository klonen: - ```bash - git clone https://github.com/username/project.git - cd project - ``` + + ```bash + git clone https://github.com/username/project.git + cd project + ``` 2. Build-Verzeichnis erstellen: - ```bash - mkdir build && cd build - ``` + + ```bash + mkdir build && cd build + ``` 3. CMake konfigurieren und Build ausführen: - ```bash - cmake .. - cmake --build . - ``` + ```bash + cmake .. + cmake --build . + ``` ### Windows 1. Repository klonen: - ```powershell - git clone https://github.com/username/project.git - cd project - ``` + + ```powershell + git clone https://github.com/username/project.git + cd project + ``` 2. Build-Verzeichnis erstellen: - ```powershell - mkdir build - cd build - ``` + + ```powershell + mkdir build + cd build + ``` 3. CMake konfigurieren und Build ausführen: - ```powershell - cmake .. - cmake --build . --config Release - ``` + ```powershell + cmake .. + cmake --build . --config Release + ``` ### Visual Studio @@ -58,7 +63,6 @@ 4. Visual Studio erkennt automatisch das CMake-Projekt 5. Build über "Build All" ausführen - #### Falls Syntax errors 1. Erstelle .vscode/c_cpp_properties.json Datei @@ -66,21 +70,18 @@ ```json { - "configurations": [ - { - "name": "Fedora", - "includePath": [ - "/usr/include", - "/usr/include/SDL2" - ], - "defines": [], - "intelliSenseMode": "linux-gcc-x64", - "compilerPath": "/usr/bin/gcc", - "cStandard": "c17", - "cppStandard": "c++17" - } - ], - "version": 4 + "configurations": [ + { + "name": "Fedora", + "includePath": ["/usr/include", "/usr/include/SDL2"], + "defines": [], + "intelliSenseMode": "linux-gcc-x64", + "compilerPath": "/usr/bin/gcc", + "cStandard": "c17", + "cppStandard": "c++17" + } + ], + "version": 4 } ``` @@ -94,12 +95,13 @@ cmake .. -DCMAKE_BUILD_TYPE=Debug # Debug-Build ``` ## Prerequisites for Leveleditor -- QT 6: ```sudo apt install qt6-base-dev``` +- QT 6: `sudo apt install qt6-base-dev` ## Authors Max Körschen: + - Units.cpp/hpp (Combat and movement) - Helpmenu.cpp/hpp - UnitInfoMenu.cpp/hpp @@ -108,8 +110,8 @@ Max Körschen: - level.cpp/hpp (eventhandling for units and buildings, movement, attack etc) - debugging in CombatEngine.cpp/hpp, Bullets.cpp/hpp - Lorenz Diel: + - Units.cpp/hpp - UnitInfoMenu.cpp/hpp - level.cpp/hpp @@ -118,6 +120,7 @@ Lorenz Diel: - CombatEngine.cpp/hpp David Maul: + - Engine.cpp/hpp - Scene.hpp - Spritesheet.cpp/hpp @@ -128,6 +131,7 @@ David Maul: - main.cpp Frederik Keens: + - main.cpp - Player.cpp/hpp - Level.cpp/hpp @@ -138,5 +142,20 @@ Frederik Keens: - Scene.hpp - Engine.cpp/hpp - - +David Hermann: + +- Projektmanagement (GitLab Issues, Milestones, etc.) +- Projektstruktur (Ordnerhierarchien) +- Refactoring der Architektur für bessere Modularität, Memory Management und Box2d Integration +- Spezifische Arbeit: + - CMakeLists.txt + - CombatEngine.cpp/hpp (refactoring, box2d integration) + - GameManager.cpp/hpp + - Unit.cpp/hpp (refactoring, box2d integration) + - Bullet.cpp/hpp + - Level.cpp/hpp (refactoring, box2d integration) + - PhysicsBody.cpp/hpp (box2d integration) + - PhysicsEngine.cpp/hpp (box2d integration) + - Menu.cpp/hpp (Main Menu UI) + - ContextMenu.cpp/hpp (Context Menu) + - Dimensions.hpp diff --git a/src/game/combat/CombatEngine.cpp b/src/game/combat/CombatEngine.cpp index 579b260..555b765 100644 --- a/src/game/combat/CombatEngine.cpp +++ b/src/game/combat/CombatEngine.cpp @@ -1,3 +1,10 @@ +/** + * CombatEngine.cpp + * + * @author Lorenz Diel + * @author David Hermann + */ + #include "CombatEngine.hpp" #include "../level/Level.hpp" @@ -5,11 +12,6 @@ #include <memory> #include <unordered_map> -/** - * @authors Lorenz Diel - */ - - namespace advanced_wars { diff --git a/src/game/combat/CombatEngine.hpp b/src/game/combat/CombatEngine.hpp index ba8520f..3072099 100644 --- a/src/game/combat/CombatEngine.hpp +++ b/src/game/combat/CombatEngine.hpp @@ -1,12 +1,15 @@ +/** + * CombatEngine.hpp + * + * @author Lorenz Diel + * @author David Hermann + */ + #pragma once #include "../core/Engine.hpp" #include "../entities/Unit.hpp" -/** - * @authors Lorenz Diel - */ - namespace advanced_wars { diff --git a/src/game/combat/Weapon.cpp b/src/game/combat/Weapon.cpp index 9b8e155..153c020 100644 --- a/src/game/combat/Weapon.cpp +++ b/src/game/combat/Weapon.cpp @@ -1,9 +1,11 @@ -#include "Weapon.hpp" - /** - * @authors Lorenz Diel + * Weapon.cpp + * + * @author Lorenz Diel */ +#include "Weapon.hpp" + namespace advanced_wars { Weapon::Weapon() {} diff --git a/src/game/combat/Weapon.hpp b/src/game/combat/Weapon.hpp index 1031c04..3c0f96d 100644 --- a/src/game/combat/Weapon.hpp +++ b/src/game/combat/Weapon.hpp @@ -1,12 +1,14 @@ +/** + * Weapon.hpp + * + * @author Lorenz Diel + */ + #pragma once #include <string> #include <unordered_map> -/** - * @authors Lorenz Diel - */ - namespace advanced_wars { diff --git a/src/game/core/Config.cpp b/src/game/core/Config.cpp index cc8381e..f43a918 100644 --- a/src/game/core/Config.cpp +++ b/src/game/core/Config.cpp @@ -1,3 +1,9 @@ +/** + * Config.cpp + * + * @author Lorenz Diel + */ + #include "Config.hpp" #include "../entities/Unit.hpp" @@ -9,10 +15,6 @@ #include <string> #include <unordered_map> -/** - * @authors Lorenz Diel - */ - namespace advanced_wars { diff --git a/src/game/core/Config.hpp b/src/game/core/Config.hpp index 5574b3d..fe8bbcc 100644 --- a/src/game/core/Config.hpp +++ b/src/game/core/Config.hpp @@ -1,3 +1,9 @@ +/** + * Config.hpp + * + * @author Lorenz Diel + */ + #pragma once #include <boost/property_tree/ptree.hpp> @@ -6,10 +12,6 @@ #include <string> #include <unordered_map> -/** - * @authors Lorenz Diel - */ - namespace advanced_wars { /* ENUMS FOR GLOBAL USE*/ diff --git a/src/game/core/GameManager.cpp b/src/game/core/GameManager.cpp index dda9b65..ec64711 100644 --- a/src/game/core/GameManager.cpp +++ b/src/game/core/GameManager.cpp @@ -1,3 +1,9 @@ +/** + * GameManager.cpp + * + * @author David Hermann + */ + #include "GameManager.hpp" #include <iostream> #include <memory> diff --git a/src/game/core/GameManager.hpp b/src/game/core/GameManager.hpp index c273345..4c071e1 100644 --- a/src/game/core/GameManager.hpp +++ b/src/game/core/GameManager.hpp @@ -1,3 +1,9 @@ +/** + * GameManager.hpp + * + * @author David Hermann + */ + #pragma once #include "../level/Level.hpp" diff --git a/src/game/effect/Effect.cpp b/src/game/effect/Effect.cpp index 1407e94..3c95704 100644 --- a/src/game/effect/Effect.cpp +++ b/src/game/effect/Effect.cpp @@ -1,5 +1,6 @@ /** * Effect.cpp + * * @author David Maul * @author Frederik Keens */ diff --git a/src/game/entities/Bullet.cpp b/src/game/entities/Bullet.cpp index 719715f..15dd74e 100644 --- a/src/game/entities/Bullet.cpp +++ b/src/game/entities/Bullet.cpp @@ -1,3 +1,9 @@ +/** + * Bullet.cpp + * + * @author David Hermann + */ + #include "Bullet.hpp" #include "../core/Engine.hpp" #include "../physics/PhysicsBody.hpp" diff --git a/src/game/entities/Bullet.hpp b/src/game/entities/Bullet.hpp index a109214..15f273a 100644 --- a/src/game/entities/Bullet.hpp +++ b/src/game/entities/Bullet.hpp @@ -1,3 +1,9 @@ +/** + * Bullet.hpp + * + * @author David Hermann + */ + #pragma once #include "../core/Engine.hpp" diff --git a/src/game/entities/Unit.cpp b/src/game/entities/Unit.cpp index c8e338d..16b8a16 100644 --- a/src/game/entities/Unit.cpp +++ b/src/game/entities/Unit.cpp @@ -1,10 +1,11 @@ /** * Unit.cpp * - * @authors Max Körschen + * @author Max Körschen * @author Nicolas Will * @author Frederik Keens * @author Lorenz Diel + * @author David Hermann */ #include "Unit.hpp" @@ -65,14 +66,14 @@ Unit::Unit( Weapon(config.getUnitSecondaryWeapon(m_unitTypeId), secondaryDamage)); } -void Unit::update(float deltaTime) +void Unit::update() { if (!m_physicsBody) { return; } - m_physicsBody->update(deltaTime); + m_physicsBody->update(); b2Vec2 pos = m_physicsBody->getPosition(); calcState(static_cast<int>(pos.x), static_cast<int>(pos.y)); diff --git a/src/game/entities/Unit.hpp b/src/game/entities/Unit.hpp index a3f89be..6b6dee3 100644 --- a/src/game/entities/Unit.hpp +++ b/src/game/entities/Unit.hpp @@ -1,10 +1,11 @@ /** * Unit.hpp * - * @authors Max Körschen + * @author Max Körschen * @author Nicolas Will * @author Frederik Keens * @author Lorenz Diel + * @author David Hermann */ #pragma once @@ -37,7 +38,7 @@ class Unit ~Unit(); /// Aktualisiert die Einheit (Bewegung, Physik, etc.). - void update(float deltaTime); + void update(); /// Bewegt die Einheit zu einer neuen Position. void moveTo(int posX, int posY); diff --git a/src/game/level/Level.cpp b/src/game/level/Level.cpp index ea6af4b..5bde2de 100644 --- a/src/game/level/Level.cpp +++ b/src/game/level/Level.cpp @@ -1,12 +1,12 @@ /** * Level.cpp * - * @authors Max Körschen + * @author Max Körschen * @author Nicolas Will * @author Frederik Keens * @author Lorenz Diel * @author David Maul - + * @author David Hermann */ #include "Level.hpp" @@ -381,7 +381,7 @@ void Level::render(Engine& engine) { Unit& unitRef = *unit; m_physicsEngine->step(deltaTime); - unitRef.update(deltaTime); + unitRef.update(); unitRef.render(engine, RENDERING_SCALE); } diff --git a/src/game/level/Level.hpp b/src/game/level/Level.hpp index ed9d693..3545fdc 100644 --- a/src/game/level/Level.hpp +++ b/src/game/level/Level.hpp @@ -1,11 +1,12 @@ /** * Level.hpp * - * @authors Max Körschen + * @author Max Körschen * @author Nicolas Will * @author Frederik Keens * @author Lorenz Diel * @author David Maul + * @author David Hermann */ #pragma once diff --git a/src/game/physics/PhysicsBody.cpp b/src/game/physics/PhysicsBody.cpp index 24bbaf9..369ba7d 100644 --- a/src/game/physics/PhysicsBody.cpp +++ b/src/game/physics/PhysicsBody.cpp @@ -1,3 +1,9 @@ +/** + * PhysicsBody.cpp + * + * @author David Hermann + */ + #include "PhysicsBody.hpp" #include "../../util/Dimensions.hpp" #include <box2d/box2d.h> @@ -29,7 +35,7 @@ PhysicsBody::PhysicsBody( m_fixture = m_body->CreateFixture(&fixtureDef); } -void PhysicsBody::update(float /*deltaTime*/) +void PhysicsBody::update() { if (m_body == nullptr) { diff --git a/src/game/physics/PhysicsBody.hpp b/src/game/physics/PhysicsBody.hpp index 5bb6d69..70f1032 100644 --- a/src/game/physics/PhysicsBody.hpp +++ b/src/game/physics/PhysicsBody.hpp @@ -1,3 +1,9 @@ +/** + * PhysicsBody.hpp + * + * @author David Hermann + */ + #pragma once #include "box2d/b2_body.h" @@ -17,7 +23,7 @@ class PhysicsBody PhysicsBody( b2World* world, int x, int y, float width, float height, float density, float friction, bool isSensor, BodyType type); - void update(float deltaTime); + void update(); void setTargetPosition(int targetTileX, int targetTileY); b2Vec2 getPosition() const; b2Vec2 getVelocity() const; diff --git a/src/game/physics/PhysicsEngine.cpp b/src/game/physics/PhysicsEngine.cpp index 54884b3..8f5ded3 100644 --- a/src/game/physics/PhysicsEngine.cpp +++ b/src/game/physics/PhysicsEngine.cpp @@ -1,3 +1,9 @@ +/** + * PhysicsEngine.cpp + * + * @author David Hermann + */ + #include "PhysicsEngine.hpp" #include "../entities/Bullet.hpp" #include "../entities/Unit.hpp" diff --git a/src/game/physics/PhysicsEngine.hpp b/src/game/physics/PhysicsEngine.hpp index a59683e..b1fdc30 100644 --- a/src/game/physics/PhysicsEngine.hpp +++ b/src/game/physics/PhysicsEngine.hpp @@ -1,3 +1,9 @@ +/** + * PhysicsEngine.hpp + * + * @author David Hermann + */ + #pragma once #include "PhysicsBody.hpp" diff --git a/src/game/ui/context/ContextMenu.cpp b/src/game/ui/context/ContextMenu.cpp index 1324409..e5da09c 100644 --- a/src/game/ui/context/ContextMenu.cpp +++ b/src/game/ui/context/ContextMenu.cpp @@ -1,6 +1,9 @@ /** - * @authors Max Körschen + * ContextMenu.cpp + * + * @author Max Körschen * @author Nicolas Will + * @author David Hermann */ #include "ContextMenu.hpp" diff --git a/src/game/ui/context/ContextMenu.hpp b/src/game/ui/context/ContextMenu.hpp index fdf50aa..af715a3 100644 --- a/src/game/ui/context/ContextMenu.hpp +++ b/src/game/ui/context/ContextMenu.hpp @@ -1,6 +1,9 @@ /** - * @authors Max Körschen + * ContextMenu.hpp + * + * @author Max Körschen * @author Nicolas Will + * @author David Hermann */ #pragma once diff --git a/src/game/ui/context/RecruitingMenu.cpp b/src/game/ui/context/RecruitingMenu.cpp index a0bd421..a67a912 100644 --- a/src/game/ui/context/RecruitingMenu.cpp +++ b/src/game/ui/context/RecruitingMenu.cpp @@ -1,5 +1,5 @@ /** - * @authors Max Körschen + * @author Max Körschen * @author Nicolas Will */ diff --git a/src/game/ui/context/RecruitingMenu.hpp b/src/game/ui/context/RecruitingMenu.hpp index 2c8dba2..44b1455 100644 --- a/src/game/ui/context/RecruitingMenu.hpp +++ b/src/game/ui/context/RecruitingMenu.hpp @@ -1,5 +1,5 @@ /** - * @authors Max Körschen + * @author Max Körschen * @author Nicolas Will */ diff --git a/src/game/ui/menu/Menu.cpp b/src/game/ui/menu/Menu.cpp index 9d9cb4e..afb071c 100644 --- a/src/game/ui/menu/Menu.cpp +++ b/src/game/ui/menu/Menu.cpp @@ -1,3 +1,9 @@ +/** + * Menu.cpp + * + * @author David Hermann + */ + #include "Menu.hpp" #include "../../core/Config.hpp" #include "../../core/Spritesheet.hpp" diff --git a/src/game/ui/menu/Menu.hpp b/src/game/ui/menu/Menu.hpp index 5080a8a..0eb8256 100644 --- a/src/game/ui/menu/Menu.hpp +++ b/src/game/ui/menu/Menu.hpp @@ -1,3 +1,9 @@ +/** + * Menu.hpp + * + * @author David Hermann + */ + #pragma once #include "../../core/Scene.hpp" diff --git a/src/util/Dimensions.hpp b/src/util/Dimensions.hpp index ffc679d..b9ca322 100644 --- a/src/util/Dimensions.hpp +++ b/src/util/Dimensions.hpp @@ -1,3 +1,9 @@ +/** + * Dimensions.hpp + * + * @author David Hermann + */ + namespace advanced_wars { -- GitLab