aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-04 12:15:05 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-04 12:15:05 +0100
commit16444f19ae2c7c71a2be53ce6fd2e4d671aa8765 (patch)
treef5109369648b19cfa7a23ee8ea00f4752f1a09d8 /src/example
parentf6111b6df65047557239c827100454c188979c43 (diff)
Modified test and setup of AISystem
Diffstat (limited to 'src/example')
-rw-r--r--src/example/AITest.cpp45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/example/AITest.cpp b/src/example/AITest.cpp
index ccf5a85..3998ff4 100644
--- a/src/example/AITest.cpp
+++ b/src/example/AITest.cpp
@@ -1,32 +1,41 @@
+#include <SDL2/SDL_timer.h>
+#include <chrono>
+#include <crepe/ComponentManager.h>
#include <crepe/api/Camera.h>
#include <crepe/api/Color.h>
-#include <crepe/api/Texture.h>
-#include <crepe/api/Sprite.h>
-#include <crepe/ComponentManager.h>
#include <crepe/api/GameObject.h>
+#include <crepe/api/LoopManager.h>
+#include <crepe/api/Scene.h>
+#include <crepe/api/Sprite.h>
+#include <crepe/api/Texture.h>
#include <crepe/system/RenderSystem.h>
-#include <SDL2/SDL_timer.h>
-#include <chrono>
using namespace crepe;
+using namespace std;
-int main() {
- ComponentManager mgr;
- GameObject game_object1 = mgr.new_object("", "", vec2{0, 0}, 0, 1);
- GameObject game_object2 = mgr.new_object("", "", vec2{0, 0}, 0, 1);
-
- Texture img = Texture("asset/texture/test_ap43.png");
- game_object1.add_component<Sprite>(img, Color::MAGENTA, Sprite::FlipSettings{false, false}, 1, 1, 195);
+class Scene1 : public Scene {
+public:
+ void load_scene() override {
+ ComponentManager & mgr = this->component_manager;
- game_object2.add_component<Camera>(Color::WHITE, ivec2{1080, 720}, vec2{1036, 780}, 1.0f);
+ GameObject game_object1 = mgr.new_object("", "", vec2{0, 0}, 0, 1);
+ GameObject game_object2 = mgr.new_object("", "", vec2{0, 0}, 0, 1);
- RenderSystem sys{mgr};
+ Texture img = Texture("asset/texture/test_ap43.png");
+ game_object1.add_component<Sprite>(img, Color::MAGENTA,
+ Sprite::FlipSettings{false, false}, 1, 1, 195);
- auto start = std::chrono::steady_clock::now();
- while (std::chrono::steady_clock::now() - start < std::chrono::seconds(5)) {
- sys.update();
- SDL_Delay(10);
+ game_object2.add_component<Camera>(Color::WHITE, ivec2{1080, 720}, vec2{1036, 780},
+ 1.0f);
}
+ string get_name() const override { return "Scene1"; }
+};
+
+int main() {
+ LoopManager engine;
+ engine.add_scene<Scene1>();
+ engine.start();
+
return 0;
}