From 8aedeaf12c7dbf35f2f75f1b063b76a4fad06f30 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 6 Jul 2021 10:12:59 -0400 Subject: Added "floating" sprite attribute Sprites with this flag enabled will ignore map collision. --- src/transform_system.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/transform_system.cpp') diff --git a/src/transform_system.cpp b/src/transform_system.cpp index 825514f..425d8ea 100644 --- a/src/transform_system.cpp +++ b/src/transform_system.cpp @@ -81,7 +81,8 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i curLoc, vec2 } if (dirHasDir(dir, Direction::right)) { - if (newTileDR.x() > oldTileDR.x() && + if (!sprite.floating && + newTileDR.x() > oldTileDR.x() && newColDR.x() < mapBounds.w()) { for (int y = newTileUL.y(); y <= newTileDR.y(); y++) { if (map.isBlocked(newTileDR.x(), y)) { @@ -138,7 +139,8 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i curLoc, vec2 } if (dirHasDir(dir, Direction::left)) { - if (newTileUL.x() < oldTileUL.x() && + if (!sprite.floating && + newTileUL.x() < oldTileUL.x() && newColUL.x() >= 0) { for (int y = newTileUL.y(); y <= newTileDR.y(); y++) { if (map.isBlocked(newTileUL.x(), y)) { @@ -217,7 +219,8 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i curLoc, vec2 newTileDR = newColDR / map.getTileSize(); if (dirHasDir(dir, Direction::down)) { - if (newTileDR.y() > oldTileDR.y() && + if (!sprite.floating && + newTileDR.y() > oldTileDR.y() && newColDR.y() < mapBounds.h()) { for (int x = newTileUL.x(); x <= newTileDR.x(); x++) { if (map.isBlocked(x, newTileDR.y())) { @@ -274,7 +277,8 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i curLoc, vec2 } if (dirHasDir(dir, Direction::up)) { - if (newTileUL.y() < oldTileUL.y() && + if (!sprite.floating && + newTileUL.y() < oldTileUL.y() && newColUL.y() >= 0) { for (int x = newTileUL.x(); x <= newTileDR.x(); x++) { if (map.isBlocked(x, newTileUL.y())) { -- cgit 1.4.1