Godzil 3 年 前
コミット
190b2adbea
2 ファイル変更4 行追加4 行削除
  1. 1 1
      source/Game.cpp
  2. 3 3
      source/include/Systems/Movement.h

+ 1 - 1
source/Game.cpp

@@ -117,7 +117,7 @@ void Game::Update()
 
     this->millisecsPerviousFrame = SDL_GetTicks();
 
-    registry->getSystem<MovementSystem>().Update();
+    registry->getSystem<MovementSystem>().update(deltaTime);
 
     registry->update();
 }

+ 3 - 3
source/include/Systems/Movement.h

@@ -25,15 +25,15 @@ public:
         this->requireComponent<RigidBodyComponent>();
     }
 
-    void Update()
+    void update(double deltaTime)
     {
         for (auto entity: this->getSystemEntities())
         {
             auto &transform = entity.getComponent<TransformComponent>();
             const auto rigidbody = entity.getComponent<RigidBodyComponent>();
 
-            transform.position.x += rigidbody.velocity.x;
-            transform.position.y += rigidbody.velocity.y;
+            transform.position.x += rigidbody.velocity.x * deltaTime;
+            transform.position.y += rigidbody.velocity.y * deltaTime;
 
             Logger::Debug("Entity id#%d - Position is now (%f, %f)",
                           entity.getId(), transform.position.x, transform.position.y);