diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-08 12:03:28 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-08 12:03:28 +0100 |
commit | c9c9702edc58ff8f40b13dc6b86b216421f79e9b (patch) | |
tree | 3f3e710735105cbbd63ebd4f320c88fbc0ecfa0c /game/workers/WorkerScript.cpp | |
parent | 8055d401fc7c553a7036336b4b2fb2fca99a5986 (diff) | |
parent | b1e2df1e75e7fc8ea4c30b7deaa54a7acf02d951 (diff) |
Merge branch 'max/game2' of github.com:lonkaars/crepe
Diffstat (limited to 'game/workers/WorkerScript.cpp')
-rw-r--r-- | game/workers/WorkerScript.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/game/workers/WorkerScript.cpp b/game/workers/WorkerScript.cpp index 1bcf8d5..b0bfc4e 100644 --- a/game/workers/WorkerScript.cpp +++ b/game/workers/WorkerScript.cpp @@ -1,6 +1,7 @@ #include "WorkerScript.h" #include "../Config.h" +#include "api/BehaviorScript.h" #include <crepe/api/Animator.h> #include <crepe/api/Rigidbody.h> @@ -44,6 +45,9 @@ void WorkerScript::fixed_update(duration_t dt) { = this->get_components_by_id<Sprite>(trans_worker.game_object_id); RefVector<Animator> animator_worker = this->get_components_by_id<Animator>(trans_worker.game_object_id); + BehaviorScript & bs_panic + = this->get_components_by_id<BehaviorScript>(trans_worker.game_object_id) + .front(); if (rb_worker.data.linear_velocity.x < 0) { sprite_worker.front().get().data.flip.flip_x = true; @@ -55,6 +59,8 @@ void WorkerScript::fixed_update(duration_t dt) { = -rb_worker.data.linear_velocity.x / 5; animator_worker.front().get().set_anim(0); animator_worker.back().get().set_anim(0); + animator_worker.front().get().active = true; + animator_worker.back().get().active = true; } else { sprite_worker.front().get().data.flip.flip_x = false; sprite_worker.back().get().data.flip.flip_x = false; @@ -65,6 +71,15 @@ void WorkerScript::fixed_update(duration_t dt) { = rb_worker.data.linear_velocity.x / 5; animator_worker.front().get().set_anim(0); animator_worker.back().get().set_anim(0); + animator_worker.front().get().active = true; + animator_worker.back().get().active = true; + } + + trans_worker.rotation = 0; + bs_panic.active = true; + rb_worker.data.linear_velocity_coefficient = {1, 1}; + for (Sprite & sprite : sprite_worker) { + sprite.data.position_offset.x = 0; } } } else { @@ -84,6 +99,9 @@ void WorkerScript::fixed_update(duration_t dt) { = this->get_components_by_id<Sprite>(trans_worker.game_object_id); RefVector<Animator> animator_worker = this->get_components_by_id<Animator>(trans_worker.game_object_id); + BehaviorScript & bs_panic + = this->get_components_by_id<BehaviorScript>(trans_worker.game_object_id) + .front(); if (rb_worker.data.linear_velocity.x < 0) { sprite_worker.front().get().data.flip.flip_x = true; @@ -96,6 +114,8 @@ void WorkerScript::fixed_update(duration_t dt) { animator_worker.front().get().set_anim(0); animator_worker.back().get().set_anim(0); + animator_worker.front().get().active = true; + animator_worker.back().get().active = true; } else { sprite_worker.front().get().data.flip.flip_x = false; sprite_worker.back().get().data.flip.flip_x = false; @@ -107,6 +127,15 @@ void WorkerScript::fixed_update(duration_t dt) { animator_worker.front().get().set_anim(0); animator_worker.back().get().set_anim(0); + animator_worker.front().get().active = true; + animator_worker.back().get().active = true; + } + + trans_worker.rotation = 0; + bs_panic.active = true; + rb_worker.data.linear_velocity_coefficient = {1, 1}; + for (Sprite & sprite : sprite_worker) { + sprite.data.position_offset.x = 0; } } } |