This commit is contained in:
Charles 2001-04-27 18:30:19 +00:00
parent 2b7bd23070
commit 7e318c0ab2
4 changed files with 72 additions and 10 deletions

View File

@ -603,8 +603,6 @@ void CNpcEnemy::init()
m_drawOffset.vx = 0;
m_drawOffset.vy = -( ofs.vy >> 1 );
setCollisionCentreOffset( 0, -( ofs.vy >> 1 ) );
m_positionHistory = NULL;
m_isShuttingDown = false;
@ -1276,6 +1274,10 @@ void CNpcEnemy::render()
{
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 );
}
}
}

View File

@ -37,6 +37,7 @@ void CNpcSquidDartEnemy::render()
// Render
DVECTOR renderPos;
DVECTOR origRenderPos;
DVECTOR offset = CLevel::getCameraPos();
int frame = 6 + ( m_frame >> 8 );
@ -44,18 +45,21 @@ void CNpcSquidDartEnemy::render()
int spriteWidth = m_spriteBank->getFrameWidth( frame );
int spriteHeight = m_spriteBank->getFrameHeight( frame );
renderPos.vx = Pos.vx - offset.vx + m_drawOffset.vx;
renderPos.vx = Pos.vx - offset.vx;
origRenderPos.vx = renderPos.vx;
if ( m_reversed )
{
renderPos.vx += spriteWidth >> 1;
renderPos.vx += ( spriteWidth >> 1 ) + m_drawOffset.vx;
}
else
{
renderPos.vx -= spriteWidth >> 1;
renderPos.vx -= ( spriteWidth >> 1 ) + m_drawOffset.vx;
}
renderPos.vy = Pos.vy - offset.vy - ( spriteHeight >> 1 ) + m_drawOffset.vy;
renderPos.vy = Pos.vy - offset.vy;
origRenderPos.vy = renderPos.vy;
renderPos.vy += m_drawOffset.vy - ( spriteHeight >> 1 );
if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() )
{
@ -63,6 +67,15 @@ void CNpcSquidDartEnemy::render()
{
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 YMax = SprFrame->y2 - origRenderPos.vy;
s32 YMin = SprFrame->y0 - origRenderPos.vy;
setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) );
setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 );
}
}
}

View File

@ -45,13 +45,18 @@ void CNpcSmallJellyfishEnemy::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 + m_drawOffset.vx;
renderPos.vx = Pos.vx - offset.vx;
origRenderPos.vx = renderPos.vx;
renderPos.vx += m_drawOffset.vx;
renderPos.vy = Pos.vy - offset.vy - ( spriteHeight >> 1 ) + m_drawOffset.vy;
renderPos.vy = Pos.vy - offset.vy;
origRenderPos.vy = renderPos.vy;
renderPos.vy += m_drawOffset.vy - ( spriteHeight >> 1 );
if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() )
{
@ -59,6 +64,39 @@ void CNpcSmallJellyfishEnemy::render()
{
SprFrame = m_spriteBank->printRotatedScaledSprite( m_frame>>8,renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10);
setRGB0( SprFrame, 255, 128, 255 );
// get xmax, xmin, ymax, ymin
s32 XMax;
s32 XMin;
s32 YMax;
s32 YMin;
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 (XMax<SprFrame->x1) XMax=SprFrame->x1;
if (XMax<SprFrame->x2) XMax=SprFrame->x2;
if (XMax<SprFrame->x3) 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 (YMax<SprFrame->y1) YMax=SprFrame->y1;
if (YMax<SprFrame->y2) YMax=SprFrame->y2;
if (YMax<SprFrame->y3) YMax=SprFrame->y3;
XMax -= origRenderPos.vx;
XMin -= origRenderPos.vx;
YMax -= origRenderPos.vy;
YMin -= origRenderPos.vy;
setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) );
setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 );
}
}
}

View File

@ -110,8 +110,6 @@ void CNpcFriend::init()
m_drawOffset.vx = 0;
m_drawOffset.vy = -( ofs.vy >> 1 );
setCollisionCentreOffset( 0, -( ofs.vy >> 1 ) );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -136,6 +134,13 @@ void CNpcFriend::shutdown()
void CNpcFriend::think(int _frames)
{
if ( _frames > 2 )
{
// make sure enemies don't go berserk if too many frames are dropped
_frames = 2;
}
CNpcThing::think(_frames);
if ( m_animPlaying )
@ -206,6 +211,10 @@ void CNpcFriend::render()
if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
{
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 );
}
}
}