diff --git a/assets/levelX.gif b/assets/levelX.gif index f0fdc60..f53df08 100644 Binary files a/assets/levelX.gif and b/assets/levelX.gif differ diff --git a/main.c b/main.c index fdab1f8..4c7f51d 100755 --- a/main.c +++ b/main.c @@ -1006,7 +1006,7 @@ RCL_Unit SFG_floorHeightAt(int16_t x, int16_t y) SFG_TileDefinition tile = SFG_getMapTile(SFG_currentLevel.levelPointer,x,y,&properties); - uint8_t doorHeight = 0; + RCL_Unit doorHeight = 0; if (properties == SFG_TILE_PROPERTY_DOOR) { @@ -1017,6 +1017,11 @@ RCL_Unit SFG_floorHeightAt(int16_t x, int16_t y) if ((door->coords[0] == x) && (door->coords[1] == y)) { doorHeight = door->state & SFG_DOOR_VERTICAL_POSITION_MASK; + + doorHeight = doorHeight != (0xff & SFG_DOOR_VERTICAL_POSITION_MASK) ? + doorHeight * SFG_DOOR_HEIGHT_STEP : RCL_UNITS_PER_SQUARE; + + break; } } @@ -1032,8 +1037,7 @@ RCL_Unit SFG_floorHeightAt(int16_t x, int16_t y) SFG_game.frameTime - SFG_currentLevel.timeStart); } - return SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP - - doorHeight * SFG_DOOR_HEIGHT_STEP; + return SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP - doorHeight; } /** diff --git a/raycastlib.h b/raycastlib.h index 625d665..8c51e79 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -1755,12 +1755,17 @@ void RCL_moveCameraWithCollision(RCL_Camera *camera, RCL_Vector2D planeOffset, RCL_Unit bottomLimit = -1 * RCL_INFINITY; RCL_Unit topLimit = RCL_INFINITY; + RCL_Unit currCeilHeight = RCL_INFINITY; + if (computeHeight) { bottomLimit = camera->height - RCL_CAMERA_COLL_HEIGHT_BELOW + RCL_CAMERA_COLL_STEP_HEIGHT; topLimit = camera->height + RCL_CAMERA_COLL_HEIGHT_ABOVE; + + if (ceilingHeightFunc != 0) + currCeilHeight = ceilingHeightFunc(xSquare,ySquare); } // checks a single square for collision against the camera @@ -1768,7 +1773,9 @@ void RCL_moveCameraWithCollision(RCL_Camera *camera, RCL_Vector2D planeOffset, if (computeHeight)\ {\ RCL_Unit height = floorHeightFunc(s1,s2);\ - if (height > bottomLimit)\ + if (height > bottomLimit || \ + currCeilHeight - height < \ + RCL_CAMERA_COLL_HEIGHT_BELOW + RCL_CAMERA_COLL_HEIGHT_ABOVE)\ dir##Collides = 1;\ else if (ceilingHeightFunc != 0)\ {\