From e9082de7d114ce024a884cac38c545c99de4026a Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 09:51:06 +0100 Subject: Finnished collision --- game/workers/PanicFromPlayerScript.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'game/workers/PanicFromPlayerScript.cpp') 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(rand()) + / (static_cast(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(rand()) + / (static_cast(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; } -- cgit v1.2.3