aboutsummaryrefslogtreecommitdiff
path: root/game/workers/PanicFromPlayerScript.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-08 12:17:36 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-08 12:17:36 +0100
commitdc5d46426b30303843e8746d514db6f55ce1495b (patch)
tree2b01a358b3daa4f55e54ca2c87f58becf83edeb8 /game/workers/PanicFromPlayerScript.cpp
parent1a5744a3285a5ba5132fb4f6f031c27df1b64d33 (diff)
parentc9c9702edc58ff8f40b13dc6b86b216421f79e9b (diff)
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/enemyAI
Diffstat (limited to 'game/workers/PanicFromPlayerScript.cpp')
-rw-r--r--game/workers/PanicFromPlayerScript.cpp14
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;
}