2001-02-26 21:27:20 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
thing.h
|
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
#ifndef __THING_THING_H__
|
|
|
|
#define __THING_THING_H__
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#ifndef _GLOBAL_HEADER_
|
|
|
|
#include "system\global.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GAME_EVENT_H__
|
|
|
|
#include "game\event.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
2001-04-06 23:25:18 +02:00
|
|
|
// Collision rectangle definition
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int x1,y1,x2,y2;
|
|
|
|
}
|
|
|
|
CRECT;
|
|
|
|
|
|
|
|
|
2001-02-26 21:27:20 +01:00
|
|
|
// Thing manager class
|
|
|
|
class CThingManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void init();
|
|
|
|
static void shutdown();
|
|
|
|
|
|
|
|
static void thinkAllThings(int _frames);
|
|
|
|
static void renderAllThings();
|
|
|
|
static void processEventAllThings(GAME_EVENT _event,class CThing *_sourceThing);
|
|
|
|
|
2001-04-06 23:25:18 +02:00
|
|
|
static CThing* checkCollisionAreaAgainstThings(CRECT *_area,int _type,int _continue);
|
|
|
|
|
2001-02-26 21:27:20 +01:00
|
|
|
protected:
|
|
|
|
static void addToThingList(class CThing *_this);
|
|
|
|
static void removeFromThingList(CThing *_this);
|
|
|
|
friend class CThing;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static class CThing *s_thingLists[];
|
2001-02-26 21:42:25 +01:00
|
|
|
static int s_initialised;
|
2001-02-26 21:27:20 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Base thing class
|
|
|
|
class CThing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TYPE_PICKUP,
|
2001-03-08 21:12:47 +01:00
|
|
|
TYPE_PLATFORM,
|
2001-02-26 21:27:20 +01:00
|
|
|
TYPE_PLAYER,
|
2001-02-27 17:59:50 +01:00
|
|
|
TYPE_PLAYERPROJECTILE,
|
|
|
|
TYPE_NPC,
|
2001-02-26 21:27:20 +01:00
|
|
|
TYPE_ENEMY,
|
2001-02-27 17:59:50 +01:00
|
|
|
TYPE_ENEMYPROJECTILE,
|
|
|
|
TYPE_TRIGGER,
|
2001-02-26 21:27:20 +01:00
|
|
|
|
|
|
|
MAX_TYPE,
|
|
|
|
}
|
|
|
|
TYPE;
|
|
|
|
|
|
|
|
CThing() {;}
|
|
|
|
virtual ~CThing() {;}
|
|
|
|
|
2001-02-27 17:59:50 +01:00
|
|
|
virtual TYPE getThingType()=0;
|
2001-02-26 21:27:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
virtual void init();
|
|
|
|
virtual void shutdown();
|
|
|
|
virtual void think(int _frames);
|
|
|
|
virtual void render();
|
|
|
|
|
|
|
|
// Linkage
|
|
|
|
void addChild(CThing *Child);
|
|
|
|
void removeChild(CThing *Child);
|
|
|
|
void removeAllChild();
|
2001-03-09 22:03:52 +01:00
|
|
|
bool hasChild(CThing *Child);
|
2001-02-26 21:27:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
DVECTOR getPos() {return Pos;}
|
2001-03-26 18:44:45 +02:00
|
|
|
void setPos(DVECTOR newPos) {Pos=newPos;}
|
2001-04-01 23:40:52 +02:00
|
|
|
DVECTOR getPosDelta() {return PosDelta;}
|
2001-04-10 22:08:23 +02:00
|
|
|
//virtual void shove(DVECTOR move);
|
2001-03-08 21:12:47 +01:00
|
|
|
CThing *getNext() {return Next;}
|
2001-02-26 21:27:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
virtual void processEvent(GAME_EVENT _event,CThing *_sourceThing);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
|
|
// Linkage
|
|
|
|
CThing *Parent,*Next;
|
|
|
|
|
|
|
|
// Pos
|
2001-04-01 23:40:52 +02:00
|
|
|
DVECTOR Pos, PosLast, PosDelta;
|
2001-02-26 21:27:20 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
class CThing *m_nextThing;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -- Collision --
|
|
|
|
public:
|
2001-04-06 22:53:48 +02:00
|
|
|
DVECTOR getCollisionCentre() {return m_collisionCentre;}
|
|
|
|
int getCollisionRadius() {return m_collisionRadius;}
|
|
|
|
CRECT getCollisionArea() {return m_collisionArea;}
|
|
|
|
s16 getCollisionAngle() {return m_collisionAngle;}
|
|
|
|
bool getCentreCollision() {return m_centreCollision;}
|
|
|
|
DVECTOR getNewCollidedPos() {return m_newCollidedPos;}
|
|
|
|
DVECTOR getCollisionSize() {return m_collisionSize;}
|
|
|
|
|
2001-02-27 17:59:50 +01:00
|
|
|
virtual int canCollide() {return true;}
|
2001-04-01 23:40:52 +02:00
|
|
|
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
|
2001-04-06 23:25:18 +02:00
|
|
|
int checkCollisionAgainstArea(CRECT *_rect);
|
2001-02-26 21:27:20 +01:00
|
|
|
void updateCollisionArea();
|
2001-02-27 17:59:50 +01:00
|
|
|
virtual void collidedWith(CThing *_thisThing) {;}
|
2001-03-31 00:43:35 +02:00
|
|
|
virtual void setHasPlatformCollided( bool newVal ) {;}
|
|
|
|
virtual bool getHasPlatformCollided() {return false;}
|
2001-04-06 22:53:48 +02:00
|
|
|
virtual s32 getNewYPos( CThing *_thisThing );
|
2001-03-09 22:03:52 +01:00
|
|
|
void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;}
|
2001-04-06 22:53:48 +02:00
|
|
|
void setCentreCollision(bool newCentreCollision) {m_centreCollision = newCentreCollision;}
|
2001-04-06 23:25:18 +02:00
|
|
|
|
|
|
|
|
2001-02-26 21:27:20 +01:00
|
|
|
protected:
|
|
|
|
void setCollisionSize(int _w,int _h);
|
|
|
|
void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;}
|
|
|
|
void setCollisionCentreOffset(DVECTOR xy) {m_collisionCentreOffset=xy;}
|
2001-03-08 22:04:11 +01:00
|
|
|
void setCollisionAngle(int newAngle) {m_collisionAngle = newAngle;}
|
2001-02-26 21:27:20 +01:00
|
|
|
private:
|
|
|
|
DVECTOR m_collisionSize;
|
|
|
|
DVECTOR m_collisionCentreOffset;
|
|
|
|
int m_collisionRadius;
|
|
|
|
CRECT m_collisionArea;
|
|
|
|
DVECTOR m_collisionCentre;
|
2001-03-08 21:12:47 +01:00
|
|
|
s16 m_collisionAngle;
|
|
|
|
bool m_centreCollision;
|
|
|
|
DVECTOR m_newCollidedPos;
|
2001-02-26 21:27:20 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2001-02-27 17:59:50 +01:00
|
|
|
/* These are the individual base classes for each of the seperate thing types */
|
|
|
|
class CPickupThing : public CThing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual TYPE getThingType() {return TYPE_PICKUP;}
|
|
|
|
};
|
|
|
|
class CPlayerThing : public CThing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual TYPE getThingType() {return TYPE_PLAYER;}
|
|
|
|
};
|
|
|
|
class CPlayerProjectileThing : public CThing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual TYPE getThingType() {return TYPE_PLAYERPROJECTILE;}
|
|
|
|
};
|
|
|
|
class CNpcThing : public CThing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual TYPE getThingType() {return TYPE_NPC;}
|
|
|
|
};
|
|
|
|
class CEnemyThing : public CThing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual TYPE getThingType() {return TYPE_ENEMY;}
|
|
|
|
};
|
|
|
|
class CEnemyProjectileThing : public CThing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual TYPE getThingType() {return TYPE_ENEMYPROJECTILE;}
|
|
|
|
};
|
|
|
|
class CPlatformThing : public CThing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual TYPE getThingType() {return TYPE_PLATFORM;}
|
|
|
|
};
|
|
|
|
class CTriggerThing : public CThing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual TYPE getThingType() {return TYPE_TRIGGER;}
|
|
|
|
};
|
|
|
|
|
2001-02-26 21:27:20 +01:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Globals
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Functions
|
|
|
|
--------- */
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#endif /* __THING_THING_H__ */
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
|
|
end */
|