aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
Diffstat (limited to 'src/example')
-rw-r--r--src/example/AITest.cpp44
-rw-r--r--src/example/CMakeLists.txt1
2 files changed, 45 insertions, 0 deletions
diff --git a/src/example/AITest.cpp b/src/example/AITest.cpp
new file mode 100644
index 0000000..841b195
--- /dev/null
+++ b/src/example/AITest.cpp
@@ -0,0 +1,44 @@
+#include <SDL2/SDL_timer.h>
+#include <chrono>
+#include <crepe/api/AI.h>
+#include <crepe/api/Camera.h>
+#include <crepe/api/Color.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/manager/ComponentManager.h>
+#include <crepe/manager/Mediator.h>
+
+using namespace crepe;
+using namespace std;
+
+class Scene1 : public Scene {
+public:
+ void load_scene() override {
+ Mediator & mediator = this->mediator;
+ ComponentManager & mgr = mediator.component_manager;
+
+ GameObject game_object1 = mgr.new_object("", "", vec2{250, 250}, 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);
+ game_object1.add_component<AI>(1, 200, 200).seek_on();
+
+ 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;
+}
diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt
index 8ef71bb..149c412 100644
--- a/src/example/CMakeLists.txt
+++ b/src/example/CMakeLists.txt
@@ -21,3 +21,4 @@ add_example(savemgr)
add_example(rendering_particle)
add_example(game)
add_example(button)
+add_example(AITest)