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/PanicFromPlayerScript.cpp | |
parent | 8055d401fc7c553a7036336b4b2fb2fca99a5986 (diff) | |
parent | b1e2df1e75e7fc8ea4c30b7deaa54a7acf02d951 (diff) |
Merge branch 'max/game2' of github.com:lonkaars/crepe
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; } |