diff options
author | Max-001 <maxsmits21@kpnmail.nl> | 2025-01-08 09:51:06 +0100 |
---|---|---|
committer | Max-001 <maxsmits21@kpnmail.nl> | 2025-01-08 09:51:06 +0100 |
commit | e9082de7d114ce024a884cac38c545c99de4026a (patch) | |
tree | ad10395021fed08e8143ea40b42bc9784ed4dc4e /game/workers/PanicFromPlayerScript.cpp | |
parent | b8ff1dcd4e531c3c858ee09f705cf553e86ed7ff (diff) |
Finnished collision
Diffstat (limited to 'game/workers/PanicFromPlayerScript.cpp')
-rw-r--r-- | game/workers/PanicFromPlayerScript.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/game/workers/PanicFromPlayerScript.cpp b/game/workers/PanicFromPlayerScript.cpp index 1e49aaa..baa48df 100644 --- a/game/workers/PanicFromPlayerScript.cpp +++ b/game/workers/PanicFromPlayerScript.cpp @@ -32,11 +32,21 @@ void PanicFromPlayerScript::fixed_update(duration_t dt) { } if (result_x < 0) { - rb_worker.data.linear_velocity.x = 10000 * dt.count(); + float min_value = 8000; + float max_value = 10000; + float value = min_value + + static_cast<float>(rand()) + / (static_cast<float>(RAND_MAX / (max_value - min_value))); + rb_worker.data.linear_velocity.x = value * dt.count(); sprite_worker.front().get().data.flip.flip_x = false; sprite_worker.back().get().data.flip.flip_x = false; } else { - rb_worker.data.linear_velocity.x = -5000 * dt.count(); + float min_value = -4000; + float max_value = -5000; + float value = min_value + + static_cast<float>(rand()) + / (static_cast<float>(RAND_MAX / (max_value - min_value))); + rb_worker.data.linear_velocity.x = value * dt.count(); sprite_worker.front().get().data.flip.flip_x = true; sprite_worker.back().get().data.flip.flip_x = true; } |