summaryrefslogtreecommitdiff
path: root/src/train.cpp
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2022-04-01 21:23:01 -0600
committercflip <cflip@cflip.net>2022-04-01 21:23:01 -0600
commit3ee74cdb1b4fd2bf9eefdf6bcd8439b27cbb7336 (patch)
tree4c58b1cae03df912d2be17b077ab1810fcb3627b /src/train.cpp
parent7803be09b7c0a133b1009408fea2fb1f1474e786 (diff)
Add a game timerHEADmaster
This adds a delta time that ensures that everything moves at the same speed regardless of framerate or system.
Diffstat (limited to 'src/train.cpp')
-rw-r--r--src/train.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/train.cpp b/src/train.cpp
index 43ebe8a..8507af0 100644
--- a/src/train.cpp
+++ b/src/train.cpp
@@ -7,7 +7,7 @@
static const Bitmap SPRITES("res/car.png");
-void Train::update()
+void Train::update(float deltaTime)
{
if (m_next) {
m_speed = m_next->m_speed;
@@ -20,7 +20,7 @@ void Train::update()
m_speed *= m_acceleration;
if (m_progress < 1.f) {
- m_progress += m_speed;
+ m_progress += m_speed * deltaTime;
return;
}