mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-12-22 15:28:49 -05:00
Fix collisions
This commit is contained in:
parent
ea6efb8b20
commit
361ec6e655
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.5 KiB |
10
main.c
10
main.c
@ -1006,7 +1006,7 @@ RCL_Unit SFG_floorHeightAt(int16_t x, int16_t y)
|
|||||||
SFG_TileDefinition tile =
|
SFG_TileDefinition tile =
|
||||||
SFG_getMapTile(SFG_currentLevel.levelPointer,x,y,&properties);
|
SFG_getMapTile(SFG_currentLevel.levelPointer,x,y,&properties);
|
||||||
|
|
||||||
uint8_t doorHeight = 0;
|
RCL_Unit doorHeight = 0;
|
||||||
|
|
||||||
if (properties == SFG_TILE_PROPERTY_DOOR)
|
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))
|
if ((door->coords[0] == x) && (door->coords[1] == y))
|
||||||
{
|
{
|
||||||
doorHeight = door->state & SFG_DOOR_VERTICAL_POSITION_MASK;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1032,8 +1037,7 @@ RCL_Unit SFG_floorHeightAt(int16_t x, int16_t y)
|
|||||||
SFG_game.frameTime - SFG_currentLevel.timeStart);
|
SFG_game.frameTime - SFG_currentLevel.timeStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP -
|
return SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP - doorHeight;
|
||||||
doorHeight * SFG_DOOR_HEIGHT_STEP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1755,12 +1755,17 @@ void RCL_moveCameraWithCollision(RCL_Camera *camera, RCL_Vector2D planeOffset,
|
|||||||
RCL_Unit bottomLimit = -1 * RCL_INFINITY;
|
RCL_Unit bottomLimit = -1 * RCL_INFINITY;
|
||||||
RCL_Unit topLimit = RCL_INFINITY;
|
RCL_Unit topLimit = RCL_INFINITY;
|
||||||
|
|
||||||
|
RCL_Unit currCeilHeight = RCL_INFINITY;
|
||||||
|
|
||||||
if (computeHeight)
|
if (computeHeight)
|
||||||
{
|
{
|
||||||
bottomLimit = camera->height - RCL_CAMERA_COLL_HEIGHT_BELOW +
|
bottomLimit = camera->height - RCL_CAMERA_COLL_HEIGHT_BELOW +
|
||||||
RCL_CAMERA_COLL_STEP_HEIGHT;
|
RCL_CAMERA_COLL_STEP_HEIGHT;
|
||||||
|
|
||||||
topLimit = camera->height + RCL_CAMERA_COLL_HEIGHT_ABOVE;
|
topLimit = camera->height + RCL_CAMERA_COLL_HEIGHT_ABOVE;
|
||||||
|
|
||||||
|
if (ceilingHeightFunc != 0)
|
||||||
|
currCeilHeight = ceilingHeightFunc(xSquare,ySquare);
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks a single square for collision against the camera
|
// checks a single square for collision against the camera
|
||||||
@ -1768,7 +1773,9 @@ void RCL_moveCameraWithCollision(RCL_Camera *camera, RCL_Vector2D planeOffset,
|
|||||||
if (computeHeight)\
|
if (computeHeight)\
|
||||||
{\
|
{\
|
||||||
RCL_Unit height = floorHeightFunc(s1,s2);\
|
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;\
|
dir##Collides = 1;\
|
||||||
else if (ceilingHeightFunc != 0)\
|
else if (ceilingHeightFunc != 0)\
|
||||||
{\
|
{\
|
||||||
|
Loading…
Reference in New Issue
Block a user