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

@ -240,30 +240,19 @@ void CNpcFriend::render()
{
CNpcThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
// 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 (canRender())
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
{
m_actorGfx->Render(renderPos,m_animNo,(m_frame>>8),m_reversed);
DVECTOR &renderPos=getRenderPos();
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 );
}
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

@ -26,36 +26,36 @@ class CLevel
public:
CLevel();
// Scene Handlers
void init(int LevelNo);
void shutdown();
void render();
void think(int _frames);
void init(int LevelNo);
void shutdown();
void render();
void think(int _frames);
void setCameraCentre(DVECTOR _pos) {MapPos=_pos;}
static DVECTOR getCameraPos() {return MapPos;}
static DVECTOR getPlayerSpawnPos() {return s_playerSpawnPos;}
void setCameraCentre(DVECTOR _pos) {MapPos=_pos;}
static DVECTOR const &getCameraPos() {return MapPos;}
static DVECTOR const &getPlayerSpawnPos() {return s_playerSpawnPos;}
static int getCurrentChapter();
static int getCurrentChapterLevel();
static int getCurrentChapter();
static int getCurrentChapterLevel();
int getActorCount() {return ActorCount;}
sThingActor **getActorList() {return ActorList;}
int getPlatformCount() {return PlatformCount;}
sThingPlatform **getPlatformList() {return PlatformList;}
int getHazardCount() {return HazardCount;}
sThingHazard **getHazardList() {return HazardList;}
int getActorCount() {return ActorCount;}
sThingActor **getActorList() {return ActorList;}
int getPlatformCount() {return PlatformCount;}
sThingPlatform **getPlatformList() {return PlatformList;}
int getHazardCount() {return HazardCount;}
sThingHazard **getHazardList() {return HazardList;}
CLayerCollision *getCollisionLayer() {return CollisionLayer;}
DVECTOR getMapSize();
CLayerCollision *getCollisionLayer() {return CollisionLayer;}
DVECTOR getMapSize();
bool GetNextLevel(int &Lvl);
bool GetNextLevel(int &Lvl);
void respawnLevel();
void respawnLevel();
static u8 getIsBossRespawn() {return m_isBossRespawn;}
static s32 getBossHealth() {return m_bossHealth;}
static void setIsBossRespawn( u8 newIsBossRespawn ) {m_isBossRespawn=newIsBossRespawn;}
static void setBossHealth( s32 newBossHealth ) {m_bossHealth=newBossHealth;}
static u8 getIsBossRespawn() {return m_isBossRespawn;}
static s32 getBossHealth() {return m_bossHealth;}
static void setIsBossRespawn( u8 newIsBossRespawn ) {m_isBossRespawn=newIsBossRespawn;}
static void setBossHealth( s32 newBossHealth ) {m_bossHealth=newBossHealth;}
private:

View File

@ -230,47 +230,33 @@ 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 (canRender())
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
rotation.vx = 0;
if ( m_reversed )
{
SVECTOR rotation;
rotation.vx = 0;
if ( m_reversed )
{
rotation.vy = 0;
rotation.vz = getCollisionAngle();
renderPos.vx-= BX;
renderPos.vy+= BY;
}
else
{
rotation.vy = 0;
rotation.vz = getCollisionAngle();
renderPos.vx+= BX;
renderPos.vy+= BY;
}
rotation.vy = 0;
rotation.vz = getCollisionAngle();
renderPos.vx-= BX;
renderPos.vy+= BY;
}
else
{
rotation.vy = 0;
rotation.vz = getCollisionAngle();
renderPos.vx+= BX;
renderPos.vy+= BY;
}
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = ONE;
m_modelGfx->Render(renderPos,&rotation,&scale);
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = ONE;
m_modelGfx->Render(renderPos,&rotation,&scale);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
DVECTOR centre;
@ -306,7 +292,7 @@ void CNpcBranchPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
}
}

View File

@ -150,34 +150,21 @@ 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 (canRender())
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
{
SVECTOR rotation;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = getCollisionAngle();
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = ONE;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = getCollisionAngle();
m_modelGfx->Render(renderPos,&rotation,&scale);
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = ONE;
m_modelGfx->Render(renderPos,&rotation,&scale);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -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);
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);
DVECTOR &renderPos=getRenderPos();
m_modelGfx->Render(renderPos);
#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);
m_modelGfx->Render(renderPos);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -129,45 +109,45 @@ void CNpcFishHookPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
x1 = Pos.vx - offset.vx;
x2 = m_lineBase.vx - offset.vx;
if ( x1 > x2 )
// draw Line (Literally!!)
if (renderPos.vx>0 && renderPos.vx<512)
{
int tempX = x1;
x1 = x2;
x2 = tempX;
}
y1 = Pos.vy - offset.vy;
y2 = m_lineBase.vy - offset.vy;
if ( y1 > y2 )
{
int tempY = y1;
y1 = y2;
y2 = tempY;
}
if ( y1 < 0 )
{
y1 = 0;
}
DVECTOR const &CamPos=CLevel::getCameraPos();
if ( y2 > VidGetScrH() )
{
y2 = VidGetScrH();
}
x1 = renderPos.vx;
x2 = m_lineBase.vx - CamPos.vx;
if ( x2 >= 0 && x1 <= VidGetScrW() )
{
if ( y2 >= 0 && y1 <= VidGetScrH() )
if ( x1 > x2 )
{
DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 );
int tempX = x1;
x1 = x2;
x2 = tempX;
}
y1 = renderPos.vy;
y2 = m_lineBase.vy - CamPos.vy;
if ( y1 > y2 )
{
int tempY = y1;
y1 = y2;
y2 = tempY;
}
if ( y1 < 0 )
{
y1 = 0;
}
if ( y2 > VidGetScrH() )
{
y2 = 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);
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);
DVECTOR &renderPos=getRenderPos();
m_modelGfx->Render(renderPos);
}
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -937,8 +920,6 @@ void CNpcPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#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);
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);
DVECTOR &renderPos=getRenderPos();
m_modelGfx->Render(renderPos);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -178,53 +159,53 @@ 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;
x1 = x1Boundary = Pos.vx - offset.vx;
x2 = x2Boundary = m_lineBase.vx - offset.vx;
y1 = y1Boundary = Pos.vy - offset.vy;
y2 = y2Boundary = m_lineBase.vy - offset.vy;
y1 = y1Boundary = Pos.vy - offset.vy;
y2 = y2Boundary = m_lineBase.vy - offset.vy;
int angle = ratan2( x1 - x2, y1 - y2 );
int angle = ratan2( x1 - x2, y1 - y2 );
if ( y2 < 0 )
{
int yDiff = -y2;
y2 = y2Boundary = 0;
int hyp = ( yDiff << 12 ) / rcos( angle );
x2 += ( hyp * rsin( angle ) ) >> 12;
}
if ( y1 > VidGetScrH() )
{
int yDiff = y1 - VidGetScrH();
y1 = y1Boundary = VidGetScrH();
int hyp = ( yDiff << 12 ) / rcos( angle );
x1 -= ( hyp * rsin( angle ) ) >> 12;
}
if ( x1Boundary > x2Boundary )
{
int tempX = x1Boundary;
x1Boundary = x2Boundary;
x2Boundary = tempX;
}
if ( y1Boundary > y2Boundary )
{
int tempY = y1Boundary;
y1Boundary = y2Boundary;
y2Boundary = tempY;
}
if ( x2Boundary >= 0 && x1Boundary <= VidGetScrW() )
{
if ( y2Boundary >= 0 && y1Boundary <= VidGetScrH() )
if ( y2 < 0 )
{
DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 );
int yDiff = -y2;
y2 = y2Boundary = 0;
int hyp = ( yDiff << 12 ) / rcos( angle );
x2 += ( hyp * rsin( angle ) ) >> 12;
}
if ( y1 > VidGetScrH() )
{
int yDiff = y1 - VidGetScrH();
y1 = y1Boundary = VidGetScrH();
int hyp = ( yDiff << 12 ) / rcos( angle );
x1 -= ( hyp * rsin( angle ) ) >> 12;
}
if ( x1Boundary > x2Boundary )
{
int tempX = x1Boundary;
x1Boundary = x2Boundary;
x2Boundary = tempX;
}
if ( y1Boundary > y2Boundary )
{
int tempY = y1Boundary;
y1Boundary = y2Boundary;
y2Boundary = tempY;
}
if ( x2Boundary >= 0 && x1Boundary <= VidGetScrW() )
{
if ( y2Boundary >= 0 && y1Boundary <= VidGetScrH() )
{
DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 );
}
}
*/
}
}
}

View File

@ -107,33 +107,23 @@ 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 (canRender())
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
{
SVECTOR rotation;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = 0;
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = m_extension;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = 0;
m_modelGfx->Render(renderPos,&rotation,&scale);
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = m_extension;
m_modelGfx->Render(renderPos,&rotation,&scale);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -159,7 +149,6 @@ void CNpcRetractingPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
}
}

View File

@ -117,34 +117,21 @@ 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 (canRender())
{
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
{
SVECTOR rotation;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = getCollisionAngle();
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = ONE;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = getCollisionAngle();
m_modelGfx->Render(renderPos,&rotation,&scale);
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = ONE;
m_modelGfx->Render(renderPos,&rotation,&scale);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
@ -170,7 +157,6 @@ void CNpcSeesawPlatform::render()
DrawLine(x1,y1,x2,y2,0,255,0,0);
#endif
}
}
}
}

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,10 +360,32 @@ 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()
{
int i;
CThing *thing;
// 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;
for(i=0;i<CThing::MAX_TYPE;i++)
{
@ -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;
#endif
#if defined (__USER_paul__) || defined (__USER_charles__)
int showthings=true;
#else
int showthings=false;
#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,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__ */
/*===========================================================================