aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-06 16:41:51 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-06 16:41:51 +0100
commit0d0943d23364d7110f0232e3564f4ea63af13db2 (patch)
tree8ae2f2cb22690101b70c1cd5f1b6ea33863eedcf /src/example
parent9eac8d31b25c234a21b1d188df17e77e71f48088 (diff)
Implemented flee and arrive behaviors
Diffstat (limited to 'src/example')
-rw-r--r--src/example/AITest.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/example/AITest.cpp b/src/example/AITest.cpp
index 144aef3..319d0fe 100644
--- a/src/example/AITest.cpp
+++ b/src/example/AITest.cpp
@@ -27,7 +27,7 @@ class Script1 : public Script {
bool mousemove(const MouseMoveEvent & event) {
RefVector<AI> aivec = this->get_components<AI>();
AI & ai = aivec.front().get();
- ai.seek_target
+ ai.flee_target
= vec2{static_cast<float>(event.mouse_x), static_cast<float>(event.mouse_y)};
return true;
}
@@ -52,7 +52,9 @@ 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>(30).seek_on();
+ AI & ai = game_object1.add_component<AI>(30);
+ ai.arrive_on();
+ ai.flee_on();
game_object1.add_component<Rigidbody>(Rigidbody::Data{
.mass = 0.5f, .max_linear_velocity = {21, 21}, // sqrt(21^2 + 21^2) = 30
});