From b8d62ce8d2f7c8f38aa9c52ab8d7dd32dc3aba64 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 13 Mar 2015 11:14:01 -0400 Subject: Fixed my timestep! http://gafferongames.com/game-physics/fix-your-timestep/ --- src/components.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/components.h') diff --git a/src/components.h b/src/components.h index f421529..c66db47 100644 --- a/src/components.h +++ b/src/components.h @@ -19,10 +19,10 @@ class UserMovementComponent : public Component { class PhysicsBodyComponent : public Component { public: void receive(Game& game, Entity& entity, const Message& msg); - void tick(Game& game, Entity& entity); + void tick(Game& game, Entity& entity, double dt); void detectCollision(Game& game, Entity& entity, Entity& collider, std::pair old_position); - private: + protected: std::pair velocity; std::pair accel; }; @@ -40,15 +40,13 @@ class PlayerSpriteComponent : public Component { bool dying = false; }; -class PlayerPhysicsComponent : public Component { +class PlayerPhysicsComponent : public PhysicsBodyComponent { public: PlayerPhysicsComponent(); - void tick(Game& game, Entity& entity); + void tick(Game& game, Entity& entity, double dt); void receive(Game& game, Entity& entity, const Message& msg); private: - std::pair velocity; - std::pair accel; double jump_velocity; double jump_gravity; double jump_gravity_short; -- cgit 1.4.1