From c110d56dc5d00681f547db294784e64d2d059f54 Mon Sep 17 00:00:00 2001 From: Daveo Date: Thu, 10 May 2001 16:16:57 +0000 Subject: [PATCH] --- source/friend/friend.cpp | 29 ++--- source/fx/fxjfish.cpp | 2 +- source/level/level.h | 46 ++++---- source/platform/pbranch.cpp | 62 ++++------ source/platform/pcart.cpp | 39 +++---- source/platform/pdual.cpp | 32 +----- source/platform/pfishhk.cpp | 92 ++++++--------- source/platform/pjellfsh.cpp | 57 ---------- source/platform/pjellfsh.h | 2 +- source/platform/platform.cpp | 29 +---- source/platform/ppendulm.cpp | 111 ++++++++---------- source/platform/pretract.cpp | 37 +++--- source/platform/pseesaw.cpp | 38 ++----- source/thing/thing.cpp | 152 +++++++++++++++++-------- source/thing/thing.h | 211 ++++++++++++++++++----------------- 15 files changed, 403 insertions(+), 536 deletions(-) diff --git a/source/friend/friend.cpp b/source/friend/friend.cpp index c0aa80829..222592e83 100644 --- a/source/friend/friend.cpp +++ b/source/friend/friend.cpp @@ -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 ); } + } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/fx/fxjfish.cpp b/source/fx/fxjfish.cpp index af8f85def..79219af53 100644 --- a/source/fx/fxjfish.cpp +++ b/source/fx/fxjfish.cpp @@ -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= 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 - } + } } } diff --git a/source/platform/pcart.cpp b/source/platform/pcart.cpp index 239504a1c..0eef1b972 100644 --- a/source/platform/pcart.cpp +++ b/source/platform/pcart.cpp @@ -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 - } + } } } diff --git a/source/platform/pdual.cpp b/source/platform/pdual.cpp index f76ecb229..d0f318aac 100644 --- a/source/platform/pdual.cpp +++ b/source/platform/pdual.cpp @@ -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 ); } } +*/ } } } diff --git a/source/platform/pfishhk.cpp b/source/platform/pfishhk.cpp index 6cdaa2e87..79ab11e83 100644 --- a/source/platform/pfishhk.cpp +++ b/source/platform/pfishhk.cpp @@ -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 ); } } + } diff --git a/source/platform/pjellfsh.cpp b/source/platform/pjellfsh.cpp index 808543b18..3213f4442 100644 --- a/source/platform/pjellfsh.cpp +++ b/source/platform/pjellfsh.cpp @@ -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 - } - } - } -} diff --git a/source/platform/pjellfsh.h b/source/platform/pjellfsh.h index 0fe6ba0c2..09c32a609 100644 --- a/source/platform/pjellfsh.h +++ b/source/platform/pjellfsh.h @@ -21,7 +21,7 @@ class CNpcJellyfishPlatform : public CNpcPlatform { public: - virtual void render(); + }; #endif \ No newline at end of file diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 5db2bc267..f7b369ecc 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -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 - } - } } } diff --git a/source/platform/ppendulm.cpp b/source/platform/ppendulm.cpp index 19fbf2294..4683803a8 100644 --- a/source/platform/ppendulm.cpp +++ b/source/platform/ppendulm.cpp @@ -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 ); + } + } +*/ } } } diff --git a/source/platform/pretract.cpp b/source/platform/pretract.cpp index b207cd0a7..a2c81b5a6 100644 --- a/source/platform/pretract.cpp +++ b/source/platform/pretract.cpp @@ -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 - } } } } diff --git a/source/platform/pseesaw.cpp b/source/platform/pseesaw.cpp index 730142ee6..2cc385d81 100644 --- a/source/platform/pseesaw.cpp +++ b/source/platform/pseesaw.cpp @@ -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 - } } } } diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index dcb3b990b..bfb344c25 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -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;ithink(_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;im_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;irender(); - 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.x2ScrBBox.XMax) m_renderFlag=false; + if (collisionRect.y2ScrBBox.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 /*---------------------------------------------------------------------- diff --git a/source/thing/thing.h b/source/thing/thing.h index 0c92f5176..50ead1628 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -26,6 +26,7 @@ #include "game\event.h" #endif +#include /* 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__ */ /*===========================================================================