diff options
author | Andy <drumsetmonkey@gmail.com> | 2017-01-19 09:21:12 -0500 |
---|---|---|
committer | Andy <drumsetmonkey@gmail.com> | 2017-01-19 09:21:12 -0500 |
commit | 213d9ccfbb4752d4c62d6b7e6b3f9172cdf1bccc (patch) | |
tree | 7872c6f30c8adf048a7863a33d837299c7fb0771 /src/gametime.cpp | |
parent | 19a32074595a4a2797eaeb978f8bd302f736f6a6 (diff) | |
parent | 8452b199d28bea53bf2c5e3b3d604064000fc73d (diff) |
Limb animation actually works
Diffstat (limited to 'src/gametime.cpp')
-rw-r--r-- | src/gametime.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/gametime.cpp b/src/gametime.cpp index 1005d84..cb736ff 100644 --- a/src/gametime.cpp +++ b/src/gametime.cpp @@ -1,15 +1,9 @@ #include <gametime.hpp> -#include <common.hpp> +#include <common.hpp> // millis static unsigned int tickCount = 0; -static float deltaTime = 1; - -// millisecond timers -static unsigned int currentTime = 0; -static unsigned int prevTime; - -static float accum = 0.0f; +static unsigned int deltaTime = 1; namespace game { namespace time { @@ -34,15 +28,19 @@ namespace game { } void mainLoopHandler(void) { - if (!currentTime) - currentTime = prevTime = millis(); + static unsigned int cur = 0, prev; - currentTime = millis(); - deltaTime = currentTime - prevTime; - prevTime = currentTime; + if (cur == 0) + cur = prev = millis(); + + cur = millis(); + deltaTime = cur - prev; + prev = cur; } bool tickHasPassed(void) { + static unsigned int accum = 0; + accum += deltaTime; if (accum > MSEC_PER_TICK) { accum = 0.0f; |