Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in punch timer #1

Open
rwols opened this issue Dec 22, 2024 · 2 comments
Open

Fix bug in punch timer #1

rwols opened this issue Dec 22, 2024 · 2 comments

Comments

@rwols
Copy link

rwols commented Dec 22, 2024

I played around with this (fun game!) and I noticed the color mod lerping not working as it should. Sometimes the texture becomes red at the very end of the timer. It's due to the logic in BillGates::Update. The m_punchTimer may become negative which causes the lerp function to wraparound. I am too lazy to fork this and submit a pull request on this Microsoft platform. Here is the patch to fix it:

diff --git a/src/billgates.cpp b/src/billgates.cpp
index 62c4a51..69f7549 100644
--- a/src/billgates.cpp
+++ b/src/billgates.cpp
@@ -37,9 +37,7 @@ void BillGates::Unload() {
 }
 
 void BillGates::Update(float dt) {
-
-    if      (m_punchTimer > 0) m_punchTimer -= dt;
-    else if (m_punchTimer < 0) m_punchTimer = 0;
+    m_punchTimer = std::max(0.0f, m_punchTimer - dt);
 }
 
 void BillGates::Draw() {
@Martysh12
Copy link
Owner

UHHH oh wow I didn't expect anyone to actually play this and submit bugs. Thank you for your contribution!!

@Martysh12
Copy link
Owner

I will take a look at this tomorrow, I don't have much time today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants