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();
|
|
|
|
DVECTOR playerPos = player->getPos();
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*if ( Pos.vy + moveY < m_initPos.vy )
|
2001-04-23 20:33:40 +02:00
|
|
|
{
|
|
|
|
Pos.vy = m_initPos.vy;
|
|
|
|
m_velocity = 0;
|
|
|
|
m_state = NPC_BOB_STOP;
|
|
|
|
moveY = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Pos.vy += moveY;
|
2001-05-30 17:25:38 +02:00
|
|
|
}*/
|
2001-04-23 20:33:40 +02:00
|
|
|
}
|
|
|
|
}
|