This commit is contained in:
Charles 2001-06-06 16:19:00 +00:00
parent ec7b344da1
commit 9d18ec51df
2 changed files with 104 additions and 47 deletions

View file

@ -23,6 +23,14 @@
#include "utils\utils.h" #include "utils\utils.h"
#endif #endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -31,6 +39,8 @@ void CNpcGaryFriend::postInit()
CNpcFriend::postInit(); CNpcFriend::postInit();
m_started = false; m_started = false;
m_fallDeath = false;
m_drawRotation = 0;
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -39,74 +49,88 @@ void CNpcGaryFriend::think( int _frames )
{ {
CNpcFriend::think(_frames); CNpcFriend::think(_frames);
s8 multiplier = -1 + ( 2 * m_extension ); if ( m_fallDeath )
s32 maxHeight = 20;
s32 fallSpeed = 3;
s8 yMovement = fallSpeed * _frames;
s8 groundHeight;
// check vertical collision
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
if ( m_platform )
{ {
s32 platformHeight = m_platform->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy ); m_drawRotation += 64 * _frames;
m_drawRotation &= 4095;
if ( platformHeight < groundHeight ) Pos.vy += m_speed * _frames;
if ( m_speed < 5 )
{ {
groundHeight = platformHeight; m_speed++;
} }
//Pos.vy += platformHeight; DVECTOR offset = CLevel::getCameraPos();
//return;
}
if ( groundHeight <= 0 ) if ( Pos.vy - offset.vy > VidGetScrH() )
{
// groundHeight <= 0 indicates either on ground or below ground
// check horizontal collision
if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight )
{ {
// reverse direction setToShutdown();
m_extension = !m_extension;
m_reversed = !m_reversed;
}
else
{
// make sure we are on the ground, not below it
Pos.vy += groundHeight;
if ( m_started )
{
CSoundMediator::playSfx( CSoundMediator::SFX_GARY_DE_SNAIL );
Pos.vx += multiplier * _frames;
}
} }
} }
else else
{ {
// above ground s8 multiplier = -1 + ( 2 * m_extension );
s32 maxHeight = 20;
s32 fallSpeed = 3;
s8 yMovement = fallSpeed * _frames;
s8 groundHeight;
if ( groundHeight < yMovement ) // check vertical collision
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
switch ( CGameScene::getCollision()->getCollisionBlock( Pos.vx, Pos.vy ) & COLLISION_TYPE_MASK )
{ {
// colliding with ground case COLLISION_TYPE_FLAG_DEATH_FALL:
case COLLISION_TYPE_FLAG_DEATH_INSTANT:
case COLLISION_TYPE_FLAG_DEATH_LIQUID:
{
CPlayer *player = GameScene.getPlayer();
player->takeDamage( DAMAGE__KILL_OUTRIGHT );
Pos.vy += groundHeight; m_speed = -5;
m_fallDeath = true;
break;
}
default:
break;
}
if ( m_platform )
{
s32 platformHeight = m_platform->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy );
if ( platformHeight < groundHeight )
{
groundHeight = platformHeight;
}
//Pos.vy += platformHeight;
//return;
}
if ( groundHeight <= 0 )
{
// groundHeight <= 0 indicates either on ground or below ground
// check horizontal collision
if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight ) if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight )
{ {
// reverse direction // reverse direction
m_extension = !m_extension; m_extension = !m_extension;
m_reversed = !m_reversed;
} }
else else
{ {
// make sure we are on the ground, not below it
Pos.vy += groundHeight;
if ( m_started ) if ( m_started )
{ {
CSoundMediator::playSfx( CSoundMediator::SFX_GARY_DE_SNAIL ); CSoundMediator::playSfx( CSoundMediator::SFX_GARY_DE_SNAIL );
@ -117,7 +141,34 @@ void CNpcGaryFriend::think( int _frames )
} }
else else
{ {
Pos.vy += yMovement; // above ground
if ( groundHeight < yMovement )
{
// colliding with ground
Pos.vy += groundHeight;
if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight )
{
// reverse direction
m_extension = !m_extension;
}
else
{
if ( m_started )
{
CSoundMediator::playSfx( CSoundMediator::SFX_GARY_DE_SNAIL );
Pos.vx += multiplier * _frames;
}
}
}
else
{
Pos.vy += yMovement;
}
} }
} }
} }
@ -155,13 +206,16 @@ void CNpcGaryFriend::render()
{ {
CNpcThing::render(); CNpcThing::render();
POLY_FT4 *frame;
// Render // Render
if (canRender()) if (canRender())
{ {
DVECTOR &renderPos=getRenderPos(); DVECTOR &renderPos=getRenderPos();
m_actorGfx->Render(renderPos,m_animNo,(m_frame>>8),m_reversed); frame = m_actorGfx->Render(renderPos,m_animNo,(m_frame>>8),m_reversed);
m_actorGfx->RotateScale( frame, renderPos, m_drawRotation, 4096, 4096 );
sBBox boundingBox = m_actorGfx->GetBBox(); sBBox boundingBox = m_actorGfx->GetBBox();
boundingBox.YMax = 0; boundingBox.YMax = 0;

View file

@ -35,6 +35,9 @@ public:
protected: protected:
DVECTOR m_triggerPos; DVECTOR m_triggerPos;
u8 m_started; u8 m_started;
u8 m_fallDeath;
s16 m_speed;
s16 m_drawRotation;
}; };
#endif #endif