summary refs log tree commit diff stats
path: root/src/components.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2015-03-13 11:14:01 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2015-03-13 11:14:01 -0400
commitb8d62ce8d2f7c8f38aa9c52ab8d7dd32dc3aba64 (patch)
tree42720ef2eefaf42abc25937e9a2a78cd6998f0f6 /src/components.h
parent47d9d7884c57c2c14dd363b4ccb0df1dcbb5375e (diff)
downloadtherapy-b8d62ce8d2f7c8f38aa9c52ab8d7dd32dc3aba64.tar.gz
therapy-b8d62ce8d2f7c8f38aa9c52ab8d7dd32dc3aba64.tar.bz2
therapy-b8d62ce8d2f7c8f38aa9c52ab8d7dd32dc3aba64.zip
Fixed my timestep!
http://gafferongames.com/game-physics/fix-your-timestep/
Diffstat (limited to 'src/components.h')
-rw-r--r--src/components.h10
1 files changed, 4 insertions, 6 deletions
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 {
19class PhysicsBodyComponent : public Component { 19class PhysicsBodyComponent : public Component {
20 public: 20 public:
21 void receive(Game& game, Entity& entity, const Message& msg); 21 void receive(Game& game, Entity& entity, const Message& msg);
22 void tick(Game& game, Entity& entity); 22 void tick(Game& game, Entity& entity, double dt);
23 void detectCollision(Game& game, Entity& entity, Entity& collider, std::pair<double, double> old_position); 23 void detectCollision(Game& game, Entity& entity, Entity& collider, std::pair<double, double> old_position);
24 24
25 private: 25 protected:
26 std::pair<double, double> velocity; 26 std::pair<double, double> velocity;
27 std::pair<double, double> accel; 27 std::pair<double, double> accel;
28}; 28};
@@ -40,15 +40,13 @@ class PlayerSpriteComponent : public Component {
40 bool dying = false; 40 bool dying = false;
41}; 41};
42 42
43class PlayerPhysicsComponent : public Component { 43class PlayerPhysicsComponent : public PhysicsBodyComponent {
44 public: 44 public:
45 PlayerPhysicsComponent(); 45 PlayerPhysicsComponent();
46 void tick(Game& game, Entity& entity); 46 void tick(Game& game, Entity& entity, double dt);
47 void receive(Game& game, Entity& entity, const Message& msg); 47 void receive(Game& game, Entity& entity, const Message& msg);
48 48
49 private: 49 private:
50 std::pair<double, double> velocity;
51 std::pair<double, double> accel;
52 double jump_velocity; 50 double jump_velocity;
53 double jump_gravity; 51 double jump_gravity;
54 double jump_gravity_short; 52 double jump_gravity_short;