feat: add working shapes

This commit is contained in:
2021-11-22 19:15:32 +01:00
parent 1d7a8cc66b
commit 7fb357e9c8
5 changed files with 42 additions and 27 deletions

View File

@@ -265,13 +265,13 @@ void World::cleanDeadMobs() {
TowerPtr World::getTower(const glm::vec2& position) const {
for (TowerPtr tower : m_Towers) {
if (tower->getSize() == TowerSize::Big) {
if (tower->getX() - 2 <= static_cast<std::int32_t>(position.x) && tower->getX() + 2 >= static_cast<std::int32_t>(position.x) &&
tower->getY() - 2 <= static_cast<std::int32_t>(position.y) && tower->getY() + 2 >= static_cast<std::int32_t>(position.y)) {
if (tower->getCenterX() - 2.5f < position.x && tower->getCenterX() + 2.5f > position.x &&
tower->getCenterY() - 2.5f < position.y && tower->getCenterY() + 2.5f > position.y) {
return tower;
}
} else {
if (tower->getX() - 1 <= static_cast<std::int32_t>(position.x) && tower->getX() + 1 >= static_cast<std::int32_t>(position.x) &&
tower->getY() - 1 <= static_cast<std::int32_t>(position.y) && tower->getY() + 1 >= static_cast<std::int32_t>(position.y)) {
} else { // little tower
if (tower->getCenterX() - 1.5f < position.x && tower->getCenterX() + 1.5f > position.x &&
tower->getCenterY() - 1.5f < position.y && tower->getCenterY() + 1.5f > position.y) {
return tower;
}
}