SBSPSS/source/level/layercollision.h

86 lines
2.1 KiB
C
Raw Normal View History

2001-02-02 19:39:16 +01:00
/******************************/
2001-02-02 20:16:49 +01:00
/*** Collision Layer Class ***/
2001-02-02 19:39:16 +01:00
/******************************/
2001-02-02 20:16:49 +01:00
#ifndef __LAYER_COLLISION_H__
#define __LAYER_COLLISION_H__
2001-02-02 19:39:16 +01:00
2001-02-02 20:16:49 +01:00
#include <dstructs.h>
2001-02-02 19:39:16 +01:00
2001-02-13 17:45:31 +01:00
2001-05-12 19:24:44 +02:00
#if !defined(__USER_CDBUILD__)
2001-02-13 17:45:31 +01:00
#define __SHOW_COLLISION__
2001-05-12 19:24:44 +02:00
#endif
2001-02-13 17:45:31 +01:00
2001-02-02 19:39:16 +01:00
/*****************************************************************************/
2001-02-02 20:16:49 +01:00
class CLayerCollision
2001-02-02 19:39:16 +01:00
{
public:
2001-07-13 21:03:55 +02:00
enum
{
COL_Y_OFS =8,
};
2001-02-02 20:16:49 +01:00
CLayerCollision(sLayerHdr *Hdr);
virtual ~CLayerCollision();
2001-02-02 19:39:16 +01:00
2001-02-02 20:16:49 +01:00
virtual void shutdown();
2001-02-02 19:39:16 +01:00
2001-08-14 19:07:16 +02:00
int GetYPos(int Y) {return(ColYTable[Y+COL_Y_OFS]);}
2001-07-13 21:03:55 +02:00
2001-02-15 20:49:34 +01:00
int getHeightFromGround(int _x,int _y,int _maxHeight=32);
2001-07-12 17:45:39 +02:00
int getHeightFromGroundExcluding(int _x,int _y,int _exclusion,int _maxHeight=32);
2001-07-13 21:03:55 +02:00
int getHeightFromGroundNonSB(int _x,int _y,int _maxHeight=32) {return( CLayerCollision::getHeightFromGroundExcluding( _x, _y, COLLISION_TYPE_FLAG_SB_NOMOVE, _maxHeight ) );}
2001-07-06 21:42:07 +02:00
int getHeightFromGroundCart(int _x,int _y,int _maxHeight=32);
2001-08-14 21:19:13 +02:00
int getHeightFromGroundAmmo(int _x,int _y,int _maxHeight=32) {return(CLayerCollision::getHeightFromGroundExcluding( _x, _y, COLLISION_TYPE_FLAG_NORMAL, _maxHeight ));}
2001-02-02 20:46:54 +01:00
2001-08-14 21:19:13 +02:00
inline u8 *getMapPtr(int X,int Y)
2001-07-13 21:03:55 +02:00
{
2001-08-14 21:19:13 +02:00
X>>=4;
Y>>=4;
ASSERT((Y>=0-COL_Y_OFS) && (Y<MapHeight+COL_Y_OFS));
int Ofs=(X)+GetYPos(Y);
2001-07-13 21:03:55 +02:00
return(&Map[Ofs]);
// return(&Map[(_x>>4)+((_y>>4)*MapWidth)]);
}
2001-08-14 21:19:13 +02:00
inline int getCollisionBlock(int X,int Y)
2001-07-13 21:03:55 +02:00
{
2001-08-14 21:19:13 +02:00
u8 Col=*getMapPtr(X,Y);
2001-07-13 21:03:55 +02:00
return (Col);
// return Map[(_x>>4)+((_y>>4)*MapWidth)];
}
inline u8 Get(int X,int Y)
{
2001-08-14 21:19:13 +02:00
ASSERT((Y>=0-COL_Y_OFS) && (Y<MapHeight+COL_Y_OFS));
2001-07-14 16:17:34 +02:00
int Ofs=(X)+GetYPos(Y);
return(Map[Ofs] & COLLISION_TILE_MASK);
2001-07-13 21:03:55 +02:00
// return(Map[X+(Y*MapWidth)]&COLLISION_TILE_MASK);
}
2001-05-16 21:06:47 +02:00
2001-02-13 17:45:31 +01:00
#ifdef __SHOW_COLLISION__
void render(DVECTOR &MapPos);
#endif
2001-08-15 17:05:44 +02:00
// int getMapWidth() {return(MapWidth);}
// int getMapHeight() {return(MapHeight);}
2001-02-13 17:45:31 +01:00
2001-02-02 19:39:16 +01:00
protected:
2001-02-02 20:16:49 +01:00
sLayerHdr *LayerHdr;
int MapWidth,MapHeight;
2001-02-02 19:39:16 +01:00
2001-02-02 20:46:54 +01:00
2001-02-02 20:16:49 +01:00
u8 *Map;
2001-02-15 20:49:34 +01:00
2001-03-01 17:35:05 +01:00
static u8 s_collisionTable[];
2001-08-14 19:07:16 +02:00
int *ColYTable;
2001-02-02 19:39:16 +01:00
};
/*****************************************************************************/
#endif