aboutsummaryrefslogtreecommitdiff
path: root/src/example/AITest.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-11 20:12:12 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-11 20:12:12 +0100
commitc90423d5c9d38ae426c168e52994a4fd63e6f266 (patch)
treefa18eae598cf0fccbb0f2dffd3e1d76fedaed53a /src/example/AITest.cpp
parent9b4f6f24f29e8873a14989ba8c9fccfbc460af7f (diff)
parent194ee3f192c3343c3ccc28dfa97fed180503ffd4 (diff)
merge master
Diffstat (limited to 'src/example/AITest.cpp')
-rw-r--r--src/example/AITest.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/example/AITest.cpp b/src/example/AITest.cpp
index d12a99a..f4efc9f 100644
--- a/src/example/AITest.cpp
+++ b/src/example/AITest.cpp
@@ -1,5 +1,3 @@
-#include <SDL2/SDL_timer.h>
-#include <chrono>
#include <crepe/api/AI.h>
#include <crepe/api/BehaviorScript.h>
#include <crepe/api/Camera.h>
@@ -50,23 +48,30 @@ public:
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);
- AI & ai = game_object1.add_component<AI>(300);
+ game_object1.add_component<Sprite>(img, Sprite::Data{
+ .color = Color::MAGENTA,
+ .flip = Sprite::FlipSettings{false, false},
+ .sorting_in_layer = 1,
+ .order_in_layer = 1,
+ .size = {0, 195},
+ });
+ AI & ai = game_object1.add_component<AI>(3000);
// ai.arrive_on();
// ai.flee_on();
ai.path_follow_on();
- ai.add_path_node(vec2{1200, 1200});
- ai.add_path_node(vec2{-1200, 1200});
- ai.add_path_node(vec2{1200, -1200});
- ai.add_path_node(vec2{-1200, -1200});
+ ai.make_oval_path(500, 1000, {0, -1000}, 1.5708, true);
+ ai.make_oval_path(1000, 500, {0, 500}, 4.7124, false);
game_object1.add_component<Rigidbody>(Rigidbody::Data{
- .mass = 0.5f, .max_linear_velocity = {50, 50}, // sqrt(21^2 + 21^2) = 30
+ .mass = 0.1f,
+ .max_linear_velocity = {40, 40},
});
game_object1.add_component<BehaviorScript>().set_script<Script1>();
- game_object2.add_component<Camera>(Color::WHITE, ivec2{1080, 720}, vec2{5000, 5000},
- 1.0f);
+ game_object2.add_component<Camera>(ivec2{1080, 720}, vec2{5000, 5000},
+ Camera::Data{
+ .bg_color = Color::WHITE,
+ .zoom = 1,
+ });
}
string get_name() const override { return "Scene1"; }