summary refs log tree commit diff stats
path: root/src/transform_system.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-23 22:22:49 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2021-02-24 16:00:53 -0500
commitb06b259c54e09f1a4026191d6eec9684599bd370 (patch)
treef31b241c3da5559d388d97bf9e65c2104f4652e8 /src/transform_system.cpp
parentae654356f843bb42a3c72d57b528d87aa63cf66d (diff)
downloadtanetane-b06b259c54e09f1a4026191d6eec9684599bd370.tar.gz
tanetane-b06b259c54e09f1a4026191d6eec9684599bd370.tar.bz2
tanetane-b06b259c54e09f1a4026191d6eec9684599bd370.zip
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??
Diffstat (limited to 'src/transform_system.cpp')
-rw-r--r--src/transform_system.cpp31
1 files changed, 27 insertions, 4 deletions
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
72 enclosureZone = &map.getZone(sprite.enclosureZone); 72 enclosureZone = &map.getZone(sprite.enclosureZone);
73 } 73 }
74 74
75 if (dirHasDir(sprite.dir, Direction::right)) { 75 if (dirHasDir(dir, Direction::right)) {
76 if (newTileDR.x() > oldTileDR.x() && 76 if (newTileDR.x() > oldTileDR.x() &&
77 newColDR.x() < mapBounds.w()) { 77 newColDR.x() < mapBounds.w()) {
78 for (int y = newTileUL.y(); y <= newTileDR.y(); y++) { 78 for (int y = newTileUL.y(); y <= newTileDR.y(); y++) {
@@ -113,7 +113,7 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i newLoc, Dire
113 } 113 }
114 } 114 }
115 115
116 if (dirHasDir(sprite.dir, Direction::left)) { 116 if (dirHasDir(dir, Direction::left)) {
117 if (newTileUL.x() < oldTileUL.x() && 117 if (newTileUL.x() < oldTileUL.x() &&
118 newColUL.x() >= 0) { 118 newColUL.x() >= 0) {
119 for (int y = newTileUL.y(); y <= newTileDR.y(); y++) { 119 for (int y = newTileUL.y(); y <= newTileDR.y(); y++) {
@@ -154,7 +154,7 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i newLoc, Dire
154 } 154 }
155 } 155 }
156 156
157 if (dirHasDir(sprite.dir, Direction::down)) { 157 if (dirHasDir(dir, Direction::down)) {
158 if (newTileDR.y() > oldTileDR.y() && 158 if (newTileDR.y() > oldTileDR.y() &&
159 newColDR.y() < mapBounds.h()) { 159 newColDR.y() < mapBounds.h()) {
160 for (int x = newTileUL.x(); x <= newTileDR.x(); x++) { 160 for (int x = newTileUL.x(); x <= newTileDR.x(); x++) {
@@ -195,7 +195,7 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i newLoc, Dire
195 } 195 }
196 } 196 }
197 197
198 if (dirHasDir(sprite.dir, Direction::up)) { 198 if (dirHasDir(dir, Direction::up)) {
199 if (newTileUL.y() < oldTileUL.y() && 199 if (newTileUL.y() < oldTileUL.y() &&
200 newColUL.y() >= 0) { 200 newColUL.y() >= 0) {
201 for (int x = newTileUL.x(); x <= newTileDR.x(); x++) { 201 for (int x = newTileUL.x(); x <= newTileDR.x(); x++) {
@@ -239,6 +239,29 @@ CollisionResult TransformSystem::checkCollision(int spriteId, vec2i newLoc, Dire
239 return result; 239 return result;
240} 240}
241 241
242CharacterMedium TransformSystem::getMediumAtPosition(int spriteId, vec2i newLoc) {
243 Sprite& sprite = game_.getSprite(spriteId);
244
245 const Map& map = game_.getMap();
246
247 vec2i newColUL = newLoc + sprite.collisionOffset;
248 vec2i newColDR = newColUL + sprite.collisionSize;
249 vec2i newTileUL = newColUL / map.getTileSize();
250 vec2i newTileDR = newColDR / map.getTileSize();
251
252 CharacterMedium result = CharacterMedium::Normal;
253 for (int y=newTileUL.y(); y<=newTileDR.y(); y++) {
254 for (int x=newTileUL.x(); x<=newTileDR.x(); x++) {
255 CharacterMedium tileMedium = map.getMedium(x, y);
256 if (tileMedium > result) {
257 result = tileMedium;
258 }
259 }
260 }
261
262 return result;
263}
264
242void TransformSystem::addCollidable(int spriteId) { 265void TransformSystem::addCollidable(int spriteId) {
243 Sprite& sprite = game_.getSprite(spriteId); 266 Sprite& sprite = game_.getSprite(spriteId);
244 267