From eed36625920d8f3123d09f70c76d2c9918fb5770 Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Wed, 15 Jun 2022 09:10:24 +0300 Subject: [PATCH] Fixed HardHit detection in DefaultCollision. Issue #141. --- SpaceCadetPinball/TCollisionComponent.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SpaceCadetPinball/TCollisionComponent.cpp b/SpaceCadetPinball/TCollisionComponent.cpp index d713867..5e7cfb2 100644 --- a/SpaceCadetPinball/TCollisionComponent.cpp +++ b/SpaceCadetPinball/TCollisionComponent.cpp @@ -60,14 +60,17 @@ bool TCollisionComponent::DefaultCollision(TBall* ball, vector2* nextPosition, v return false; } + bool collision = false; auto projSpeed = maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, Threshold, Boost); if (projSpeed > Threshold) + { loader::play_sound(HardHitSoundId, ball, "TCollisionComponent1"); + collision = true; + } else if (projSpeed > 0.2f) loader::play_sound(SoftHitSoundId, ball, "TCollisionComponent2"); - else - return false; - return true; + + return collision; } void TCollisionComponent::Collision(TBall* ball, vector2* nextPosition, vector2* direction,