SBSPSS/source/platform/pbob.cpp

98 lines
1.8 KiB
C++
Raw Permalink Normal View History

2001-04-23 20:33:40 +02:00
/*=========================================================================
pbob.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PBOB_H__
#include "platform\pbob.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-05-30 17:25:38 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBobbingPlatform::postInit()
{
CNpcPlatform::postInit();
m_vertPos = Pos.vy << 3;
}
2001-04-23 20:33:40 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBobbingPlatform::processMovement( int _frames )
{
if ( m_contact )
{
CPlayer *player = GameScene.getPlayer();
2001-07-23 21:26:37 +02:00
DVECTOR const &playerPos = player->getPos();
2001-04-23 20:33:40 +02:00
int height = player->getHeightFromGroundNoPlatform( playerPos.vx, playerPos.vy );
// if stood on, increase velocity
if ( m_velocity < 0 )
{
m_velocity = 0;
}
2001-05-30 17:25:38 +02:00
else if ( m_velocity < ( 2 << 2 ) )
2001-04-23 20:33:40 +02:00
{
if ( height <= 0 )
{
m_velocity = 0;
}
else
{
m_velocity += 1;
}
}
m_state = NPC_BOB_MOVE;
}
else
{
if ( m_state == NPC_BOB_MOVE )
{
// otherwise drop velocity and ultimately reverse course
2001-05-30 17:25:38 +02:00
if ( m_velocity > -( 2 << 2 ) )
2001-04-23 20:33:40 +02:00
{
m_velocity--;
}
}
}
if ( m_velocity )
{
s32 moveY = m_velocity * _frames;
2001-05-30 17:25:38 +02:00
m_vertPos += moveY;
Pos.vy = m_vertPos >> 3;
if ( Pos.vy < m_initPos.vy )
{
Pos.vy = m_initPos.vy;
m_vertPos = Pos.vy << 3;
m_velocity = 0;
m_state = NPC_BOB_STOP;
moveY = 0;
}
2001-07-24 21:23:40 +02:00
if ( m_soundId == NOT_PLAYING )
2001-04-23 20:33:40 +02:00
{
2001-07-24 21:23:40 +02:00
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_SINKING_CRATE, true, true );
2001-04-23 20:33:40 +02:00
}
}
}