This commit is contained in:
Daveo 2001-05-10 16:16:57 +00:00
parent 0b65d9d4a7
commit c110d56dc5
15 changed files with 403 additions and 536 deletions

View File

@ -241,29 +241,18 @@ void CNpcFriend::render()
CNpcThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = Pos.vy - offset.vy;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
m_actorGfx->Render(renderPos,m_animNo,(m_frame>>8),m_reversed);
sBBox boundingBox = m_actorGfx->GetBBox();
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -119,7 +119,7 @@ s16 *dH=HeightTable;
_MapOfs.vx+=LX;
_MapOfs.vy+=LY;
if (!Parent->getOnScreenFlag()) return;
if (!Parent->canRender()) return;
MapOfs.vx=_MapOfs.vx+XOfs;
for (int L=0; L<Width; L++)

View File

@ -32,8 +32,8 @@ public:
void think(int _frames);
void setCameraCentre(DVECTOR _pos) {MapPos=_pos;}
static DVECTOR getCameraPos() {return MapPos;}
static DVECTOR getPlayerSpawnPos() {return s_playerSpawnPos;}
static DVECTOR const &getCameraPos() {return MapPos;}
static DVECTOR const &getPlayerSpawnPos() {return s_playerSpawnPos;}
static int getCurrentChapter();
static int getCurrentChapterLevel();

View File

@ -230,23 +230,9 @@ void CNpcBranchPlatform::render()
{
CPlatformThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx ;
renderPos.vy = Pos.vy - offset.vy ;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
rotation.vx = 0;
if ( m_reversed )
@ -306,7 +292,7 @@ void CNpcBranchPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
}
}

View File

@ -150,24 +150,11 @@ void CNpcCartPlatform::render()
{
CPlatformThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx ;
renderPos.vy = Pos.vy - offset.vy ;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = getCollisionAngle();
@ -203,7 +190,7 @@ void CNpcCartPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
}
}

View File

@ -205,34 +205,15 @@ void CNpcDualPlatform::render()
{
int x1,y1,x2,y2;
setOnScreenFlag(false);
if ( m_isActive )
{
CPlatformThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = Pos.vy - offset.vy;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
if (canRender())
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
{
setOnScreenFlag(true);
DVECTOR &renderPos=getRenderPos();
m_modelGfx->Render(renderPos);
// POLY_F4 *F4=GetPrimF4();
// setXYWH(F4,renderPos.vx-32,renderPos.vy-32,64,16);
// setRGB0(F4,127,127,64);
// AddPrimToList(F4,2);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -257,9 +238,7 @@ void CNpcDualPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
/*
x1 = Pos.vx - offset.vx;
x2 = m_lineBase.vx - offset.vx;
@ -339,6 +318,7 @@ void CNpcDualPlatform::render()
DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 );
}
}
*/
}
}
}

View File

@ -77,34 +77,14 @@ void CNpcFishHookPlatform::render()
{
int x1,y1,x2,y2;
setOnScreenFlag(false);
if ( m_isActive )
{
CPlatformThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = Pos.vy - offset.vy;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
DVECTOR &renderPos=getRenderPos();
if (canRender())
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
{
setOnScreenFlag(true);
m_modelGfx->Render(renderPos);
// POLY_F4 *F4=GetPrimF4();
// setXYWH(F4,renderPos.vx-32,renderPos.vy-32,64,16);
// setRGB0(F4,127,127,64);
// AddPrimToList(F4,2);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -129,11 +109,16 @@ void CNpcFishHookPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
x1 = Pos.vx - offset.vx;
x2 = m_lineBase.vx - offset.vx;
}
// draw Line (Literally!!)
if (renderPos.vx>0 && renderPos.vx<512)
{
DVECTOR const &CamPos=CLevel::getCameraPos();
x1 = renderPos.vx;
x2 = m_lineBase.vx - CamPos.vx;
if ( x1 > x2 )
{
@ -142,8 +127,8 @@ void CNpcFishHookPlatform::render()
x2 = tempX;
}
y1 = Pos.vy - offset.vy;
y2 = m_lineBase.vy - offset.vy;
y1 = renderPos.vy;
y2 = m_lineBase.vy - CamPos.vy;
if ( y1 > y2 )
{
@ -161,13 +146,8 @@ void CNpcFishHookPlatform::render()
{
y2 = VidGetScrH();
}
if ( x2 >= 0 && x1 <= VidGetScrW() )
{
if ( y2 >= 0 && y1 <= VidGetScrH() )
{
DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 );
}
}
}
}

View File

@ -30,60 +30,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcJellyfishPlatform::render()
{
if ( m_isActive )
{
CPlatformThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = Pos.vy - offset.vy;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
{
m_modelGfx->Render(renderPos);
// POLY_F4 *F4=GetPrimF4();
// setXYWH(F4,renderPos.vx-32,renderPos.vy-32,64,16);
// setRGB0(F4,127,127,64);
// AddPrimToList(F4,2);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
DVECTOR centre;
int halfLength;
int x1,y1,x2,y2;
centre=getCollisionCentre();
size=getCollisionSize();
halfLength=size.vx>>1;
x1=-halfLength*mcos(getCollisionAngle()&4095)>>12;
y1=-halfLength*msin(getCollisionAngle()&4095)>>12;
x2=+halfLength*mcos(getCollisionAngle()&4095)>>12;
y2=+halfLength*msin(getCollisionAngle()&4095)>>12;
centre.vx-=offset.vx;
centre.vy-=offset.vy;
x1+=centre.vx;
y1+=centre.vy;
x2+=centre.vx;
y2+=centre.vy;
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
}
}

View File

@ -21,7 +21,7 @@
class CNpcJellyfishPlatform : public CNpcPlatform
{
public:
virtual void render();
};
#endif

View File

@ -884,34 +884,17 @@ void CNpcPlatform::processMovement( int _frames )
void CNpcPlatform::render()
{
setOnScreenFlag(false);
if ( m_isActive )
{
CPlatformThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = Pos.vy - offset.vy;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
if (canRender())
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
{
setOnScreenFlag(true);
DVECTOR &renderPos=getRenderPos();
m_modelGfx->Render(renderPos);
// POLY_F4 *F4=GetPrimF4();
// setXYWH(F4,renderPos.vx-32,renderPos.vy-32,64,16);
// setRGB0(F4,127,127,64);
// AddPrimToList(F4,2);
}
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -939,8 +922,6 @@ void CNpcPlatform::render()
#endif
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -126,34 +126,15 @@ void CNpcPendulumPlatform::render()
int x1,y1,x2,y2;
int x1Boundary,y1Boundary,x2Boundary,y2Boundary;
setOnScreenFlag(false);
if ( m_isActive )
{
CPlatformThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = Pos.vy - offset.vy;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
if (canRender())
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
{
setOnScreenFlag(true);
DVECTOR &renderPos=getRenderPos();
m_modelGfx->Render(renderPos);
// POLY_F4 *F4=GetPrimF4();
// setXYWH(F4,renderPos.vx-32,renderPos.vy-32,64,16);
// setRGB0(F4,127,127,64);
// AddPrimToList(F4,2);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -178,9 +159,7 @@ void CNpcPendulumPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
/*
x1 = x1Boundary = Pos.vx - offset.vx;
x2 = x2Boundary = m_lineBase.vx - offset.vx;
@ -226,5 +205,7 @@ void CNpcPendulumPlatform::render()
DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 );
}
}
*/
}
}
}

View File

@ -107,23 +107,13 @@ void CNpcRetractingPlatform::render()
CPlatformThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
CPlatformThing::render();
renderPos.vx = Pos.vx - offset.vx ;
renderPos.vy = Pos.vy - offset.vy ;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = 0;
@ -162,4 +152,3 @@ void CNpcRetractingPlatform::render()
}
}
}
}

View File

@ -117,24 +117,11 @@ void CNpcSeesawPlatform::render()
{
CPlatformThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = Pos.vy - offset.vy;
CRECT collisionRect = getCollisionArea();
collisionRect.x1 -= Pos.vx;
collisionRect.x2 -= Pos.vx;
collisionRect.y1 -= Pos.vy;
collisionRect.y2 -= Pos.vy;
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = getCollisionAngle();
@ -173,4 +160,3 @@ void CNpcSeesawPlatform::render()
}
}
}
}

View File

@ -29,6 +29,8 @@
#include "utils\utils.h"
#endif
#include "level\level.h"
/* Std Lib
------- */
@ -52,9 +54,13 @@
Vars
---- */
CThing *CThingManager::s_thingLists[CThing::MAX_TYPE]={NULL,NULL};
CThing *CThingManager::s_thingLists[CThing::MAX_TYPE];//={NULL,NULL};
CThing *CThingManager::s_CollisionLists[CThing::MAX_TYPE];
int CThingManager::s_initialised=false;
sBBox CThingManager::m_RenderBBox;
sBBox CThingManager::m_ThinkBBox;
/*----------------------------------------------------------------------
Function:
Purpose:
@ -63,13 +69,9 @@ int CThingManager::s_initialised=false;
---------------------------------------------------------------------- */
void CThingManager::init()
{
int i;
ASSERT(!s_initialised);
for(i=0;i<CThing::MAX_TYPE;i++)
{
s_thingLists[i]=NULL;
}
initList(s_thingLists);
initList(s_CollisionLists);
s_initialised=true;
}
@ -97,6 +99,22 @@ void CThingManager::shutdown()
s_initialised=false;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CThingManager::initList(CThing **List)
{
int i;
for(i=0 ;i<CThing::MAX_TYPE; i++)
{
List[i]=NULL;
}
}
/*----------------------------------------------------------------------
Function:
Purpose: Kills every CThing except the player
@ -142,7 +160,7 @@ void CThingManager::thinkAllThings(int _frames)
{
thing->think(_frames);
thing->updateCollisionArea();
thing=thing->m_nextThing;
thing=thing->m_nextListThing;
}
}
@ -168,7 +186,7 @@ void CThingManager::thinkAllThings(int _frames)
thing1->collidedWith(thing2);
}
thing1=thing1->m_nextThing;
thing1=thing1->m_nextListThing;
}
// Player -> Pickup collision
@ -181,7 +199,7 @@ void CThingManager::thinkAllThings(int _frames)
{
thing1->collidedWith(thing2);
}
thing1=thing1->m_nextThing;
thing1=thing1->m_nextListThing;
}
// Player -> Enemy collision
@ -194,7 +212,7 @@ void CThingManager::thinkAllThings(int _frames)
{
thing1->collidedWith(thing2);
}
thing1=thing1->m_nextThing;
thing1=thing1->m_nextListThing;
}
// Player -> Friend collision
@ -207,7 +225,7 @@ void CThingManager::thinkAllThings(int _frames)
{
thing1->collidedWith(thing2);
}
thing1=thing1->m_nextThing;
thing1=thing1->m_nextListThing;
}
// Player -> Hazard collision
@ -220,7 +238,7 @@ void CThingManager::thinkAllThings(int _frames)
{
thing1->collidedWith(thing2);
}
thing1=thing1->m_nextThing;
thing1=thing1->m_nextListThing;
}
// Player -> Enemy projectile collision
@ -233,7 +251,7 @@ void CThingManager::thinkAllThings(int _frames)
{
thing1->collidedWith(thing2);
}
thing1=thing1->m_nextThing;
thing1=thing1->m_nextListThing;
}
// Player -> Trigger collision
@ -246,7 +264,7 @@ void CThingManager::thinkAllThings(int _frames)
{
thing1->collidedWith(thing2);
}
thing1=thing1->m_nextThing;
thing1=thing1->m_nextListThing;
}
// Enemy -> Player projectile collision
@ -262,9 +280,9 @@ void CThingManager::thinkAllThings(int _frames)
{
thing1->collidedWith(thing2);
}
thing2=thing2->m_nextThing;
thing2=thing2->m_nextListThing;
}
thing1=thing1->m_nextThing;
thing1=thing1->m_nextListThing;
}
// Enemy -> Enemy collision
@ -286,10 +304,10 @@ void CThingManager::thinkAllThings(int _frames)
}
}
thing2 = thing2->m_nextThing;
thing2 = thing2->m_nextListThing;
}
thing1 = thing1->m_nextThing;
thing1 = thing1->m_nextListThing;
}
// Hazard -> Platform collision
@ -311,10 +329,10 @@ void CThingManager::thinkAllThings(int _frames)
}
}
thing2 = thing2->m_nextThing;
thing2 = thing2->m_nextListThing;
}
thing1 = thing1->m_nextThing;
thing1 = thing1->m_nextListThing;
}
for(i=0;i<CThing::MAX_TYPE;i++)
@ -323,7 +341,7 @@ void CThingManager::thinkAllThings(int _frames)
CThing *nextThing = thing;
while(thing)
{
nextThing=thing->m_nextThing;
nextThing=thing->m_nextListThing;
if ( thing->isSetToShutdown() )
{
@ -342,8 +360,30 @@ void CThingManager::thinkAllThings(int _frames)
Params:
Returns:
---------------------------------------------------------------------- */
static int s_RenderBBoxX0=0;
static int s_RenderBBoxX1=512;
static int s_RenderBBoxY0=0;
static int s_RenderBBoxY1=256;
static int s_ThinkBBoxX0=0-256;
static int s_ThinkBBoxX1=512+526;
static int s_ThinkBBoxY0=0+128;
static int s_ThinkBBoxY1=256+128;
void CThingManager::renderAllThings()
{
// Setup Screen BBox's
DVECTOR const &CamPos=CLevel::getCameraPos();
m_RenderBBox.XMin=s_RenderBBoxX0+CamPos.vx;
m_RenderBBox.XMax=s_RenderBBoxX1+CamPos.vx;
m_RenderBBox.YMin=s_RenderBBoxY0+CamPos.vy;
m_RenderBBox.YMax=s_RenderBBoxY1+CamPos.vy;
m_ThinkBBox.XMin=s_ThinkBBoxX0+CamPos.vx;
m_ThinkBBox.XMax=s_ThinkBBoxX1+CamPos.vx;
m_ThinkBBox.YMin=s_ThinkBBoxY0+CamPos.vy;
m_ThinkBBox.YMax=s_ThinkBBoxY1+CamPos.vy;
int i;
CThing *thing;
@ -353,7 +393,7 @@ void CThingManager::renderAllThings()
while(thing)
{
thing->render();
thing=thing->m_nextThing;
thing=thing->m_nextListThing;
}
}
}
@ -375,7 +415,7 @@ void CThingManager::processEventAllThings(GAME_EVENT _event,CThing *_sourceThin
while(thing)
{
thing->processEvent(_event,_sourceThing);
thing=thing->m_nextThing;
thing=thing->m_nextListThing;
}
}
}
@ -403,7 +443,7 @@ CThing *CThingManager::checkCollisionAreaAgainstThings(CRECT *_area,int _type,i
if(_continue)
{
ASSERT(thing);
thing=thing->m_nextThing;
thing=thing->m_nextListThing;
}
else
{
@ -416,7 +456,7 @@ CThing *CThingManager::checkCollisionAreaAgainstThings(CRECT *_area,int _type,i
{
return thing;
}
thing=thing->m_nextThing;
thing=thing->m_nextListThing;
}
return NULL;
@ -430,7 +470,7 @@ CThing *CThingManager::checkCollisionAreaAgainstThings(CRECT *_area,int _type,i
---------------------------------------------------------------------- */
void CThingManager::addToThingList(CThing *_this)
{
_this->m_nextThing=s_thingLists[_this->getThingType()];
_this->m_nextListThing=s_thingLists[_this->getThingType()];
s_thingLists[_this->getThingType()]=_this;
}
@ -449,16 +489,16 @@ void CThingManager::removeFromThingList(CThing *_this)
while(thing!=_this)
{
prevThing=thing;
thing=thing->m_nextThing;
thing=thing->m_nextListThing;
ASSERT(thing); // Not in the list!?!?
}
if(prevThing)
{
prevThing->m_nextThing=_this->m_nextThing;
prevThing->m_nextListThing=_this->m_nextListThing;
}
else
{
s_thingLists[_this->getThingType()]=_this->m_nextThing;
s_thingLists[_this->getThingType()]=_this->m_nextListThing;
}
}
@ -524,24 +564,48 @@ void CThing::think(int _frames)
Params:
Returns:
---------------------------------------------------------------------- */
#if !defined(__USER_CDBUILD__)
#include "gfx\prim.h"
#include "level\level.h"
#if defined (__USER_paul__) || defined (__USER_charles__)
#define SHOW_BBOX 1
int showthings=true;
#else
#endif
#if defined (__USER_daveo__)
#define SHOW_BBOX 1
int showthings=false;
#endif
void CThing::render()
{
// Check Is Onscreen
CRECT const &collisionRect = getCollisionArea();
sBBox &ScrBBox=CThingManager::getRenderBBox();
DVECTOR const &CamPos=CLevel::getCameraPos();
m_RenderPos.vx = Pos.vx - CamPos.vx;
m_RenderPos.vy = Pos.vy - CamPos.vy;
// Will speed this up
m_renderFlag=true;
if (collisionRect.x2<ScrBBox.XMin || collisionRect.x1>ScrBBox.XMax) m_renderFlag=false;
if (collisionRect.y2<ScrBBox.YMin || collisionRect.y1>ScrBBox.YMax) m_renderFlag=false;
/***/
#ifdef SHOW_BBOX
if(showthings) ShowBBox();
#endif
}
/****************************************************************************************/
#ifdef SHOW_BBOX
#include "gfx\prim.h"
void CThing::ShowBBox()
{
if(showthings)
{
DVECTOR ofs;
DVECTOR const &ofs=CLevel::getCameraPos();
CRECT area;
ofs=CLevel::getCameraPos();
area=getCollisionArea();
area.x1-=ofs.vx;
area.y1-=ofs.vy;
@ -636,10 +700,6 @@ void CThing::render()
*/
}
}
#else
void CThing::render()
{
}
#endif
/*----------------------------------------------------------------------

View File

@ -26,6 +26,7 @@
#include "game\event.h"
#endif
#include <dstructs.h>
/* Std Lib
------- */
@ -39,14 +40,14 @@
-------------------- */
// Collision rectangle definition
typedef struct
struct CRECT
{
int x1,y1,x2,y2;
}
CRECT;
};
/*----------------------------------------------------------------------*/
// Thing manager class
class CThing;
class CThingManager
{
public:
@ -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 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 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,15 +102,13 @@ public:
TYPE_FX,
MAX_TYPE,
}
TYPE;
};
// TYPE;
CThing() {;}
virtual ~CThing() {;}
virtual TYPE getThingType()=0;
virtual void init();
virtual void shutdown();
virtual void think(int _frames);
@ -114,19 +124,16 @@ public:
int getNumChildren();
DVECTOR getPos() {return Pos;}
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
// Parent Child Linkage
CThing *Parent,*Next;
// Count
int m_numChildren;
@ -134,21 +141,19 @@ protected:
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;}
void ShowBBox();
DVECTOR const &getCollisionCentre() {return m_collisionCentre;}
DVECTOR const &getCollisionCentreOffset() {return m_collisionCentreOffset;}
int getCollisionRadius() {return m_collisionRadius;}
CRECT getCollisionArea() {return m_collisionArea;}
CRECT const &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;}
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);
@ -160,9 +165,9 @@ public:
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);
@ -177,46 +182,55 @@ private:
DVECTOR m_collisionCentre;
s16 m_collisionAngle; // pkg - move to CNpcPlatform?
DVECTOR m_newCollidedPos; // pkg - to be removed?
bool m_OnScreenFlag;
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;}
};
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:
@ -226,28 +240,19 @@ public:
protected:
int m_boxX1,m_boxY1,m_boxX2,m_boxY2;
};
class CHazardThing : public CThing
{
public:
virtual TYPE getThingType() {return TYPE_HAZARD;}
};
class CFXThing : public CThing
{
public:
virtual TYPE getThingType() {return TYPE_FX;}
};
/*----------------------------------------------------------------------
Globals
------- */
/*----------------------------------------------------------------------
Functions
--------- */
/*---------------------------------------------------------------------- */
#endif /* __THING_THING_H__ */
/*===========================================================================