Fix collisions

merge-requests/1/head
Miloslav Číž 3 years ago
parent ea6efb8b20
commit 361ec6e655

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

@ -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;
}
/**

@ -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)\
{\

Loading…
Cancel
Save