summary refs log tree commit diff stats
path: root/src/systems
diff options
context:
space:
mode:
Diffstat (limited to 'src/systems')
-rw-r--r--src/systems/controlling.cpp12
-rw-r--r--src/systems/controlling.h6
-rw-r--r--src/systems/pondering.cpp6
-rw-r--r--src/systems/pondering.h2
-rw-r--r--src/systems/rendering.h4
5 files changed, 15 insertions, 15 deletions
diff --git a/src/systems/controlling.cpp b/src/systems/controlling.cpp index b1e73ad..456da3b 100644 --- a/src/systems/controlling.cpp +++ b/src/systems/controlling.cpp
@@ -14,12 +14,12 @@ void ControllingSystem::tick(double dt)
14 { 14 {
15 int key = actions.front().first; 15 int key = actions.front().first;
16 int action = actions.front().second; 16 int action = actions.front().second;
17 17
18 auto entities = game.getEntityManager().getEntitiesWithComponents<ControllableComponent, PonderableComponent, AnimatableComponent, DroppableComponent>(); 18 auto entities = game.getEntityManager().getEntitiesWithComponents<ControllableComponent, PonderableComponent, AnimatableComponent, DroppableComponent>();
19 for (auto entity : entities) 19 for (auto entity : entities)
20 { 20 {
21 auto& controllable = game.getEntityManager().getComponent<ControllableComponent>(entity); 21 auto& controllable = game.getEntityManager().getComponent<ControllableComponent>(entity);
22 22
23 if (action == GLFW_PRESS) 23 if (action == GLFW_PRESS)
24 { 24 {
25 if (key == controllable.getLeftKey()) 25 if (key == controllable.getLeftKey())
@@ -33,7 +33,7 @@ void ControllingSystem::tick(double dt)
33 } else if (key == controllable.getRightKey()) 33 } else if (key == controllable.getRightKey())
34 { 34 {
35 controllable.setHoldingRight(true); 35 controllable.setHoldingRight(true);
36 36
37 if (!controllable.isFrozen()) 37 if (!controllable.isFrozen())
38 { 38 {
39 walkRight(entity); 39 walkRight(entity);
@@ -56,7 +56,7 @@ void ControllingSystem::tick(double dt)
56 if (key == controllable.getLeftKey()) 56 if (key == controllable.getLeftKey())
57 { 57 {
58 controllable.setHoldingLeft(false); 58 controllable.setHoldingLeft(false);
59 59
60 if (!controllable.isFrozen()) 60 if (!controllable.isFrozen())
61 { 61 {
62 if (controllable.isHoldingRight()) 62 if (controllable.isHoldingRight())
@@ -69,7 +69,7 @@ void ControllingSystem::tick(double dt)
69 } else if (key == controllable.getRightKey()) 69 } else if (key == controllable.getRightKey())
70 { 70 {
71 controllable.setHoldingRight(false); 71 controllable.setHoldingRight(false);
72 72
73 if (!controllable.isFrozen()) 73 if (!controllable.isFrozen())
74 { 74 {
75 if (controllable.isHoldingRight()) 75 if (controllable.isHoldingRight())
@@ -94,7 +94,7 @@ void ControllingSystem::tick(double dt)
94 } 94 }
95 } 95 }
96 } 96 }
97 97
98 actions.pop(); 98 actions.pop();
99 } 99 }
100} 100}
diff --git a/src/systems/controlling.h b/src/systems/controlling.h index 61f86eb..30210b3 100644 --- a/src/systems/controlling.h +++ b/src/systems/controlling.h
@@ -8,10 +8,10 @@ class ControllingSystem : public System {
8 public: 8 public:
9 ControllingSystem(Game& game) 9 ControllingSystem(Game& game)
10 : System(game) {} 10 : System(game) {}
11 11
12 void tick(double dt); 12 void tick(double dt);
13 void input(int key, int action); 13 void input(int key, int action);
14 14
15 private: 15 private:
16 void walkLeft(int entity); 16 void walkLeft(int entity);
17 void walkRight(int entity); 17 void walkRight(int entity);
@@ -19,7 +19,7 @@ class ControllingSystem : public System {
19 void jump(int entity); 19 void jump(int entity);
20 void stopJumping(int entity); 20 void stopJumping(int entity);
21 void drop(int entity, bool start); 21 void drop(int entity, bool start);
22 22
23 std::queue<std::pair<int,int>> actions; 23 std::queue<std::pair<int,int>> actions;
24}; 24};
25 25
diff --git a/src/systems/pondering.cpp b/src/systems/pondering.cpp index 96775d0..50a8bc8 100644 --- a/src/systems/pondering.cpp +++ b/src/systems/pondering.cpp
@@ -6,16 +6,16 @@
6void PonderingSystem::tick(double dt) 6void PonderingSystem::tick(double dt)
7{ 7{
8 auto entities = game.getEntityManager().getEntitiesWithComponents<PonderableComponent, TransformableComponent>(); 8 auto entities = game.getEntityManager().getEntitiesWithComponents<PonderableComponent, TransformableComponent>();
9 9
10 for (auto entity : entities) 10 for (auto entity : entities)
11 { 11 {
12 auto& transformable = game.getEntityManager().getComponent<TransformableComponent>(entity); 12 auto& transformable = game.getEntityManager().getComponent<TransformableComponent>(entity);
13 auto& ponderable = game.getEntityManager().getComponent<PonderableComponent>(entity); 13 auto& ponderable = game.getEntityManager().getComponent<PonderableComponent>(entity);
14 14
15 // Accelerate 15 // Accelerate
16 ponderable.setVelocityX(ponderable.getVelocityX() + ponderable.getAccelX() * dt); 16 ponderable.setVelocityX(ponderable.getVelocityX() + ponderable.getAccelX() * dt);
17 ponderable.setVelocityY(ponderable.getVelocityY() + ponderable.getAccelY() * dt); 17 ponderable.setVelocityY(ponderable.getVelocityY() + ponderable.getAccelY() * dt);
18 18
19 // Move 19 // Move
20 transformable.setX(transformable.getX() + ponderable.getVelocityX() * dt); 20 transformable.setX(transformable.getX() + ponderable.getVelocityX() * dt);
21 transformable.setY(transformable.getY() + ponderable.getVelocityY() * dt); 21 transformable.setY(transformable.getY() + ponderable.getVelocityY() * dt);
diff --git a/src/systems/pondering.h b/src/systems/pondering.h index ad01a22..3fe5473 100644 --- a/src/systems/pondering.h +++ b/src/systems/pondering.h
@@ -7,7 +7,7 @@ class PonderingSystem : public System {
7 public: 7 public:
8 PonderingSystem(Game& game) 8 PonderingSystem(Game& game)
9 : System(game) {} 9 : System(game) {}
10 10
11 void tick(double dt); 11 void tick(double dt);
12}; 12};
13 13
diff --git a/src/systems/rendering.h b/src/systems/rendering.h index 9b6e27e..cec72e2 100644 --- a/src/systems/rendering.h +++ b/src/systems/rendering.h
@@ -9,9 +9,9 @@ class RenderingSystem : public System {
9 public: 9 public:
10 RenderingSystem(Game& game) 10 RenderingSystem(Game& game)
11 : System(game) {} 11 : System(game) {}
12 12
13 void tick(double dt); 13 void tick(double dt);
14 14
15 private: 15 private:
16 Texture texture {GAME_WIDTH, GAME_HEIGHT}; 16 Texture texture {GAME_WIDTH, GAME_HEIGHT};
17}; 17};