SBSPSS/source/hazard/hfirebal.cpp

119 lines
2.4 KiB
C++
Raw Normal View History

2001-04-24 16:13:32 +02:00
/*=========================================================================
hfirebal.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __HAZARD_HFIREBAL_H__
#include "hazard\hfirebal.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-05-18 14:55:34 +02:00
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
2001-04-24 16:13:32 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFireballHazard::init()
{
CNpcHazard::init();
2001-05-18 14:55:34 +02:00
m_extension = 0;
m_velocity = 40;
2001-05-23 21:11:51 +02:00
m_height = 50;
2001-04-24 16:13:32 +02:00
2001-05-18 14:55:34 +02:00
m_respawnRate = 4;
}
2001-04-24 16:13:32 +02:00
2001-05-18 14:55:34 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-24 16:13:32 +02:00
2001-05-18 14:55:34 +02:00
void CNpcFireballHazard::setWaypoints( sThingHazard *ThisHazard )
{
int pointNum;
2001-04-24 16:13:32 +02:00
2001-05-18 14:55:34 +02:00
u16 *PntList=(u16*)MakePtr(ThisHazard,sizeof(sThingHazard));
2001-05-10 21:27:57 +02:00
2001-05-18 14:55:34 +02:00
u16 newXPos, newYPos;
2001-05-30 00:07:28 +02:00
m_npcPath.setWaypointCount( ThisHazard->PointCount - 1 );
2001-05-18 14:55:34 +02:00
newXPos = (u16) *PntList;
2001-05-30 00:07:28 +02:00
setWaypointPtr( PntList );
2001-05-18 14:55:34 +02:00
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
2001-05-31 18:24:48 +02:00
startPos.vx = ( newXPos << 4 ) + 8;
startPos.vy = ( newYPos << 4 ) + 16;
2001-05-18 14:55:34 +02:00
Pos = startPos;
m_base = Pos;
2001-05-23 21:11:51 +02:00
s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX );
m_width = maxX - minX;
m_npcPath.getPathYExtents( &minY, &maxY );
m_height = maxY - minY;
2001-04-24 16:13:32 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFireballHazard::processMovement( int _frames )
{
s32 velocity;
if ( m_extension < 4096 )
{
velocity = m_velocity * _frames;
if ( 4096 - m_extension < velocity )
{
velocity = 4096 - m_extension;
}
m_extension += velocity;
}
else
{
// move complete
Pos = m_base;
m_extension = 0;
m_isActive = false;
m_timerActive = true;
2001-05-10 21:27:57 +02:00
m_timer = ( m_respawnRate - 1 ) * GameState::getOneSecondInFrames();
2001-04-24 16:13:32 +02:00
return;
}
2001-05-23 21:11:51 +02:00
Pos.vx = m_base.vx + ( ( m_width * m_extension ) >> 12 );
Pos.vy = m_base.vy - ( m_height * rsin( m_extension >> 1 ) >> 12 );
2001-04-24 16:13:32 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFireballHazard::processTimer( int _frames )
{
m_timer -= _frames;
if ( m_timer < 0 )
{
m_timerActive = false;
m_isActive = true;
}
}