From cb0e77b69692fdbe61dae0d0dc6e7ffa732ee7b2 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Wed, 20 Oct 2021 18:27:16 +0600 Subject: [PATCH] Make neon pulsing smoother --- src/neon.cpp | 35 ++++++++++++++++------------------- src/neon.h | 2 -- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/neon.cpp b/src/neon.cpp index 27f3863..a4ee16b 100644 --- a/src/neon.cpp +++ b/src/neon.cpp @@ -183,30 +183,27 @@ Neon::Neon() CShadows::StoreShadowToBeRendered(5, m_pNeonTexture, ¢er, up.x, up.y, right.x, right.y, 180, data->m_Color.r, data->m_Color.g, data->m_Color.b, 2.0f, false, 1.0f, 0, true); - if (CTimer::m_snTimeInMilliseconds - data->m_nTimer > 150) + if (data->m_bPulsing) { - data->m_nTimer = CTimer::m_snTimeInMilliseconds; + size_t delta = CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds; - if (data->m_bPulsing) + if (data->m_fVal < 0.0f) { - if (data->m_fVal < 0.0f) - { - data->m_bIncrement = true; - } + data->m_bIncrement = true; + } - if (data->m_fVal > 0.3f) - { - data->m_bIncrement = false; - } + if (data->m_fVal > 0.3f) + { + data->m_bIncrement = false; + } - if (data->m_bIncrement) - { - data->m_fVal += 0.1f; - } - else - { - data->m_fVal -= 0.1f; - } + if (data->m_bIncrement) + { + data->m_fVal += 0.0003f * delta; + } + else + { + data->m_fVal -= 0.0003f * delta; } } } diff --git a/src/neon.h b/src/neon.h index 8829433..a6a59b1 100644 --- a/src/neon.h +++ b/src/neon.h @@ -10,7 +10,6 @@ private: CRGBA m_Color; bool m_bNeonInstalled; float m_fVal; - uint m_nTimer; bool m_bIncrement; bool m_bPulsing; @@ -18,7 +17,6 @@ private: { m_bNeonInstalled = false; m_fVal = 0.0; - m_nTimer = 0; m_bIncrement = true; } };