summary refs log tree commit diff stats
path: root/src/systems/controlling.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-11 12:34:52 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-11 12:34:52 -0500
commit77be863f4f15d2481a64e4e8dadb4060a6e4e590 (patch)
treeca571702d2148a75b5b847e77d26270257f54ebc /src/systems/controlling.cpp
parent1400ade977e13e3b535d3c2fddb6e15de3c9b5a5 (diff)
downloadtherapy-77be863f4f15d2481a64e4e8dadb4060a6e4e590.tar.gz
therapy-77be863f4f15d2481a64e4e8dadb4060a6e4e590.tar.bz2
therapy-77be863f4f15d2481a64e4e8dadb4060a6e4e590.zip
Implemented map rendering and basic collision
Only wall and platform collision currently works, and map edges are not currently implemented.
Diffstat (limited to 'src/systems/controlling.cpp')
-rw-r--r--src/systems/controlling.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/systems/controlling.cpp b/src/systems/controlling.cpp index 3647ff8..fa09d11 100644 --- a/src/systems/controlling.cpp +++ b/src/systems/controlling.cpp
@@ -123,7 +123,7 @@ void ControllingSystem::walkLeft(id_type entity)
123 123
124 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); 124 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>();
125 125
126 if (ponderable.getState() == PonderableComponent::state::grounded) 126 if (ponderable.getState() == PonderableComponent::State::grounded)
127 { 127 {
128 animating.startAnimation(entity, "walkingLeft"); 128 animating.startAnimation(entity, "walkingLeft");
129 } else { 129 } else {
@@ -141,7 +141,7 @@ void ControllingSystem::walkRight(id_type entity)
141 141
142 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); 142 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>();
143 143
144 if (ponderable.getState() == PonderableComponent::state::grounded) 144 if (ponderable.getState() == PonderableComponent::State::grounded)
145 { 145 {
146 animating.startAnimation(entity, "walkingRight"); 146 animating.startAnimation(entity, "walkingRight");
147 } else { 147 } else {
@@ -156,7 +156,7 @@ void ControllingSystem::stopWalking(id_type entity)
156 156
157 ponderable.setVelocityX(0); 157 ponderable.setVelocityX(0);
158 158
159 if (ponderable.getState() == PonderableComponent::state::grounded) 159 if (ponderable.getState() == PonderableComponent::State::grounded)
160 { 160 {
161 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); 161 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>();
162 162
@@ -173,13 +173,13 @@ void ControllingSystem::jump(id_type entity)
173{ 173{
174 auto& ponderable = game_.getEntityManager().getComponent<PonderableComponent>(entity); 174 auto& ponderable = game_.getEntityManager().getComponent<PonderableComponent>(entity);
175 175
176 if (ponderable.getState() == PonderableComponent::state::grounded) 176 if (ponderable.getState() == PonderableComponent::State::grounded)
177 { 177 {
178 playSound("res/Randomize87.wav", 0.25); 178 playSound("res/Randomize87.wav", 0.25);
179 179
180 ponderable.setVelocityY(JUMP_VELOCITY(TILE_HEIGHT*4.5, 0.3)); 180 ponderable.setVelocityY(JUMP_VELOCITY(TILE_HEIGHT*4.5, 0.3));
181 ponderable.setAccelY(JUMP_GRAVITY(TILE_HEIGHT*4.5, 0.3)); 181 ponderable.setAccelY(JUMP_GRAVITY(TILE_HEIGHT*4.5, 0.3));
182 ponderable.setState(PonderableComponent::state::jumping); 182 ponderable.setState(PonderableComponent::State::jumping);
183 } 183 }
184} 184}
185 185
@@ -187,10 +187,10 @@ void ControllingSystem::stopJumping(id_type entity)
187{ 187{
188 auto& ponderable = game_.getEntityManager().getComponent<PonderableComponent>(entity); 188 auto& ponderable = game_.getEntityManager().getComponent<PonderableComponent>(entity);
189 189
190 if (ponderable.getState() == PonderableComponent::state::jumping) 190 if (ponderable.getState() == PonderableComponent::State::jumping)
191 { 191 {
192 ponderable.setAccelY(JUMP_GRAVITY(TILE_HEIGHT*3.5, 0.233)); 192 ponderable.setAccelY(JUMP_GRAVITY(TILE_HEIGHT*3.5, 0.233));
193 ponderable.setState(PonderableComponent::state::falling); 193 ponderable.setState(PonderableComponent::State::falling);
194 } 194 }
195} 195}
196 196
@@ -199,12 +199,12 @@ void ControllingSystem::drop(id_type entity, bool start)
199 auto& droppable = game_.getEntityManager().getComponent<DroppableComponent>(entity); 199 auto& droppable = game_.getEntityManager().getComponent<DroppableComponent>(entity);
200 auto& ponderable = game_.getEntityManager().getComponent<PonderableComponent>(entity); 200 auto& ponderable = game_.getEntityManager().getComponent<PonderableComponent>(entity);
201 201
202 if (start && (ponderable.getState() == PonderableComponent::state::grounded)) 202 if (start && (ponderable.getState() == PonderableComponent::State::grounded))
203 { 203 {
204 ponderable.setState(PonderableComponent::state::dropping); 204 ponderable.setState(PonderableComponent::State::dropping);
205 } else if ((!start) && (ponderable.getState() == PonderableComponent::state::dropping)) 205 } else if ((!start) && (ponderable.getState() == PonderableComponent::State::dropping))
206 { 206 {
207 ponderable.setState(PonderableComponent::state::grounded); 207 ponderable.setState(PonderableComponent::State::grounded);
208 } 208 }
209 droppable.setDroppable(start); 209 droppable.setDroppable(start);
210} 210}