From 2684637e2dd75982ac4a37612b8aee1bfe7c00aa Mon Sep 17 00:00:00 2001 From: westonCoder Date: Mon, 16 Oct 2023 12:06:14 -0500 Subject: [PATCH] Ball Resets Lifetime Through Portal Fixes #305 --- src/scene/ball.c | 5 +++++ src/scene/ball.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/scene/ball.c b/src/scene/ball.c index 6c17bf6..4adca25 100644 --- a/src/scene/ball.c +++ b/src/scene/ball.c @@ -108,6 +108,7 @@ void ballInit(struct Ball* ball, struct Vector3* position, struct Vector3* veloc ball->rigidBody.currentRoom = startingRoom; ball->flags = 0; ball->lifetime = ballLifetime; + ball->originalLifetime = ballLifetime; ball->targetSpeed = sqrtf(vector3MagSqrd(&ball->rigidBody.velocity)); @@ -188,6 +189,10 @@ void ballUpdate(struct Ball* ball) { return; } + if (ball->rigidBody.flags & (RigidBodyFlagsCrossedPortal0 | RigidBodyFlagsCrossedPortal1)){ + ball->lifetime = ball->originalLifetime; + } + float currentSpeed = sqrtf(vector3MagSqrd(&ball->rigidBody.velocity)); if (currentSpeed == 0.0f) { diff --git a/src/scene/ball.h b/src/scene/ball.h index 4dccc0a..d96ff48 100644 --- a/src/scene/ball.h +++ b/src/scene/ball.h @@ -27,6 +27,7 @@ struct Ball { float targetSpeed; float lifetime; + float originalLifetime; short dynamicId; short flags; short soundLoopId;