summary refs log tree commit diff stats
path: root/src/transform_system.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2021-07-06 10:12:59 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2021-07-06 10:12:59 -0400
commit8aedeaf12c7dbf35f2f75f1b063b76a4fad06f30 (patch)
treeb90a7f804631d1921be64666e5ddc9bce31df371 /src/transform_system.cpp
parentb57aa99e101c7cf59fd59d2f8df9fe3547d91acc (diff)
downloadtanetane-8aedeaf12c7dbf35f2f75f1b063b76a4fad06f30.tar.gz
tanetane-8aedeaf12c7dbf35f2f75f1b063b76a4fad06f30.tar.bz2
tanetane-8aedeaf12c7dbf35f2f75f1b063b76a4fad06f30.zip
Added "floating" sprite attribute
Sprites with this flag enabled will ignore map collision.
Diffstat (limited to 'src/transform_system.cpp')
-rw-r--r--src/transform_system.cpp12
1 files changed, 8 insertions, 4 deletions
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
81 } 81 }
82 82
83 if (dirHasDir(dir, Direction::right)) { 83 if (dirHasDir(dir, Direction::right)) {
84 if (newTileDR.x() > oldTileDR.x() && 84 if (!sprite.floating &&
85 newTileDR.x() > oldTileDR.x() &&
85 newColDR.x() < mapBounds.w()) { 86 newColDR.x() < mapBounds.w()) {
86 for (int y = newTileUL.y(); y <= newTileDR.y(); y++) { 87 for (int y = newTileUL.y(); y <= newTileDR.y(); y++) {
87 if (map.isBlocked(newTileDR.x(), y)) { 88 if (map.isBlocked(newTileDR.x(), y)) {
@@ -138,7 +139,8 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i curLoc, vec2
138 } 139 }
139 140
140 if (dirHasDir(dir, Direction::left)) { 141 if (dirHasDir(dir, Direction::left)) {
141 if (newTileUL.x() < oldTileUL.x() && 142 if (!sprite.floating &&
143 newTileUL.x() < oldTileUL.x() &&
142 newColUL.x() >= 0) { 144 newColUL.x() >= 0) {
143 for (int y = newTileUL.y(); y <= newTileDR.y(); y++) { 145 for (int y = newTileUL.y(); y <= newTileDR.y(); y++) {
144 if (map.isBlocked(newTileUL.x(), y)) { 146 if (map.isBlocked(newTileUL.x(), y)) {
@@ -217,7 +219,8 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i curLoc, vec2
217 newTileDR = newColDR / map.getTileSize(); 219 newTileDR = newColDR / map.getTileSize();
218 220
219 if (dirHasDir(dir, Direction::down)) { 221 if (dirHasDir(dir, Direction::down)) {
220 if (newTileDR.y() > oldTileDR.y() && 222 if (!sprite.floating &&
223 newTileDR.y() > oldTileDR.y() &&
221 newColDR.y() < mapBounds.h()) { 224 newColDR.y() < mapBounds.h()) {
222 for (int x = newTileUL.x(); x <= newTileDR.x(); x++) { 225 for (int x = newTileUL.x(); x <= newTileDR.x(); x++) {
223 if (map.isBlocked(x, newTileDR.y())) { 226 if (map.isBlocked(x, newTileDR.y())) {
@@ -274,7 +277,8 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i curLoc, vec2
274 } 277 }
275 278
276 if (dirHasDir(dir, Direction::up)) { 279 if (dirHasDir(dir, Direction::up)) {
277 if (newTileUL.y() < oldTileUL.y() && 280 if (!sprite.floating &&
281 newTileUL.y() < oldTileUL.y() &&
278 newColUL.y() >= 0) { 282 newColUL.y() >= 0) {
279 for (int x = newTileUL.x(); x <= newTileDR.x(); x++) { 283 for (int x = newTileUL.x(); x <= newTileDR.x(); x++) {
280 if (map.isBlocked(x, newTileUL.y())) { 284 if (map.isBlocked(x, newTileUL.y())) {