2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
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;
|
|
|
|
|
|
|
|
bool IsTileSolid(int x, int y);
|
|
|
|
int GetTile(int x, int y);
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLFLAG_SOLID=1,
|
|
|
|
COLFLAG_DEATH=2,
|
|
|
|
COLFLAG_NOHOOK=4,
|
|
|
|
};
|
|
|
|
|
|
|
|
CCollision();
|
|
|
|
void Init(class CLayers *pLayers);
|
2011-02-13 06:47:51 +00:00
|
|
|
bool CheckPoint(float x, float y) { return IsTileSolid(round(x), round(y)); }
|
|
|
|
bool CheckPoint(vec2 Pos) { return CheckPoint(Pos.x, Pos.y); }
|
|
|
|
int GetCollisionAt(float x, float y) { return GetTile(round(x), round(y)); }
|
2010-05-29 07:25:38 +00:00
|
|
|
int GetWidth() { return m_Width; };
|
|
|
|
int GetHeight() { return m_Height; };
|
|
|
|
int IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
|
2011-02-12 09:30:47 +00:00
|
|
|
void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *pBounces);
|
2010-05-29 07:25:38 +00:00
|
|
|
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
|
|
|
|
bool TestBox(vec2 Pos, vec2 Size);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|