This commit is contained in:
Charles 2001-07-05 22:27:34 +00:00
parent dbf746a287
commit dd6b6963e6
3 changed files with 70 additions and 3 deletions

View file

@ -207,6 +207,72 @@ int CLayerCollision::getHeightFromCeiling(int _x,int _y,int _maxHeight)
}
*/
/*****************************************************************************/
int CLayerCollision::getHeightFromGroundNonSB(int _x,int _y,int _maxHeight)
{
int mapX,mapY,xFraction,yFraction;
int distanceFromGround;
int colHeight;
int maxHeightToCheck;
mapX=_x>>4;
mapY=(_y>>4)*MapWidth;
xFraction=_x&0x0f;
yFraction=16-(_y&0x0f);
distanceFromGround=0;
colHeight=s_collisionTable[((Map[mapX+mapY]&COLLISION_TILE_MASK)*16)+xFraction];
if ( (Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_SB_NOMOVE )
{
colHeight = 0;
}
if(colHeight)
{
// Inside a collision block.. find the nearest ground above this point
maxHeightToCheck=-_maxHeight-16; // Need to check one block more incase we cross onto a new block
while(colHeight==16)
{
mapY-=MapWidth;
distanceFromGround-=16;
if(distanceFromGround<=maxHeightToCheck)
{
return -_maxHeight;
}
colHeight=s_collisionTable[((Map[mapX+mapY]&COLLISION_TILE_MASK)*16)+xFraction];
if ( (Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_SB_NOMOVE )
{
colHeight = 0;
}
}
distanceFromGround+=yFraction-colHeight;
if(distanceFromGround<-_maxHeight)distanceFromGround=-_maxHeight;
}
else
{
// Not inside a collision block.. find the nearest ground below this point
maxHeightToCheck=_maxHeight+16; // Need to check one block more incase we cross onto a new block
while(colHeight==0)
{
mapY+=MapWidth;
distanceFromGround+=16;
if(distanceFromGround>=maxHeightToCheck)
{
return _maxHeight;
}
colHeight=s_collisionTable[((Map[mapX+mapY]&COLLISION_TILE_MASK)*16)+xFraction];
if ( (Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_SB_NOMOVE )
{
colHeight = 0;
}
}
distanceFromGround+=yFraction-colHeight;
if(distanceFromGround>_maxHeight)distanceFromGround=_maxHeight;
}
return distanceFromGround;
}
/*****************************************************************************/
#ifdef __SHOW_COLLISION__
#include "gfx\prim.h"