This commit is contained in:
parent
0b65d9d4a7
commit
c110d56dc5
15 changed files with 403 additions and 536 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "game\event.h"
|
||||
#endif
|
||||
|
||||
#include <dstructs.h>
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
@ -39,15 +40,15 @@
|
|||
-------------------- */
|
||||
|
||||
// Collision rectangle definition
|
||||
typedef struct
|
||||
struct CRECT
|
||||
{
|
||||
int x1,y1,x2,y2;
|
||||
}
|
||||
CRECT;
|
||||
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
// Thing manager class
|
||||
class CThingManager
|
||||
class CThing;
|
||||
class CThingManager
|
||||
{
|
||||
public:
|
||||
static void init();
|
||||
|
@ -56,27 +57,38 @@ public:
|
|||
|
||||
static void thinkAllThings(int _frames);
|
||||
static void renderAllThings();
|
||||
static void processEventAllThings(GAME_EVENT _event,class CThing *_sourceThing);
|
||||
static void processEventAllThings(GAME_EVENT _event,CThing *_sourceThing);
|
||||
|
||||
static CThing* checkCollisionAreaAgainstThings(CRECT *_area,int _type,int _continue);
|
||||
static void initCollision();
|
||||
|
||||
static sBBox &getRenderBBox() {return(m_RenderBBox);}
|
||||
static sBBox &getThinkBBox() {return(m_ThinkBBox);}
|
||||
|
||||
protected:
|
||||
static void addToThingList(class CThing *_this);
|
||||
static void removeFromThingList(CThing *_this);
|
||||
friend class CThing;
|
||||
static void initList(CThing **List);
|
||||
static void addToThingList(CThing *_this);
|
||||
static void removeFromThingList(CThing *_this);
|
||||
|
||||
static void addToCollisionList(CThing *_this);
|
||||
|
||||
friend class CThing;
|
||||
|
||||
private:
|
||||
static class CThing *s_thingLists[];
|
||||
static int s_initialised;
|
||||
static CThing *s_thingLists[];
|
||||
static int s_initialised;
|
||||
|
||||
static CThing *s_CollisionLists[];
|
||||
static sBBox m_RenderBBox;
|
||||
static sBBox m_ThinkBBox;
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
// Base thing class
|
||||
class CThing
|
||||
{
|
||||
public:
|
||||
typedef enum
|
||||
enum TYPE
|
||||
{
|
||||
TYPE_PICKUP,
|
||||
TYPE_PLATFORM,
|
||||
|
@ -90,164 +102,157 @@ public:
|
|||
TYPE_FX,
|
||||
|
||||
MAX_TYPE,
|
||||
}
|
||||
TYPE;
|
||||
};
|
||||
// TYPE;
|
||||
CThing() {;}
|
||||
virtual ~CThing() {;}
|
||||
|
||||
CThing() {;}
|
||||
virtual ~CThing() {;}
|
||||
virtual TYPE getThingType()=0;
|
||||
|
||||
virtual TYPE getThingType()=0;
|
||||
|
||||
|
||||
virtual void init();
|
||||
virtual void shutdown();
|
||||
virtual void think(int _frames);
|
||||
virtual void render();
|
||||
virtual u8 isSetToShutdown() {return( false );}
|
||||
virtual void init();
|
||||
virtual void shutdown();
|
||||
virtual void think(int _frames);
|
||||
virtual void render();
|
||||
virtual u8 isSetToShutdown() {return( false );}
|
||||
|
||||
// Linkage
|
||||
void addChild(CThing *Child);
|
||||
void removeChild(CThing *Child);
|
||||
void removeAllChild();
|
||||
void deleteAllChild();
|
||||
bool hasChild(CThing *Child);
|
||||
int getNumChildren();
|
||||
void addChild(CThing *Child);
|
||||
void removeChild(CThing *Child);
|
||||
void removeAllChild();
|
||||
void deleteAllChild();
|
||||
bool hasChild(CThing *Child);
|
||||
int getNumChildren();
|
||||
|
||||
|
||||
DVECTOR getPos() {return Pos;}
|
||||
void setPos(DVECTOR newPos) {Pos=newPos;}
|
||||
DVECTOR getPosDelta() {return PosDelta;}
|
||||
CThing *getNext() {return Next;}
|
||||
|
||||
|
||||
virtual void processEvent(GAME_EVENT _event,CThing *_sourceThing);
|
||||
DVECTOR const &getPos() {return Pos;}
|
||||
void setPos(DVECTOR newPos) {Pos=newPos;}
|
||||
DVECTOR getPosDelta() {return PosDelta;}
|
||||
CThing *getNext() {return Next;}
|
||||
|
||||
virtual void processEvent(GAME_EVENT _event,CThing *_sourceThing);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
// Linkage
|
||||
CThing *Parent,*Next;
|
||||
// Parent Child Linkage
|
||||
CThing *Parent,*Next;
|
||||
// Count
|
||||
int m_numChildren;
|
||||
int m_numChildren;
|
||||
// Pos
|
||||
DVECTOR Pos, PosLast, PosDelta;
|
||||
DVECTOR Pos, PosLast, PosDelta;
|
||||
|
||||
public:
|
||||
class CThing *m_nextThing;
|
||||
|
||||
|
||||
|
||||
|
||||
CThing *m_nextListThing;
|
||||
CThing *m_nextCollisionThing;
|
||||
|
||||
// -- Collision --
|
||||
public:
|
||||
DVECTOR getCollisionCentre() {return m_collisionCentre;}
|
||||
DVECTOR getCollisionCentreOffset() {return m_collisionCentreOffset;}
|
||||
int getCollisionRadius() {return m_collisionRadius;}
|
||||
CRECT getCollisionArea() {return m_collisionArea;}
|
||||
s16 getCollisionAngle() {return m_collisionAngle;} // pkg - move to CNpcPlatform?
|
||||
DVECTOR getNewCollidedPos() {return m_newCollidedPos;} // pkg - to be removed?
|
||||
DVECTOR getCollisionSize() {return m_collisionSize;}
|
||||
void ShowBBox();
|
||||
DVECTOR const &getCollisionCentre() {return m_collisionCentre;}
|
||||
DVECTOR const &getCollisionCentreOffset() {return m_collisionCentreOffset;}
|
||||
int getCollisionRadius() {return m_collisionRadius;}
|
||||
CRECT const &getCollisionArea() {return m_collisionArea;}
|
||||
s16 getCollisionAngle() {return m_collisionAngle;} // pkg - move to CNpcPlatform?
|
||||
DVECTOR const &getNewCollidedPos() {return m_newCollidedPos;} // pkg - to be removed?
|
||||
DVECTOR const &getCollisionSize() {return m_collisionSize;}
|
||||
|
||||
virtual int canCollide() {return true;}
|
||||
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
|
||||
int checkCollisionAgainstArea(CRECT *_rect);
|
||||
void updateCollisionArea();
|
||||
virtual void collidedWith(CThing *_thisThing) {;}
|
||||
virtual void setHasPlatformCollided( bool newVal ) {;}
|
||||
virtual bool getHasPlatformCollided() {return false;}
|
||||
virtual s32 getNewYPos( CThing *_thisThing );
|
||||
void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;} // pkg - to be removed?
|
||||
virtual int canCollide() {return true;}
|
||||
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
|
||||
int checkCollisionAgainstArea(CRECT *_rect);
|
||||
void updateCollisionArea();
|
||||
virtual void collidedWith(CThing *_thisThing) {;}
|
||||
virtual void setHasPlatformCollided( bool newVal ) {;}
|
||||
virtual bool getHasPlatformCollided() {return false;}
|
||||
virtual s32 getNewYPos( CThing *_thisThing );
|
||||
void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;} // pkg - to be removed?
|
||||
|
||||
bool IsOnScreen() {return(m_OnScreenFlag);/* Put check code here */}
|
||||
bool getOnScreenFlag() {return(m_OnScreenFlag);}
|
||||
void setOnScreenFlag(bool f) {m_OnScreenFlag=f;}
|
||||
bool canRender() {return (m_renderFlag);}
|
||||
DVECTOR &getRenderPos() {return(m_RenderPos);}
|
||||
bool canThink() {return (m_thinkFlag);}
|
||||
|
||||
protected:
|
||||
virtual void setCollisionSize(int _w,int _h);
|
||||
virtual void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;}
|
||||
virtual void setCollisionCentreOffset(DVECTOR xy) {m_collisionCentreOffset=xy;}
|
||||
virtual void setCollisionAngle(int newAngle) {m_collisionAngle = newAngle;} // pkg - move to CNpcPlatform?
|
||||
virtual void setCollisionSize(int _w,int _h);
|
||||
virtual void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;}
|
||||
virtual void setCollisionCentreOffset(DVECTOR xy) {m_collisionCentreOffset=xy;}
|
||||
virtual void setCollisionAngle(int newAngle) {m_collisionAngle = newAngle;} // pkg - move to CNpcPlatform?
|
||||
private:
|
||||
DVECTOR m_collisionSize;
|
||||
DVECTOR m_collisionCentreOffset;
|
||||
int m_collisionRadius;
|
||||
CRECT m_collisionArea;
|
||||
DVECTOR m_collisionCentre;
|
||||
s16 m_collisionAngle; // pkg - move to CNpcPlatform?
|
||||
DVECTOR m_newCollidedPos; // pkg - to be removed?
|
||||
bool m_OnScreenFlag;
|
||||
DVECTOR m_collisionSize;
|
||||
DVECTOR m_collisionCentreOffset;
|
||||
int m_collisionRadius;
|
||||
CRECT m_collisionArea;
|
||||
DVECTOR m_collisionCentre;
|
||||
s16 m_collisionAngle; // pkg - move to CNpcPlatform?
|
||||
DVECTOR m_newCollidedPos; // pkg - to be removed?
|
||||
|
||||
bool m_renderFlag,m_thinkFlag;
|
||||
DVECTOR m_RenderPos;
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
/* These are the individual base classes for each of the seperate thing types */
|
||||
class CPickupThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_PICKUP;}
|
||||
virtual TYPE getThingType() {return TYPE_PICKUP;}
|
||||
};
|
||||
|
||||
class CPlayerThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_PLAYER;}
|
||||
virtual TYPE getThingType() {return TYPE_PLAYER;}
|
||||
};
|
||||
|
||||
class CPlayerProjectileThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_PLAYERPROJECTILE;}
|
||||
virtual TYPE getThingType() {return TYPE_PLAYERPROJECTILE;}
|
||||
};
|
||||
|
||||
class CNpcThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_NPC;}
|
||||
virtual TYPE getThingType() {return TYPE_NPC;}
|
||||
};
|
||||
|
||||
class CEnemyThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_ENEMY;}
|
||||
virtual TYPE getThingType() {return TYPE_ENEMY;}
|
||||
};
|
||||
|
||||
class CEnemyProjectileThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_ENEMYPROJECTILE;}
|
||||
virtual TYPE getThingType() {return TYPE_ENEMYPROJECTILE;}
|
||||
};
|
||||
|
||||
class CPlatformThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_PLATFORM;}
|
||||
virtual TYPE getThingType() {return TYPE_PLATFORM;}
|
||||
};
|
||||
|
||||
class CTriggerThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_TRIGGER;}
|
||||
virtual void setPositionAndSize(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg)
|
||||
virtual void setTargetBox(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg)
|
||||
virtual TYPE getThingType() {return TYPE_TRIGGER;}
|
||||
virtual void setPositionAndSize(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg)
|
||||
virtual void setTargetBox(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg)
|
||||
protected:
|
||||
int m_boxX1,m_boxY1,m_boxX2,m_boxY2;
|
||||
int m_boxX1,m_boxY1,m_boxX2,m_boxY2;
|
||||
};
|
||||
|
||||
class CHazardThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_HAZARD;}
|
||||
virtual TYPE getThingType() {return TYPE_HAZARD;}
|
||||
};
|
||||
|
||||
class CFXThing : public CThing
|
||||
{
|
||||
public:
|
||||
virtual TYPE getThingType() {return TYPE_FX;}
|
||||
virtual TYPE getThingType() {return TYPE_FX;}
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Functions
|
||||
--------- */
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __THING_THING_H__ */
|
||||
|
||||
/*===========================================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue