From b06b259c54e09f1a4026191d6eec9684599bd370 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 23 Feb 2021 22:22:49 -0500 Subject: Started working on ladders TODO: * all the animations are weird. we will need to have an adjustable framerate bc the climbing animation does not look right at the current rate. (also remove the manual animation stuff ig) * does the medium stuff seem good and right? i am kinda not satisfied with it. * running onto a ladder causes the characters to bunch up bc the movement speed is slowed down but the trails are not doubled * no ladder running sound * shadows should vanish while on a ladder * uhh if you end a cutscene while on a ladder it resets the animation to "still" which is wrong. will this ever happen? idk * adding a sprite to your party while you are on a ladder?? --- src/transform_system.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src/transform_system.cpp') diff --git a/src/transform_system.cpp b/src/transform_system.cpp index ee392f1..4056f46 100644 --- a/src/transform_system.cpp +++ b/src/transform_system.cpp @@ -72,7 +72,7 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i newLoc, Dire enclosureZone = &map.getZone(sprite.enclosureZone); } - if (dirHasDir(sprite.dir, Direction::right)) { + if (dirHasDir(dir, Direction::right)) { if (newTileDR.x() > oldTileDR.x() && newColDR.x() < mapBounds.w()) { for (int y = newTileUL.y(); y <= newTileDR.y(); y++) { @@ -113,7 +113,7 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i newLoc, Dire } } - if (dirHasDir(sprite.dir, Direction::left)) { + if (dirHasDir(dir, Direction::left)) { if (newTileUL.x() < oldTileUL.x() && newColUL.x() >= 0) { for (int y = newTileUL.y(); y <= newTileDR.y(); y++) { @@ -154,7 +154,7 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i newLoc, Dire } } - if (dirHasDir(sprite.dir, Direction::down)) { + if (dirHasDir(dir, Direction::down)) { if (newTileDR.y() > oldTileDR.y() && newColDR.y() < mapBounds.h()) { for (int x = newTileUL.x(); x <= newTileDR.x(); x++) { @@ -195,7 +195,7 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i newLoc, Dire } } - if (dirHasDir(sprite.dir, Direction::up)) { + if (dirHasDir(dir, Direction::up)) { if (newTileUL.y() < oldTileUL.y() && newColUL.y() >= 0) { for (int x = newTileUL.x(); x <= newTileDR.x(); x++) { @@ -239,6 +239,29 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i newLoc, Dire return result; } +CharacterMedium TransformSystem::getMediumAtPosition(int spriteId, vec2i newLoc) { + Sprite& sprite = game_.getSprite(spriteId); + + const Map& map = game_.getMap(); + + vec2i newColUL = newLoc + sprite.collisionOffset; + vec2i newColDR = newColUL + sprite.collisionSize; + vec2i newTileUL = newColUL / map.getTileSize(); + vec2i newTileDR = newColDR / map.getTileSize(); + + CharacterMedium result = CharacterMedium::Normal; + for (int y=newTileUL.y(); y<=newTileDR.y(); y++) { + for (int x=newTileUL.x(); x<=newTileDR.x(); x++) { + CharacterMedium tileMedium = map.getMedium(x, y); + if (tileMedium > result) { + result = tileMedium; + } + } + } + + return result; +} + void TransformSystem::addCollidable(int spriteId) { Sprite& sprite = game_.getSprite(spriteId); -- cgit 1.4.1