diff options
Diffstat (limited to 'src/systems/orienting.cpp')
| -rw-r--r-- | src/systems/orienting.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
| diff --git a/src/systems/orienting.cpp b/src/systems/orienting.cpp index d73ddd2..a2be34f 100644 --- a/src/systems/orienting.cpp +++ b/src/systems/orienting.cpp | |||
| @@ -20,30 +20,6 @@ void OrientingSystem::tick(double) | |||
| 20 | auto& ponderable = game_.getEntityManager(). | 20 | auto& ponderable = game_.getEntityManager(). |
| 21 | getComponent<PonderableComponent>(entity); | 21 | getComponent<PonderableComponent>(entity); |
| 22 | 22 | ||
| 23 | switch (orientable.getWalkState()) | ||
| 24 | { | ||
| 25 | case OrientableComponent::WalkState::still: | ||
| 26 | { | ||
| 27 | ponderable.vel.x() = 0.0; | ||
| 28 | |||
| 29 | break; | ||
| 30 | } | ||
| 31 | |||
| 32 | case OrientableComponent::WalkState::left: | ||
| 33 | { | ||
| 34 | ponderable.vel.x() = -WALK_SPEED; | ||
| 35 | |||
| 36 | break; | ||
| 37 | } | ||
| 38 | |||
| 39 | case OrientableComponent::WalkState::right: | ||
| 40 | { | ||
| 41 | ponderable.vel.x() = WALK_SPEED; | ||
| 42 | |||
| 43 | break; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | if (orientable.isJumping() && (ponderable.vel.y() > 0)) | 23 | if (orientable.isJumping() && (ponderable.vel.y() > 0)) |
| 48 | { | 24 | { |
| 49 | orientable.setJumping(false); | 25 | orientable.setJumping(false); |
| @@ -62,6 +38,8 @@ void OrientingSystem::moveLeft(id_type entity) | |||
| 62 | orientable.setFacingRight(false); | 38 | orientable.setFacingRight(false); |
| 63 | orientable.setWalkState(OrientableComponent::WalkState::left); | 39 | orientable.setWalkState(OrientableComponent::WalkState::left); |
| 64 | 40 | ||
| 41 | ponderable.targetVel.x() = -WALK_SPEED; | ||
| 42 | |||
| 65 | auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); | 43 | auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); |
| 66 | if (ponderable.grounded) | 44 | if (ponderable.grounded) |
| 67 | { | 45 | { |
| @@ -82,6 +60,8 @@ void OrientingSystem::moveRight(id_type entity) | |||
| 82 | orientable.setFacingRight(true); | 60 | orientable.setFacingRight(true); |
| 83 | orientable.setWalkState(OrientableComponent::WalkState::right); | 61 | orientable.setWalkState(OrientableComponent::WalkState::right); |
| 84 | 62 | ||
| 63 | ponderable.targetVel.x() = WALK_SPEED; | ||
| 64 | |||
| 85 | auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); | 65 | auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); |
| 86 | if (ponderable.grounded) | 66 | if (ponderable.grounded) |
| 87 | { | 67 | { |
| @@ -93,10 +73,14 @@ void OrientingSystem::moveRight(id_type entity) | |||
| 93 | 73 | ||
| 94 | void OrientingSystem::stopWalking(id_type entity) | 74 | void OrientingSystem::stopWalking(id_type entity) |
| 95 | { | 75 | { |
| 76 | auto& ponderable = game_.getEntityManager(). | ||
| 77 | getComponent<PonderableComponent>(entity); | ||
| 78 | |||
| 96 | auto& orientable = game_.getEntityManager(). | 79 | auto& orientable = game_.getEntityManager(). |
| 97 | getComponent<OrientableComponent>(entity); | 80 | getComponent<OrientableComponent>(entity); |
| 98 | 81 | ||
| 99 | orientable.setWalkState(OrientableComponent::WalkState::still); | 82 | orientable.setWalkState(OrientableComponent::WalkState::still); |
| 83 | ponderable.targetVel.x() = 0; | ||
| 100 | 84 | ||
| 101 | auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); | 85 | auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); |
| 102 | 86 | ||
