diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-12-04 13:17:08 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-12-04 13:17:08 +0100 |
commit | ac87bfad20e1bcf1fd066a4eda231608fe12f504 (patch) | |
tree | 1ecf875bcbb3c3a846178869745bdfce7ce182b9 | |
parent | 16444f19ae2c7c71a2be53ce6fd2e4d671aa8765 (diff) |
Added AI component
-rw-r--r-- | src/crepe/api/AI.cpp | 11 | ||||
-rw-r--r-- | src/crepe/api/AI.h | 18 | ||||
-rw-r--r-- | src/crepe/api/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/example/AITest.cpp | 3 |
4 files changed, 33 insertions, 1 deletions
diff --git a/src/crepe/api/AI.cpp b/src/crepe/api/AI.cpp new file mode 100644 index 0000000..6b63216 --- /dev/null +++ b/src/crepe/api/AI.cpp @@ -0,0 +1,11 @@ +#include "AI.h" + +namespace crepe { + +AI::AI(game_object_id_t id, double mass, double max_speed, double max_force) + : Component(id), + mass(mass), + max_speed(max_speed), + max_force(max_force) {} + +} // namespace crepe diff --git a/src/crepe/api/AI.h b/src/crepe/api/AI.h new file mode 100644 index 0000000..b755439 --- /dev/null +++ b/src/crepe/api/AI.h @@ -0,0 +1,18 @@ +#pragma once + +#include "Component.h" +#include "types.h" + +namespace crepe { + +class AI : public Component { +public: + AI(game_object_id_t id, double mass, double max_speed, double max_force); + +public: + double mass; + double max_speed; + double max_force; +}; + +} // namespace crepe diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt index 50c51ed..d42b459 100644 --- a/src/crepe/api/CMakeLists.txt +++ b/src/crepe/api/CMakeLists.txt @@ -23,6 +23,7 @@ target_sources(crepe PUBLIC Asset.cpp EventHandler.cpp Script.cpp + AI.cpp ) target_sources(crepe PUBLIC FILE_SET HEADERS FILES @@ -58,4 +59,5 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES LoopManager.h LoopTimer.h Asset.h + AI.h ) diff --git a/src/example/AITest.cpp b/src/example/AITest.cpp index 3998ff4..1c4633f 100644 --- a/src/example/AITest.cpp +++ b/src/example/AITest.cpp @@ -1,6 +1,7 @@ #include <SDL2/SDL_timer.h> #include <chrono> #include <crepe/ComponentManager.h> +#include <crepe/api/AI.h> #include <crepe/api/Camera.h> #include <crepe/api/Color.h> #include <crepe/api/GameObject.h> @@ -8,7 +9,6 @@ #include <crepe/api/Scene.h> #include <crepe/api/Sprite.h> #include <crepe/api/Texture.h> -#include <crepe/system/RenderSystem.h> using namespace crepe; using namespace std; @@ -24,6 +24,7 @@ public: Texture img = Texture("asset/texture/test_ap43.png"); game_object1.add_component<Sprite>(img, Color::MAGENTA, Sprite::FlipSettings{false, false}, 1, 1, 195); + game_object1.add_component<AI>(1, 1, 1); game_object2.add_component<Camera>(Color::WHITE, ivec2{1080, 720}, vec2{1036, 780}, 1.0f); |