SBSPSS/source/hazard/hspikes.cpp

120 lines
2.2 KiB
C++
Raw Normal View History

2001-05-04 23:24:53 +02:00
/*=========================================================================
hspikes.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __HAZARD_HSPIKES_H__
#include "hazard\hspikes.h"
#endif
#ifndef __LAYER_COLLISION_H__
#include "level\layercollision.h"
#endif
2001-06-07 21:16:59 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-05-04 23:24:53 +02:00
void CNpcSpikesHazard::init()
{
CNpcHazard::init();
m_state = SPIKES_RISING;
2001-06-07 21:16:59 +02:00
m_respawnRate = 8;
m_timerActive = true;
2001-05-04 23:24:53 +02:00
}
2001-06-07 21:16:59 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-05-04 23:24:53 +02:00
void CNpcSpikesHazard::processMovement( int _frames )
{
2001-06-07 21:16:59 +02:00
if ( m_timer <= 0 )
2001-05-04 23:24:53 +02:00
{
2001-06-07 21:16:59 +02:00
s32 minY, maxY;
m_npcPath.getPathYExtents( &minY, &maxY );
switch ( m_state )
2001-05-04 23:24:53 +02:00
{
2001-06-07 21:16:59 +02:00
case SPIKES_DROPPING:
2001-05-04 23:24:53 +02:00
{
2001-06-07 21:16:59 +02:00
if ( maxY - Pos.vy == 0 )
2001-05-04 23:24:53 +02:00
{
2001-06-07 21:16:59 +02:00
m_state = SPIKES_RISING;
m_timer = ( m_respawnRate * GameState::getOneSecondInFrames() ) >> 3;
2001-05-04 23:24:53 +02:00
}
2001-06-07 21:16:59 +02:00
else
{
Pos.vy += 8 * _frames;
2001-05-04 23:24:53 +02:00
2001-06-07 21:16:59 +02:00
if ( Pos.vy > maxY )
{
Pos.vy = maxY;
}
}
2001-05-04 23:24:53 +02:00
2001-06-07 21:16:59 +02:00
break;
2001-05-04 23:24:53 +02:00
}
2001-06-07 21:16:59 +02:00
case SPIKES_RISING:
2001-05-04 23:24:53 +02:00
{
2001-06-07 21:16:59 +02:00
if ( minY - Pos.vy == 0 )
{
m_state = SPIKES_DROPPING;
2001-05-04 23:24:53 +02:00
2001-06-07 21:16:59 +02:00
m_timer = ( m_respawnRate * GameState::getOneSecondInFrames() ) >> 3;
}
else
2001-05-04 23:24:53 +02:00
{
2001-06-07 21:16:59 +02:00
Pos.vy -= 8 * _frames;
if ( Pos.vy < minY )
{
Pos.vy = minY;
}
2001-05-04 23:24:53 +02:00
}
2001-06-07 21:16:59 +02:00
break;
}
2001-05-04 23:24:53 +02:00
}
}
}
2001-06-07 21:16:59 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-06-19 22:07:57 +02:00
/*const CRECT *CNpcSpikesHazard::getThinkBBox()
2001-06-07 21:16:59 +02:00
{
CRECT objThinkBox = getCollisionArea();
sBBox &thinkBBox = CThingManager::getThinkBBox();
objThinkBox.x1 = thinkBBox.XMin;
objThinkBox.x2 = thinkBBox.XMax;
objThinkBox.y1 = thinkBBox.YMin;
objThinkBox.y2 = thinkBBox.YMax;
return &objThinkBox;
2001-06-19 22:07:57 +02:00
}*/
2001-06-07 21:16:59 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcSpikesHazard::processTimer( int _frames )
{
if ( m_timer > 0 )
{
m_timer -= _frames;
}
}