2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_COLLISION_H
|
|
|
|
#define GAME_COLLISION_H
|
|
|
|
|
|
|
|
#include <base/vmath.h>
|
|
|
|
|
|
|
|
class CCollision
|
|
|
|
{
|
|
|
|
class CTile *m_pTiles;
|
|
|
|
int m_Width;
|
|
|
|
int m_Height;
|
|
|
|
class CLayers *m_pLayers;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLFLAG_SOLID=1,
|
|
|
|
COLFLAG_DEATH=2,
|
|
|
|
COLFLAG_NOHOOK=4,
|
2010-07-29 05:21:18 +00:00
|
|
|
COLFLAG_NOLASER=8,
|
2010-08-10 04:28:17 +00:00
|
|
|
COLFLAG_THROUGH=16
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
CCollision();
|
|
|
|
void Init(class CLayers *pLayers);
|
2010-08-10 04:28:17 +00:00
|
|
|
bool CheckPoint(float x, float y) { return IsSolid(round(x), round(y)); }
|
2010-05-29 07:25:38 +00:00
|
|
|
bool CheckPoint(vec2 p) { return CheckPoint(p.x, p.y); }
|
2010-08-21 19:48:47 +00:00
|
|
|
bool FCheckPoint(float x, float y) { return IsFSolid(round(x), round(y)); }
|
|
|
|
bool FCheckPoint(vec2 p) { return FCheckPoint(p.x, p.y); }
|
2010-08-10 04:28:17 +00:00
|
|
|
void SetCollisionAt(float x, float y, int flag);
|
2010-05-29 07:25:38 +00:00
|
|
|
int GetCollisionAt(float x, float y) { return GetTile(round(x), round(y)); }
|
2010-08-21 19:48:47 +00:00
|
|
|
int GetFCollisionAt(float x, float y) { return GetFTile(round(x), round(y)); }
|
2010-05-29 07:25:38 +00:00
|
|
|
int GetWidth() { return m_Width; };
|
|
|
|
int GetHeight() { return m_Height; };
|
2010-08-21 02:20:01 +00:00
|
|
|
int IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough);
|
2010-08-10 04:28:17 +00:00
|
|
|
int IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
|
2010-08-21 17:34:33 +00:00
|
|
|
int IntersectNoLaserNW(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
|
2010-08-10 04:28:17 +00:00
|
|
|
int IntersectAir(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
|
2010-05-29 07:25:38 +00:00
|
|
|
void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *Bpounces);
|
|
|
|
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
|
|
|
|
bool TestBox(vec2 Pos, vec2 Size);
|
2010-08-10 04:28:17 +00:00
|
|
|
int GetTile(int x, int y);
|
2010-08-21 19:48:47 +00:00
|
|
|
int GetFTile(int x, int y);
|
2010-08-20 20:40:12 +00:00
|
|
|
int Entity(int x, int y, bool Front);
|
2010-07-29 14:53:25 +00:00
|
|
|
//DDRace
|
2010-08-15 14:42:40 +00:00
|
|
|
int GetMapIndex(vec2 PrevPos, vec2 Pos);
|
2010-08-10 04:28:17 +00:00
|
|
|
vec2 GetPos(int Index);
|
|
|
|
int GetCollisionDDRace(int Index);
|
2010-08-21 19:48:47 +00:00
|
|
|
int GetFCollisionDDRace(int Index);
|
2010-07-29 05:21:18 +00:00
|
|
|
int IsTeleport(int x, int y);
|
2010-08-21 19:48:47 +00:00
|
|
|
//int IsCheckpoint(int Index);
|
2010-08-10 04:28:17 +00:00
|
|
|
bool IsSpeedup(int x, int y);
|
|
|
|
void GetSpeedup(int x, int y, vec2 *Dir, int *Force);
|
2010-07-29 05:21:18 +00:00
|
|
|
|
2010-08-10 04:28:17 +00:00
|
|
|
int IsSolid(int x, int y);
|
2010-08-21 19:48:47 +00:00
|
|
|
int IsFSolid(int x, int y);
|
2010-08-21 02:20:01 +00:00
|
|
|
int IsThrough(int x, int y);
|
2010-08-10 04:28:17 +00:00
|
|
|
int IsNoLaser(int x, int y);
|
2010-08-21 19:48:47 +00:00
|
|
|
int IsFNoLaser(int x, int y);
|
2010-08-10 04:28:17 +00:00
|
|
|
int IsCp(int x, int y);
|
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
vec2 CpSpeed(int index);
|
2010-08-10 04:28:17 +00:00
|
|
|
|
|
|
|
class CTeleTile *m_pTele;
|
|
|
|
class CSpeedupTile *m_pSpeedup;
|
2010-08-15 14:42:40 +00:00
|
|
|
class CTile *m_pFront;
|
2010-08-10 04:28:17 +00:00
|
|
|
class CLayers *Layers() { return m_pLayers; }
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|