summary refs log tree commit diff stats
path: root/src/systems/orienting.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-04-28 09:22:44 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-04-28 09:22:44 -0400
commit8016a7146fec3f6f43ca05723441750e5aae3d4d (patch)
tree0d527c1af80cf9ac34a027f9ee6f1acbb95db9f4 /src/systems/orienting.cpp
parentf782b81ba10c9b7a1e221b16de0aaa7b6c521729 (diff)
downloadtherapy-8016a7146fec3f6f43ca05723441750e5aae3d4d.tar.gz
therapy-8016a7146fec3f6f43ca05723441750e5aae3d4d.tar.bz2
therapy-8016a7146fec3f6f43ca05723441750e5aae3d4d.zip
Restructured the way the world is loaded
The World class was removed and replaced by the RealizingSystem and RealizableComponent. The realizable entity is intended to be a singleton and to represent the world. The Map class was also removed and integrated into the MappableComponent.

These changes are to facilitate implementation of map objects without needing special intermediary objects (including the Map class). Now, map entities are created as soon as the world is created, and map object entities will be as well. They will simply be deactivated while the map is not active. Multiple players are now slightly better supported, which will be important in the future.

This will likely become inefficient as the world becomes bigger, and some sort of sector-loading process will have to be designed. This also reduces the usefulness of EntityManager's entity-searching capabilities (which are not the most efficiently implemented currently anyway), and will likely in the future require some added functionality to better search subsets of entities.

A lot of the components were also rewritten to use bare member variables instead of accessor methods, as they never had special functionality and just took up space. These components were also documented.
Diffstat (limited to 'src/systems/orienting.cpp')
-rw-r--r--src/systems/orienting.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/systems/orienting.cpp b/src/systems/orienting.cpp index 2df8f87..206ebf6 100644 --- a/src/systems/orienting.cpp +++ b/src/systems/orienting.cpp
@@ -24,27 +24,27 @@ void OrientingSystem::tick(double)
24 { 24 {
25 case OrientableComponent::WalkState::still: 25 case OrientableComponent::WalkState::still:
26 { 26 {
27 ponderable.setVelocityX(0); 27 ponderable.velX = 0.0;
28 28
29 break; 29 break;
30 } 30 }
31 31
32 case OrientableComponent::WalkState::left: 32 case OrientableComponent::WalkState::left:
33 { 33 {
34 ponderable.setVelocityX(-WALK_SPEED); 34 ponderable.velX = -WALK_SPEED;
35 35
36 break; 36 break;
37 } 37 }
38 38
39 case OrientableComponent::WalkState::right: 39 case OrientableComponent::WalkState::right:
40 { 40 {
41 ponderable.setVelocityX(WALK_SPEED); 41 ponderable.velX = WALK_SPEED;
42 42
43 break; 43 break;
44 } 44 }
45 } 45 }
46 46
47 if (orientable.isJumping() && (ponderable.getVelocityY() > 0)) 47 if (orientable.isJumping() && (ponderable.velY > 0))
48 { 48 {
49 orientable.setJumping(false); 49 orientable.setJumping(false);
50 } 50 }
@@ -63,7 +63,7 @@ void OrientingSystem::moveLeft(id_type entity)
63 orientable.setWalkState(OrientableComponent::WalkState::left); 63 orientable.setWalkState(OrientableComponent::WalkState::left);
64 64
65 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); 65 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>();
66 if (ponderable.isGrounded()) 66 if (ponderable.grounded)
67 { 67 {
68 animating.startAnimation(entity, "walkingLeft"); 68 animating.startAnimation(entity, "walkingLeft");
69 } else { 69 } else {
@@ -83,7 +83,7 @@ void OrientingSystem::moveRight(id_type entity)
83 orientable.setWalkState(OrientableComponent::WalkState::right); 83 orientable.setWalkState(OrientableComponent::WalkState::right);
84 84
85 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); 85 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>();
86 if (ponderable.isGrounded()) 86 if (ponderable.grounded)
87 { 87 {
88 animating.startAnimation(entity, "walkingRight"); 88 animating.startAnimation(entity, "walkingRight");
89 } else { 89 } else {
@@ -113,7 +113,7 @@ void OrientingSystem::jump(id_type entity)
113 auto& ponderable = game_.getEntityManager(). 113 auto& ponderable = game_.getEntityManager().
114 getComponent<PonderableComponent>(entity); 114 getComponent<PonderableComponent>(entity);
115 115
116 if (ponderable.isGrounded()) 116 if (ponderable.grounded)
117 { 117 {
118 auto& orientable = game_.getEntityManager(). 118 auto& orientable = game_.getEntityManager().
119 getComponent<OrientableComponent>(entity); 119 getComponent<OrientableComponent>(entity);
@@ -122,8 +122,8 @@ void OrientingSystem::jump(id_type entity)
122 122
123 playSound("res/Randomize87.wav", 0.25); 123 playSound("res/Randomize87.wav", 0.25);
124 124
125 ponderable.setVelocityY(JUMP_VELOCITY); 125 ponderable.velY = JUMP_VELOCITY;
126 ponderable.setAccelY(JUMP_GRAVITY); 126 ponderable.accelY = JUMP_GRAVITY;
127 127
128 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); 128 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>();
129 if (orientable.isFacingRight()) 129 if (orientable.isFacingRight())
@@ -147,7 +147,7 @@ void OrientingSystem::stopJumping(id_type entity)
147 auto& ponderable = game_.getEntityManager(). 147 auto& ponderable = game_.getEntityManager().
148 getComponent<PonderableComponent>(entity); 148 getComponent<PonderableComponent>(entity);
149 149
150 ponderable.setAccelY(NORMAL_GRAVITY); 150 ponderable.accelY = NORMAL_GRAVITY;
151 } 151 }
152} 152}
153 153
@@ -211,7 +211,7 @@ void OrientingSystem::drop(id_type entity)
211 auto& ponderable = game_.getEntityManager(). 211 auto& ponderable = game_.getEntityManager().
212 getComponent<PonderableComponent>(entity); 212 getComponent<PonderableComponent>(entity);
213 213
214 if (ponderable.isGrounded() 214 if (ponderable.grounded
215 && (orientable.getDropState() == OrientableComponent::DropState::none)) 215 && (orientable.getDropState() == OrientableComponent::DropState::none))
216 { 216 {
217 orientable.setDropState(OrientableComponent::DropState::ready); 217 orientable.setDropState(OrientableComponent::DropState::ready);