SBSPSS/source/platform/pgeyser.cpp

140 lines
2.3 KiB
C++
Raw Normal View History

2001-04-23 20:27:08 +02:00
/*=========================================================================
pgeyser.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PGEYSER_H__
#include "platform\pgeyser.h"
#endif
2001-05-05 19:34:26 +02:00
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
2001-04-23 20:27:08 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcGeyserPlatform::postInit()
{
2001-05-05 15:54:34 +02:00
CNpcPlatform::postInit();
2001-04-23 22:40:13 +02:00
m_isFiring = false;
2001-05-05 19:34:26 +02:00
m_state = GEYSER_READY;
2001-04-23 20:27:08 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcGeyserPlatform::processMovement( int _frames )
{
2001-04-23 22:40:13 +02:00
if ( m_isFiring )
{
2001-05-05 19:34:26 +02:00
s32 minY, maxY;
m_npcPath.getPathYExtents( &minY, &maxY );
2001-04-23 20:27:08 +02:00
2001-05-05 19:34:26 +02:00
switch ( m_state )
2001-04-23 22:40:13 +02:00
{
2001-05-05 19:34:26 +02:00
case GEYSER_DROPPING:
{
if ( maxY - Pos.vy == 0 )
{
m_isFiring = false;
reinit();
m_state = GEYSER_READY;
}
else
{
2001-05-09 23:27:23 +02:00
s32 moveY = m_speed * _frames;
2001-04-23 20:27:08 +02:00
2001-05-05 19:34:26 +02:00
if ( Pos.vy < ( minY + 64 ) )
{
s32 multiplier = Pos.vy - minY;
2001-04-23 20:27:08 +02:00
2001-05-05 19:34:26 +02:00
moveY = ( multiplier * moveY ) >> 6;
2001-04-23 20:27:08 +02:00
2001-05-05 19:34:26 +02:00
if ( moveY < 1 )
{
moveY = 1;
}
}
2001-04-23 22:40:13 +02:00
2001-05-05 19:34:26 +02:00
Pos.vy += moveY;
2001-04-23 20:27:08 +02:00
2001-05-05 19:34:26 +02:00
if ( Pos.vy > maxY )
{
Pos.vy = maxY;
}
2001-04-23 22:40:13 +02:00
}
2001-05-05 19:34:26 +02:00
break;
2001-04-23 22:40:13 +02:00
}
2001-04-23 20:27:08 +02:00
2001-05-05 19:34:26 +02:00
case GEYSER_RISING:
2001-04-23 20:27:08 +02:00
{
2001-05-05 19:34:26 +02:00
if ( minY - Pos.vy == 0 )
{
m_state = GEYSER_DROPPING;
}
else
{
2001-05-09 23:27:23 +02:00
s32 moveY = m_speed * _frames;
2001-05-05 19:34:26 +02:00
if ( Pos.vy < ( minY + 64 ) )
{
s32 multiplier = Pos.vy - minY;
moveY = ( multiplier * moveY ) >> 6;
if ( moveY < 1 )
{
moveY = 1;
}
}
Pos.vy -= moveY;
2001-04-23 20:27:08 +02:00
2001-05-05 19:34:26 +02:00
if ( Pos.vy < minY )
{
Pos.vy = minY;
}
}
break;
}
2001-04-23 20:27:08 +02:00
}
2001-04-23 22:40:13 +02:00
}
2001-05-05 19:34:26 +02:00
else
{
Pos.vx = m_base.vx + ( -3 + ( getRnd() % 7 ) );
Pos.vy = m_base.vy + ( -3 + ( getRnd() % 7 ) );
}
2001-04-23 22:40:13 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-23 20:27:08 +02:00
2001-04-23 22:40:13 +02:00
void CNpcGeyserPlatform::processTimer( int _frames )
{
if ( m_timer > 0 )
{
m_timer -= _frames;
}
else
{
2001-05-05 19:34:26 +02:00
if ( m_state == GEYSER_READY )
{
m_isFiring = true;
Pos = m_base;
m_state = GEYSER_RISING;
}
2001-04-23 20:27:08 +02:00
}
2001-04-23 22:40:13 +02:00
}