diff --git a/include/CollisionHandler.h b/include/CollisionHandler.h index fd9bff4..8c02980 100644 --- a/include/CollisionHandler.h +++ b/include/CollisionHandler.h @@ -19,14 +19,6 @@ class Entity; constexpr uint8_t DIRECTION_C = 4; -enum class direction -{ - LEFT = 0, - RIGHT, - UP, - DOWN -}; - using IntersectionBitSet = std::bitset; class CollisionHandler diff --git a/include/Direction.h b/include/Direction.h index a971704..88a5d91 100644 --- a/include/Direction.h +++ b/include/Direction.h @@ -3,5 +3,7 @@ enum class Direction { LEFT, - RIGHT + RIGHT, + UP, + DOWN }; \ No newline at end of file diff --git a/src/CollisionHandler.cpp b/src/CollisionHandler.cpp index 937a0a7..d481094 100644 --- a/src/CollisionHandler.cpp +++ b/src/CollisionHandler.cpp @@ -36,21 +36,21 @@ IntersectionBitSet CollisionHandler::getIntersection(Entity* entityA, Entity* en // checks all 4 directions to allow checking full overlap if (colliderA.x < colliderB.x + colliderB.w && colliderA.x > colliderB.x) { - intersections.set((size_t) direction::LEFT); + intersections.set((size_t) Direction::LEFT); } if (colliderA.x + colliderA.w < colliderB.x + colliderB.w && colliderA.x + colliderA.w > colliderB.x) { - intersections.set((size_t) direction::RIGHT); + intersections.set((size_t) Direction::RIGHT); } if (colliderA.y < colliderB.y + colliderB.h && colliderA.y > colliderB.y) - intersections.set((size_t) direction::UP); + intersections.set((size_t) Direction::UP); if (colliderA.y + colliderA.h < colliderB.y + colliderB.h && colliderA.y + colliderA.h > colliderB.y) - intersections.set((size_t) direction::DOWN); + intersections.set((size_t) Direction::DOWN); return intersections; } @@ -67,20 +67,20 @@ IntersectionBitSet CollisionHandler::getIntersectionWithBounds(Entity* entity, V // all 4 directions and both sides to allow checking for fully out of bounds if (collider->x + posMod.x < 0 || collider->x + posMod.x > SCREEN_SIZE_WIDTH) { - intersections.set((size_t) direction::LEFT); + intersections.set((size_t) Direction::LEFT); } if (collider->x + collider->w + posMod.x < 0 || collider->x + collider->w + posMod.x > SCREEN_SIZE_WIDTH) - intersections.set((size_t) direction::RIGHT); + intersections.set((size_t) Direction::RIGHT); if (collider->y + posMod.y < 0 || collider->y + posMod.y > SCREEN_SIZE_HEIGHT) - intersections.set((size_t) direction::UP); + intersections.set((size_t) Direction::UP); if (collider->y + collider->h + posMod.y < 0 || collider->y + collider->h + posMod.y > SCREEN_SIZE_HEIGHT) - intersections.set((size_t) direction::DOWN); + intersections.set((size_t) Direction::DOWN); return intersections; } diff --git a/src/TransformComponent.cpp b/src/TransformComponent.cpp index a143c7b..d586a1c 100644 --- a/src/TransformComponent.cpp +++ b/src/TransformComponent.cpp @@ -71,10 +71,10 @@ void TransformComponent::update() (Game::collisionHandler->getAnyIntersection(entity, Vector2D(0, positionChange.y), { GroupLabel::MAPTILES, GroupLabel::COLLIDERS })) & IntersectionBitSet("1100")); - if (intersections.test((size_t)direction::LEFT) || intersections.test((size_t)direction::RIGHT)) + if (intersections.test((size_t)Direction::LEFT) || intersections.test((size_t)Direction::RIGHT)) positionChange.x = 0; - if (intersections.test((size_t)direction::UP) || intersections.test((size_t)direction::DOWN)) + if (intersections.test((size_t)Direction::UP) || intersections.test((size_t)Direction::DOWN)) positionChange.y = 0; }