diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-13 11:14:01 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-13 11:14:01 -0400 |
commit | b8d62ce8d2f7c8f38aa9c52ab8d7dd32dc3aba64 (patch) | |
tree | 42720ef2eefaf42abc25937e9a2a78cd6998f0f6 /src/components.h | |
parent | 47d9d7884c57c2c14dd363b4ccb0df1dcbb5375e (diff) | |
download | therapy-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.h | 10 |
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 { | |||
19 | class PhysicsBodyComponent : public Component { | 19 | class 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 | ||
43 | class PlayerPhysicsComponent : public Component { | 43 | class 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; |