From 37be2627824b96070a6700866a3b38e59f6d1039 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 14 May 2001 21:08:03 +0000 Subject: [PATCH] --- source/enemy/nanemone.cpp | 30 ++++--------- source/enemy/nbuttfly.cpp | 86 ++++++++++++++---------------------- source/enemy/nmjback.cpp | 30 ++++--------- source/enemy/nmjfish.cpp | 30 ++++--------- source/enemy/npc.cpp | 30 ++++--------- source/enemy/nprojjf.cpp | 86 ++++++++++++++---------------------- source/enemy/nsdart.cpp | 57 +++++++----------------- source/enemy/nsj2back.cpp | 86 ++++++++++++++---------------------- source/enemy/nsjback.cpp | 86 ++++++++++++++---------------------- source/enemy/nsjfish.cpp | 86 ++++++++++++++---------------------- source/enemy/nworm.cpp | 60 +++++++------------------ source/hazard/hazard.cpp | 23 ++-------- source/hazard/hbbarrel.cpp | 38 +++++----------- source/hazard/hboat.cpp | 47 +++++++------------- source/hazard/hbwheel.cpp | 38 +++++----------- source/hazard/hcsaw.cpp | 38 +++++----------- source/hazard/hdbarrel.cpp | 38 +++++----------- source/hazard/hfalling.cpp | 43 +++++++++++++++++- source/hazard/hfalling.h | 1 + source/hazard/hfan.cpp | 38 +++++----------- source/hazard/hmower.cpp | 38 +++++----------- source/platform/ppendulm.cpp | 12 +++++ source/platform/ppendulm.h | 1 + source/platform/psbarrel.cpp | 79 ++++++++++++++------------------- 24 files changed, 404 insertions(+), 697 deletions(-) diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp index c23dd382b..14b7a446e 100644 --- a/source/enemy/nanemone.cpp +++ b/source/enemy/nanemone.cpp @@ -566,30 +566,16 @@ void CNpcAnemone2Enemy::render() { CEnemyThing::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() ) - { - SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); - m_actorGfx->RotateScale( SprFrame, renderPos, m_drawRotation, m_scaleX, m_scaleY ); + 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 ); - } + SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); + m_actorGfx->RotateScale( SprFrame, renderPos, m_drawRotation, m_scaleX, m_scaleY ); + + 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/enemy/nbuttfly.cpp b/source/enemy/nbuttfly.cpp index 8e92d222c..f2a6d0ac0 100644 --- a/source/enemy/nbuttfly.cpp +++ b/source/enemy/nbuttfly.cpp @@ -47,67 +47,45 @@ void CNpcButterflyBackgroundEnemy::render() { CEnemyThing::render(); - // Render - DVECTOR renderPos; - DVECTOR origRenderPos; - DVECTOR offset = CLevel::getCameraPos(); - int spriteWidth = m_spriteBank->getFrameWidth( m_frame >> 8 ); - int spriteHeight = m_spriteBank->getFrameHeight( m_frame >> 8 ); - - renderPos.vx = Pos.vx - offset.vx; - origRenderPos.vx = renderPos.vx; - renderPos.vx += m_drawOffset.vx; - - renderPos.vy = Pos.vy - offset.vy; - origRenderPos.vy = renderPos.vy; - renderPos.vy += m_drawOffset.vy - ( spriteHeight >> 1 ); - - 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() ) - { - SprFrame = m_spriteBank->printFT4(FRM_BUTTERFLY_FLAP01 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,!m_reversed,0,15); - setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) + DVECTOR &renderPos=getRenderPos(); - // get xmax, xmin, ymax, ymin + SprFrame = m_spriteBank->printFT4(FRM_BUTTERFLY_FLAP01 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,!m_reversed,0,15); + setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) - s32 XMax; - s32 XMin; + // get xmax, xmin, ymax, ymin - s32 YMax; - s32 YMin; + s32 XMax; + s32 XMin; - XMin=SprFrame->x0; - if (XMin>SprFrame->x1) XMin=SprFrame->x1; - if (XMin>SprFrame->x2) XMin=SprFrame->x2; - if (XMin>SprFrame->x3) XMin=SprFrame->x3; - XMax=SprFrame->x0; - if (XMaxx1) XMax=SprFrame->x1; - if (XMaxx2) XMax=SprFrame->x2; - if (XMaxx3) XMax=SprFrame->x3; - YMin=SprFrame->y0; - if (YMin>SprFrame->y1) YMin=SprFrame->y1; - if (YMin>SprFrame->y2) YMin=SprFrame->y2; - if (YMin>SprFrame->y3) YMin=SprFrame->y3; - YMax=SprFrame->y0; - if (YMaxy1) YMax=SprFrame->y1; - if (YMaxy2) YMax=SprFrame->y2; - if (YMaxy3) YMax=SprFrame->y3; + s32 YMax; + s32 YMin; - XMax -= origRenderPos.vx; - XMin -= origRenderPos.vx; - YMax -= origRenderPos.vy; - YMin -= origRenderPos.vy; + XMin=SprFrame->x0; + if (XMin>SprFrame->x1) XMin=SprFrame->x1; + if (XMin>SprFrame->x2) XMin=SprFrame->x2; + if (XMin>SprFrame->x3) XMin=SprFrame->x3; + XMax=SprFrame->x0; + if (XMaxx1) XMax=SprFrame->x1; + if (XMaxx2) XMax=SprFrame->x2; + if (XMaxx3) XMax=SprFrame->x3; + YMin=SprFrame->y0; + if (YMin>SprFrame->y1) YMin=SprFrame->y1; + if (YMin>SprFrame->y2) YMin=SprFrame->y2; + if (YMin>SprFrame->y3) YMin=SprFrame->y3; + YMax=SprFrame->y0; + if (YMaxy1) YMax=SprFrame->y1; + if (YMaxy2) YMax=SprFrame->y2; + if (YMaxy3) YMax=SprFrame->y3; - setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); - setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); - } + XMax -= renderPos.vx; + XMin -= renderPos.vx; + YMax -= renderPos.vy; + YMin -= renderPos.vy; + + setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); + setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); } } } \ No newline at end of file diff --git a/source/enemy/nmjback.cpp b/source/enemy/nmjback.cpp index bf6d89cf3..636042f5a 100644 --- a/source/enemy/nmjback.cpp +++ b/source/enemy/nmjback.cpp @@ -50,30 +50,16 @@ void CNpcMotherJellyfishBackground::render() { CEnemyThing::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() ) - { - SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),false); - m_actorGfx->RotateScale( SprFrame, renderPos, 0, 8192, 8192 ); + 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 ); - } + SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),false); + m_actorGfx->RotateScale( SprFrame, renderPos, 0, 8192, 8192 ); + + 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/enemy/nmjfish.cpp b/source/enemy/nmjfish.cpp index 61c652b70..1582f7b14 100644 --- a/source/enemy/nmjfish.cpp +++ b/source/enemy/nmjfish.cpp @@ -366,30 +366,16 @@ void CNpcMotherJellyfishEnemy::render() { CEnemyThing::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() ) - { - SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),false); - m_actorGfx->RotateScale( SprFrame, renderPos, 0, 8192, 8192 ); + 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 ); - } + SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),false); + m_actorGfx->RotateScale( SprFrame, renderPos, 0, 8192, 8192 ); + + 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/enemy/npc.cpp b/source/enemy/npc.cpp index 5e491b1ad..d61a0f581 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -1343,30 +1343,16 @@ void CNpcEnemy::render() { CEnemyThing::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() ) - { - SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); - m_actorGfx->RotateScale( SprFrame, renderPos, m_drawRotation, 4096, 4096 ); + 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 ); - } + SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); + m_actorGfx->RotateScale( SprFrame, renderPos, m_drawRotation, 4096, 4096 ); + + 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/enemy/nprojjf.cpp b/source/enemy/nprojjf.cpp index 36929ff82..047f4958c 100644 --- a/source/enemy/nprojjf.cpp +++ b/source/enemy/nprojjf.cpp @@ -150,67 +150,45 @@ void CNpcSmallJellyfishProjectileEnemy::render() { CEnemyThing::render(); - // Render - DVECTOR renderPos; - DVECTOR origRenderPos; - DVECTOR offset = CLevel::getCameraPos(); - int spriteWidth = m_spriteBank->getFrameWidth( m_frame >> 8 ); - int spriteHeight = m_spriteBank->getFrameHeight( m_frame >> 8 ); - - renderPos.vx = Pos.vx - offset.vx; - origRenderPos.vx = renderPos.vx; - renderPos.vx += m_drawOffset.vx; - - renderPos.vy = Pos.vy - offset.vy; - origRenderPos.vy = renderPos.vy; - renderPos.vy += m_drawOffset.vy - ( spriteHeight >> 1 ); - - 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() ) - { - SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10); - setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) + DVECTOR &renderPos=getRenderPos(); - // get xmax, xmin, ymax, ymin + SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10); + setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) - s32 XMax; - s32 XMin; + // get xmax, xmin, ymax, ymin - s32 YMax; - s32 YMin; + s32 XMax; + s32 XMin; - XMin=SprFrame->x0; - if (XMin>SprFrame->x1) XMin=SprFrame->x1; - if (XMin>SprFrame->x2) XMin=SprFrame->x2; - if (XMin>SprFrame->x3) XMin=SprFrame->x3; - XMax=SprFrame->x0; - if (XMaxx1) XMax=SprFrame->x1; - if (XMaxx2) XMax=SprFrame->x2; - if (XMaxx3) XMax=SprFrame->x3; - YMin=SprFrame->y0; - if (YMin>SprFrame->y1) YMin=SprFrame->y1; - if (YMin>SprFrame->y2) YMin=SprFrame->y2; - if (YMin>SprFrame->y3) YMin=SprFrame->y3; - YMax=SprFrame->y0; - if (YMaxy1) YMax=SprFrame->y1; - if (YMaxy2) YMax=SprFrame->y2; - if (YMaxy3) YMax=SprFrame->y3; + s32 YMax; + s32 YMin; - XMax -= origRenderPos.vx; - XMin -= origRenderPos.vx; - YMax -= origRenderPos.vy; - YMin -= origRenderPos.vy; + XMin=SprFrame->x0; + if (XMin>SprFrame->x1) XMin=SprFrame->x1; + if (XMin>SprFrame->x2) XMin=SprFrame->x2; + if (XMin>SprFrame->x3) XMin=SprFrame->x3; + XMax=SprFrame->x0; + if (XMaxx1) XMax=SprFrame->x1; + if (XMaxx2) XMax=SprFrame->x2; + if (XMaxx3) XMax=SprFrame->x3; + YMin=SprFrame->y0; + if (YMin>SprFrame->y1) YMin=SprFrame->y1; + if (YMin>SprFrame->y2) YMin=SprFrame->y2; + if (YMin>SprFrame->y3) YMin=SprFrame->y3; + YMax=SprFrame->y0; + if (YMaxy1) YMax=SprFrame->y1; + if (YMaxy2) YMax=SprFrame->y2; + if (YMaxy3) YMax=SprFrame->y3; - setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); - setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); - } + XMax -= renderPos.vx; + XMin -= renderPos.vx; + YMax -= renderPos.vy; + YMin -= renderPos.vy; + + setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); + setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); } } } diff --git a/source/enemy/nsdart.cpp b/source/enemy/nsdart.cpp index e384217e5..9659c9882 100644 --- a/source/enemy/nsdart.cpp +++ b/source/enemy/nsdart.cpp @@ -42,54 +42,29 @@ void CNpcSquidDartEnemy::render() { CEnemyThing::render(); - // Render - DVECTOR renderPos; - DVECTOR origRenderPos; - DVECTOR offset = CLevel::getCameraPos(); - - int frame = FRM_SQUIDDART_SWIM0001 + ( m_frame >> 8 ); - - int spriteWidth = m_spriteBank->getFrameWidth( frame ); - int spriteHeight = m_spriteBank->getFrameHeight( frame ); - - renderPos.vx = Pos.vx - offset.vx; - origRenderPos.vx = renderPos.vx; - - if ( m_reversed ) + if (canRender()) { - renderPos.vx += ( spriteWidth >> 1 ) + m_drawOffset.vx; - } - else - { - renderPos.vx -= ( spriteWidth >> 1 ) + m_drawOffset.vx; - } + DVECTOR &renderPos=getRenderPos(); - renderPos.vy = Pos.vy - offset.vy; - origRenderPos.vy = renderPos.vy; - renderPos.vy += m_drawOffset.vy - ( spriteHeight >> 1 ); + int frame = FRM_SQUIDDART_SWIM0001 + ( m_frame >> 8 ); - CRECT collisionRect = getCollisionArea(); - collisionRect.x1 -= Pos.vx; - collisionRect.x2 -= Pos.vx; - collisionRect.y1 -= Pos.vy; - collisionRect.y2 -= Pos.vy; + SprFrame = m_spriteBank->printFT4(frame,renderPos.vx,renderPos.vy,m_reversed,0,10); + setRGB0( SprFrame, 255, 128, 255 ); - if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() ) - { - if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() ) - { - SprFrame = m_spriteBank->printFT4(frame,renderPos.vx,renderPos.vy,m_reversed,0,10); - setRGB0( SprFrame, 255, 128, 255 ); + /*s32 XMax = SprFrame->x1 - origRenderPos.vx; + s32 XMin = SprFrame->x0 - origRenderPos.vx; - s32 XMax = SprFrame->x1 - origRenderPos.vx; - s32 XMin = SprFrame->x0 - origRenderPos.vx; + s32 YMax = SprFrame->y2 - origRenderPos.vy; + s32 YMin = SprFrame->y0 - origRenderPos.vy;*/ - s32 YMax = SprFrame->y2 - origRenderPos.vy; - s32 YMin = SprFrame->y0 - origRenderPos.vy; + s32 XMax = SprFrame->x1 - renderPos.vx; + s32 XMin = SprFrame->x0 - renderPos.vx; - setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); - setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); - } + s32 YMax = SprFrame->y2 - renderPos.vy; + s32 YMin = SprFrame->y0 - renderPos.vy; + + setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); + setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); } } } diff --git a/source/enemy/nsj2back.cpp b/source/enemy/nsj2back.cpp index 1d0beffdb..0b4259ecd 100644 --- a/source/enemy/nsj2back.cpp +++ b/source/enemy/nsj2back.cpp @@ -42,67 +42,45 @@ void CNpcSmallJellyfish2BackgroundEnemy::render() { CEnemyThing::render(); - // Render - DVECTOR renderPos; - DVECTOR origRenderPos; - DVECTOR offset = CLevel::getCameraPos(); - int spriteWidth = m_spriteBank->getFrameWidth( m_frame >> 8 ); - int spriteHeight = m_spriteBank->getFrameHeight( m_frame >> 8 ); - - renderPos.vx = Pos.vx - offset.vx; - origRenderPos.vx = renderPos.vx; - renderPos.vx += m_drawOffset.vx; - - renderPos.vy = Pos.vy - offset.vy; - origRenderPos.vy = renderPos.vy; - renderPos.vy += m_drawOffset.vy - ( spriteHeight >> 1 ); - - 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() ) - { - SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,15); - setRGB0( SprFrame, 128, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) + DVECTOR &renderPos=getRenderPos(); - // get xmax, xmin, ymax, ymin + SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,15); + setRGB0( SprFrame, 128, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) - s32 XMax; - s32 XMin; + // get xmax, xmin, ymax, ymin - s32 YMax; - s32 YMin; + s32 XMax; + s32 XMin; - XMin=SprFrame->x0; - if (XMin>SprFrame->x1) XMin=SprFrame->x1; - if (XMin>SprFrame->x2) XMin=SprFrame->x2; - if (XMin>SprFrame->x3) XMin=SprFrame->x3; - XMax=SprFrame->x0; - if (XMaxx1) XMax=SprFrame->x1; - if (XMaxx2) XMax=SprFrame->x2; - if (XMaxx3) XMax=SprFrame->x3; - YMin=SprFrame->y0; - if (YMin>SprFrame->y1) YMin=SprFrame->y1; - if (YMin>SprFrame->y2) YMin=SprFrame->y2; - if (YMin>SprFrame->y3) YMin=SprFrame->y3; - YMax=SprFrame->y0; - if (YMaxy1) YMax=SprFrame->y1; - if (YMaxy2) YMax=SprFrame->y2; - if (YMaxy3) YMax=SprFrame->y3; + s32 YMax; + s32 YMin; - XMax -= origRenderPos.vx; - XMin -= origRenderPos.vx; - YMax -= origRenderPos.vy; - YMin -= origRenderPos.vy; + XMin=SprFrame->x0; + if (XMin>SprFrame->x1) XMin=SprFrame->x1; + if (XMin>SprFrame->x2) XMin=SprFrame->x2; + if (XMin>SprFrame->x3) XMin=SprFrame->x3; + XMax=SprFrame->x0; + if (XMaxx1) XMax=SprFrame->x1; + if (XMaxx2) XMax=SprFrame->x2; + if (XMaxx3) XMax=SprFrame->x3; + YMin=SprFrame->y0; + if (YMin>SprFrame->y1) YMin=SprFrame->y1; + if (YMin>SprFrame->y2) YMin=SprFrame->y2; + if (YMin>SprFrame->y3) YMin=SprFrame->y3; + YMax=SprFrame->y0; + if (YMaxy1) YMax=SprFrame->y1; + if (YMaxy2) YMax=SprFrame->y2; + if (YMaxy3) YMax=SprFrame->y3; - setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); - setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); - } + XMax -= renderPos.vx; + XMin -= renderPos.vx; + YMax -= renderPos.vy; + YMin -= renderPos.vy; + + setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); + setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); } } } diff --git a/source/enemy/nsjback.cpp b/source/enemy/nsjback.cpp index 4598894f0..5b160f369 100644 --- a/source/enemy/nsjback.cpp +++ b/source/enemy/nsjback.cpp @@ -225,67 +225,45 @@ void CNpcSmallJellyfishBackgroundEnemy::render() { CEnemyThing::render(); - // Render - DVECTOR renderPos; - DVECTOR origRenderPos; - DVECTOR offset = CLevel::getCameraPos(); - int spriteWidth = m_spriteBank->getFrameWidth( m_frame >> 8 ); - int spriteHeight = m_spriteBank->getFrameHeight( m_frame >> 8 ); - - renderPos.vx = Pos.vx - offset.vx; - origRenderPos.vx = renderPos.vx; - renderPos.vx += m_drawOffset.vx; - - renderPos.vy = Pos.vy - offset.vy; - origRenderPos.vy = renderPos.vy; - renderPos.vy += m_drawOffset.vy - ( spriteHeight >> 1 ); - - 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() ) - { - SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,15); - setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) + DVECTOR &renderPos=getRenderPos(); - // get xmax, xmin, ymax, ymin + SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,15); + setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) - s32 XMax; - s32 XMin; + // get xmax, xmin, ymax, ymin - s32 YMax; - s32 YMin; + s32 XMax; + s32 XMin; - XMin=SprFrame->x0; - if (XMin>SprFrame->x1) XMin=SprFrame->x1; - if (XMin>SprFrame->x2) XMin=SprFrame->x2; - if (XMin>SprFrame->x3) XMin=SprFrame->x3; - XMax=SprFrame->x0; - if (XMaxx1) XMax=SprFrame->x1; - if (XMaxx2) XMax=SprFrame->x2; - if (XMaxx3) XMax=SprFrame->x3; - YMin=SprFrame->y0; - if (YMin>SprFrame->y1) YMin=SprFrame->y1; - if (YMin>SprFrame->y2) YMin=SprFrame->y2; - if (YMin>SprFrame->y3) YMin=SprFrame->y3; - YMax=SprFrame->y0; - if (YMaxy1) YMax=SprFrame->y1; - if (YMaxy2) YMax=SprFrame->y2; - if (YMaxy3) YMax=SprFrame->y3; + s32 YMax; + s32 YMin; - XMax -= origRenderPos.vx; - XMin -= origRenderPos.vx; - YMax -= origRenderPos.vy; - YMin -= origRenderPos.vy; + XMin=SprFrame->x0; + if (XMin>SprFrame->x1) XMin=SprFrame->x1; + if (XMin>SprFrame->x2) XMin=SprFrame->x2; + if (XMin>SprFrame->x3) XMin=SprFrame->x3; + XMax=SprFrame->x0; + if (XMaxx1) XMax=SprFrame->x1; + if (XMaxx2) XMax=SprFrame->x2; + if (XMaxx3) XMax=SprFrame->x3; + YMin=SprFrame->y0; + if (YMin>SprFrame->y1) YMin=SprFrame->y1; + if (YMin>SprFrame->y2) YMin=SprFrame->y2; + if (YMin>SprFrame->y3) YMin=SprFrame->y3; + YMax=SprFrame->y0; + if (YMaxy1) YMax=SprFrame->y1; + if (YMaxy2) YMax=SprFrame->y2; + if (YMaxy3) YMax=SprFrame->y3; - setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); - setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); - } + XMax -= renderPos.vx; + XMin -= renderPos.vx; + YMax -= renderPos.vy; + YMin -= renderPos.vy; + + setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); + setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); } } } diff --git a/source/enemy/nsjfish.cpp b/source/enemy/nsjfish.cpp index aa9fd1090..834593189 100644 --- a/source/enemy/nsjfish.cpp +++ b/source/enemy/nsjfish.cpp @@ -50,67 +50,45 @@ void CNpcSmallJellyfishEnemy::render() { CEnemyThing::render(); - // Render - DVECTOR renderPos; - DVECTOR origRenderPos; - DVECTOR offset = CLevel::getCameraPos(); - int spriteWidth = m_spriteBank->getFrameWidth( m_frame >> 8 ); - int spriteHeight = m_spriteBank->getFrameHeight( m_frame >> 8 ); - - renderPos.vx = Pos.vx - offset.vx; - origRenderPos.vx = renderPos.vx; - renderPos.vx += m_drawOffset.vx; - - renderPos.vy = Pos.vy - offset.vy; - origRenderPos.vy = renderPos.vy; - renderPos.vy += m_drawOffset.vy - ( spriteHeight >> 1 ); - - 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() ) - { - SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10); - setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) + DVECTOR &renderPos=getRenderPos(); - // get xmax, xmin, ymax, ymin + SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10); + setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) - s32 XMax; - s32 XMin; + // get xmax, xmin, ymax, ymin - s32 YMax; - s32 YMin; + s32 XMax; + s32 XMin; - XMin=SprFrame->x0; - if (XMin>SprFrame->x1) XMin=SprFrame->x1; - if (XMin>SprFrame->x2) XMin=SprFrame->x2; - if (XMin>SprFrame->x3) XMin=SprFrame->x3; - XMax=SprFrame->x0; - if (XMaxx1) XMax=SprFrame->x1; - if (XMaxx2) XMax=SprFrame->x2; - if (XMaxx3) XMax=SprFrame->x3; - YMin=SprFrame->y0; - if (YMin>SprFrame->y1) YMin=SprFrame->y1; - if (YMin>SprFrame->y2) YMin=SprFrame->y2; - if (YMin>SprFrame->y3) YMin=SprFrame->y3; - YMax=SprFrame->y0; - if (YMaxy1) YMax=SprFrame->y1; - if (YMaxy2) YMax=SprFrame->y2; - if (YMaxy3) YMax=SprFrame->y3; + s32 YMax; + s32 YMin; - XMax -= origRenderPos.vx; - XMin -= origRenderPos.vx; - YMax -= origRenderPos.vy; - YMin -= origRenderPos.vy; + XMin=SprFrame->x0; + if (XMin>SprFrame->x1) XMin=SprFrame->x1; + if (XMin>SprFrame->x2) XMin=SprFrame->x2; + if (XMin>SprFrame->x3) XMin=SprFrame->x3; + XMax=SprFrame->x0; + if (XMaxx1) XMax=SprFrame->x1; + if (XMaxx2) XMax=SprFrame->x2; + if (XMaxx3) XMax=SprFrame->x3; + YMin=SprFrame->y0; + if (YMin>SprFrame->y1) YMin=SprFrame->y1; + if (YMin>SprFrame->y2) YMin=SprFrame->y2; + if (YMin>SprFrame->y3) YMin=SprFrame->y3; + YMax=SprFrame->y0; + if (YMaxy1) YMax=SprFrame->y1; + if (YMaxy2) YMax=SprFrame->y2; + if (YMaxy3) YMax=SprFrame->y3; - setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); - setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); - } + XMax -= renderPos.vx; + XMin -= renderPos.vx; + YMax -= renderPos.vy; + YMin -= renderPos.vy; + + setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); + setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); } } } diff --git a/source/enemy/nworm.cpp b/source/enemy/nworm.cpp index 3b44667ce..cfc9573e9 100644 --- a/source/enemy/nworm.cpp +++ b/source/enemy/nworm.cpp @@ -401,30 +401,16 @@ void CNpcParasiticWormEnemy::render() { CEnemyThing::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() ) - { - SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); - m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, 4096 ); + 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 ); - } + SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); + m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, 4096 ); + + 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 ); } } } @@ -439,30 +425,16 @@ void CNpcParasiticWormSegment::render() { CEnemyThing::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() ) - { - SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); - m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, m_scale ); + 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 ); - } + SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); + m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, m_scale ); + + 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/hazard/hazard.cpp b/source/hazard/hazard.cpp index 755c3b0c2..0ce40eca0 100644 --- a/source/hazard/hazard.cpp +++ b/source/hazard/hazard.cpp @@ -361,26 +361,11 @@ void CNpcHazard::render() { CHazardThing::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() ) - { - m_modelGfx->Render(renderPos); - //m_actorGfx->Render(renderPos,0,0,0); - } + DVECTOR &renderPos=getRenderPos(); + + m_modelGfx->Render(renderPos); } } } diff --git a/source/hazard/hbbarrel.cpp b/source/hazard/hbbarrel.cpp index c4b9eac7f..4177063b0 100644 --- a/source/hazard/hbbarrel.cpp +++ b/source/hazard/hbbarrel.cpp @@ -142,34 +142,20 @@ void CNpcBouncingBarrelHazard::render() { CHazardThing::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 = m_rockRotation; - rotation.vy = 0; - rotation.vz = m_rotation; + DVECTOR &renderPos=getRenderPos(); - VECTOR scale; - scale.vx = ONE; - scale.vy = ONE; - scale.vz = ONE; + SVECTOR rotation; + rotation.vx = m_rockRotation; + rotation.vy = 0; + rotation.vz = m_rotation; - m_modelGfx->Render(renderPos,&rotation,&scale); - } + VECTOR scale; + scale.vx = ONE; + scale.vy = ONE; + scale.vz = ONE; + + m_modelGfx->Render(renderPos,&rotation,&scale); } } diff --git a/source/hazard/hboat.cpp b/source/hazard/hboat.cpp index ff7e4931b..87d702f1e 100644 --- a/source/hazard/hboat.cpp +++ b/source/hazard/hboat.cpp @@ -134,40 +134,25 @@ void CNpcBoatHazard::render() { CHazardThing::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(); + + VECTOR flip; + + if ( m_reversed ) { - VECTOR flip; - - if ( m_reversed ) - { - flip.vx = ONE; - } - else - { - flip.vx = -ONE; - } - - flip.vy = ONE; - flip.vz = ONE; - - m_modelGfx->Render( renderPos, NULL, &flip ); - //m_actorGfx->Render(renderPos,0,0,0); + flip.vx = ONE; } + else + { + flip.vx = -ONE; + } + + flip.vy = ONE; + flip.vz = ONE; + + m_modelGfx->Render( renderPos, NULL, &flip ); } } } diff --git a/source/hazard/hbwheel.cpp b/source/hazard/hbwheel.cpp index 5b645dea1..1a76b793b 100644 --- a/source/hazard/hbwheel.cpp +++ b/source/hazard/hbwheel.cpp @@ -47,35 +47,21 @@ void CNpcBigWheelHazard::render() { CHazardThing::render(); - // Render - DVECTOR renderPos; - DVECTOR offset = CLevel::getCameraPos(); - - CRECT collisionRect = getCollisionArea(); - collisionRect.x1 -= Pos.vx; - collisionRect.x2 -= Pos.vx; - collisionRect.y1 -= Pos.vy; - collisionRect.y2 -= Pos.vy; - - renderPos.vx = Pos.vx - offset.vx; - renderPos.vy = Pos.vy - offset.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 = m_rotation; + DVECTOR &renderPos=getRenderPos(); - VECTOR scale; - scale.vx = ONE; - scale.vy = ONE; - scale.vz = ONE; + SVECTOR rotation; + rotation.vx = 0; + rotation.vy = 0; + rotation.vz = m_rotation; - m_modelGfx->Render(renderPos,&rotation,&scale); - } + VECTOR scale; + scale.vx = ONE; + scale.vy = ONE; + scale.vz = ONE; + + m_modelGfx->Render(renderPos,&rotation,&scale); } } diff --git a/source/hazard/hcsaw.cpp b/source/hazard/hcsaw.cpp index 8f944eb70..ffc10c380 100644 --- a/source/hazard/hcsaw.cpp +++ b/source/hazard/hcsaw.cpp @@ -47,34 +47,20 @@ void CNpcCircularSawHazard::render() { CHazardThing::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 = m_rotation; + DVECTOR &renderPos=getRenderPos(); - VECTOR scale; - scale.vx = ONE; - scale.vy = ONE; - scale.vz = ONE; + SVECTOR rotation; + rotation.vx = 0; + rotation.vy = 0; + rotation.vz = m_rotation; - m_modelGfx->Render(renderPos,&rotation,&scale); - } + VECTOR scale; + scale.vx = ONE; + scale.vy = ONE; + scale.vz = ONE; + + m_modelGfx->Render(renderPos,&rotation,&scale); } } diff --git a/source/hazard/hdbarrel.cpp b/source/hazard/hdbarrel.cpp index 285ae51bd..43e323cca 100644 --- a/source/hazard/hdbarrel.cpp +++ b/source/hazard/hdbarrel.cpp @@ -158,34 +158,20 @@ void CNpcDualPlatformBarrelHazard::render() { CHazardThing::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 = m_rotation; + DVECTOR &renderPos=getRenderPos(); - VECTOR scale; - scale.vx = ONE; - scale.vy = ONE; - scale.vz = ONE; + SVECTOR rotation; + rotation.vx = 0; + rotation.vy = 0; + rotation.vz = m_rotation; - m_modelGfx->Render(renderPos,&rotation,&scale); - } + VECTOR scale; + scale.vx = ONE; + scale.vy = ONE; + scale.vz = ONE; + + m_modelGfx->Render(renderPos,&rotation,&scale); } } \ No newline at end of file diff --git a/source/hazard/hfalling.cpp b/source/hazard/hfalling.cpp index 74f7e5867..7d1381605 100644 --- a/source/hazard/hfalling.cpp +++ b/source/hazard/hfalling.cpp @@ -147,7 +147,7 @@ void CNpcFallingHazard::processTimer( int _frames ) void CNpcFallingHazard::collidedWith( CThing *_thisThing ) { - if (!m_bounceFinish && m_movementTimer<=0) CNpcHazard::collidedWith(_thisThing); + if (m_movementTimer<=0) CNpcHazard::collidedWith(_thisThing); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -160,4 +160,43 @@ const CRECT *CNpcFallingHazard::getThinkBBox() objThinkBox.y2 = thinkBBox.YMin + 1; return &objThinkBox; -} \ No newline at end of file +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcFallingHazard::setWaypoints( sThingHazard *ThisHazard ) +{ + int pointNum; + + u16 *PntList=(u16*)MakePtr(ThisHazard,sizeof(sThingHazard)); + + u16 newXPos, newYPos; + + newXPos = (u16) *PntList; + PntList++; + newYPos = (u16) *PntList; + PntList++; + + DVECTOR startPos; + startPos.vx = newXPos << 4; + //startPos.vy = newYPos << 4; + startPos.vy = -10; + + Pos = startPos; + m_base = Pos; + + addWaypoint( newXPos, newYPos ); + + if ( ThisHazard->PointCount > 1 ) + { + for ( pointNum = 1 ; pointNum < ThisHazard->PointCount ; pointNum++ ) + { + newXPos = (u16) *PntList; + PntList++; + newYPos = (u16) *PntList; + PntList++; + + addWaypoint( newXPos, newYPos ); + } + } +} diff --git a/source/hazard/hfalling.h b/source/hazard/hfalling.h index 5e1a0ebe0..bc5e7124e 100644 --- a/source/hazard/hfalling.h +++ b/source/hazard/hfalling.h @@ -23,6 +23,7 @@ class CNpcFallingHazard : public CNpcHazard public: void init(); virtual CRECT const *getThinkBBox(); + virtual void setWaypoints( sThingHazard *ThisHazard ); protected: void processMovement( int _frames ); void processTimer( int _frames ); diff --git a/source/hazard/hfan.cpp b/source/hazard/hfan.cpp index 24f6b69ba..e8ec01485 100644 --- a/source/hazard/hfan.cpp +++ b/source/hazard/hfan.cpp @@ -47,34 +47,20 @@ void CNpcFanHazard::render() { CHazardThing::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 = m_rotation; - rotation.vy = 0; - rotation.vz = 0; + DVECTOR &renderPos=getRenderPos(); - VECTOR scale; - scale.vx = ONE; - scale.vy = ONE; - scale.vz = ONE; + SVECTOR rotation; + rotation.vx = m_rotation; + rotation.vy = 0; + rotation.vz = 0; - m_modelGfx->Render(renderPos,&rotation,&scale); - } + VECTOR scale; + scale.vx = ONE; + scale.vy = ONE; + scale.vz = ONE; + + m_modelGfx->Render(renderPos,&rotation,&scale); } } diff --git a/source/hazard/hmower.cpp b/source/hazard/hmower.cpp index b9f115ad9..b36b11292 100644 --- a/source/hazard/hmower.cpp +++ b/source/hazard/hmower.cpp @@ -47,34 +47,20 @@ void CNpcMowerHazard::render() { CHazardThing::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 = m_rotation; + DVECTOR &renderPos=getRenderPos(); - VECTOR scale; - scale.vx = ONE; - scale.vy = ONE; - scale.vz = ONE; + SVECTOR rotation; + rotation.vx = 0; + rotation.vy = 0; + rotation.vz = m_rotation; - m_modelGfx->Render(renderPos,&rotation,&scale); - } + VECTOR scale; + scale.vx = ONE; + scale.vy = ONE; + scale.vz = ONE; + + m_modelGfx->Render(renderPos,&rotation,&scale); } } diff --git a/source/platform/ppendulm.cpp b/source/platform/ppendulm.cpp index 87262314f..8f06fba36 100644 --- a/source/platform/ppendulm.cpp +++ b/source/platform/ppendulm.cpp @@ -210,3 +210,15 @@ void CNpcPendulumPlatform::render() } } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +const CRECT *CNpcPendulumPlatform::getThinkBBox() +{ + CRECT objThinkBox = getCollisionArea(); + + sBBox &thinkBBox = CThingManager::getThinkBBox(); + objThinkBox.y1 = thinkBBox.YMax - 1; + + return &objThinkBox; +} \ No newline at end of file diff --git a/source/platform/ppendulm.h b/source/platform/ppendulm.h index a6b54f958..cbb3f3e7e 100644 --- a/source/platform/ppendulm.h +++ b/source/platform/ppendulm.h @@ -23,6 +23,7 @@ class CNpcPendulumPlatform : public CNpcPlatform public: virtual void postInit(); virtual void render(); + virtual CRECT const *getThinkBBox(); protected: virtual void setWaypoints( sThingPlatform *ThisPlatform ); virtual void processMovement( int _frames ); diff --git a/source/platform/psbarrel.cpp b/source/platform/psbarrel.cpp index 39ae7eed9..c79cb8f6d 100644 --- a/source/platform/psbarrel.cpp +++ b/source/platform/psbarrel.cpp @@ -118,60 +118,47 @@ void CNpcSteerableBarrelPlatform::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 = m_rotation; + DVECTOR &renderPos=getRenderPos(); + DVECTOR offset = CLevel::getCameraPos(); - VECTOR scale; - scale.vx = ONE; - scale.vy = ONE; - scale.vz = ONE; + SVECTOR rotation; + rotation.vx = 0; + rotation.vy = 0; + rotation.vz = m_rotation; - m_modelGfx->Render(renderPos,&rotation,&scale); + VECTOR scale; + scale.vx = ONE; + scale.vy = ONE; + scale.vz = ONE; - #if defined (__USER_paul__) || defined (__USER_charles__) - DVECTOR size; - DVECTOR centre; - int halfLength; - int x1,y1,x2,y2; + m_modelGfx->Render(renderPos,&rotation,&scale); - centre=getCollisionCentre(); - size=getCollisionSize(); - halfLength=size.vx>>1; +#if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR size; + DVECTOR centre; + int halfLength; + int x1,y1,x2,y2; - 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=getCollisionCentre(); + size=getCollisionSize(); + halfLength=size.vx>>1; - centre.vx-=offset.vx; - centre.vy-=offset.vy; - x1+=centre.vx; - y1+=centre.vy; - x2+=centre.vx; - y2+=centre.vy; + x1=-halfLength*mcos(getCollisionAngle()&4095)>>12; + y1=-halfLength*msin(getCollisionAngle()&4095)>>12; + x2=+halfLength*mcos(getCollisionAngle()&4095)>>12; + y2=+halfLength*msin(getCollisionAngle()&4095)>>12; - DrawLine(x1,y1,x2,y2,0,255,0,0); - #endif - } + 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 } } }