2001-07-17 21:34:40 +02:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
hcheck.h
|
|
|
|
|
|
|
|
Author: CRB
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
#ifndef __HAZARD_HCHECK_H__
|
|
|
|
#include "hazard\hcheck.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER_PLAYER_H__
|
|
|
|
#include "player\player.h"
|
|
|
|
#endif
|
|
|
|
|
2001-07-17 22:15:28 +02:00
|
|
|
#ifndef __SPR_SPRITES_H__
|
|
|
|
#include <sprites.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game\game.h"
|
|
|
|
#endif
|
|
|
|
|
2001-08-03 23:04:12 +02:00
|
|
|
#ifndef __VID_HEADER_
|
|
|
|
#include "system\vid.h"
|
|
|
|
#endif
|
|
|
|
|
2001-07-17 21:34:40 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcCheckpointHazard::init()
|
|
|
|
{
|
|
|
|
CNpcHazard::init();
|
|
|
|
|
|
|
|
m_triggered = false;
|
2001-08-03 21:23:11 +02:00
|
|
|
// m_spriteFrame = FRM__CHECKPOINT;
|
|
|
|
m_spriteFrame = 0; // Change by dave cos the checkpoint gfx aint there no more
|
2001-07-17 22:30:13 +02:00
|
|
|
m_timer = 0;
|
|
|
|
m_flick = false;
|
2001-08-03 23:04:12 +02:00
|
|
|
|
|
|
|
m_scalableFont=new ("CheckpointFont") ScalableFontBank();
|
|
|
|
m_scalableFont->initialise(&standardFont);
|
|
|
|
m_scalableFont->setColour(255,255,255);
|
|
|
|
m_scalableFont->setScale(511);
|
|
|
|
|
|
|
|
if ( CLevel::getCurrentCheckpoint() == this )
|
|
|
|
{
|
|
|
|
m_triggered = true;
|
|
|
|
}
|
2001-07-17 22:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcCheckpointHazard::think(int _frames)
|
|
|
|
{
|
2001-08-03 23:04:12 +02:00
|
|
|
if ( m_flick )
|
2001-07-17 22:30:13 +02:00
|
|
|
{
|
2001-08-03 23:04:12 +02:00
|
|
|
m_timer -= _frames;
|
2001-07-17 22:30:13 +02:00
|
|
|
|
2001-08-03 23:04:12 +02:00
|
|
|
if ( m_timer <= 0 )
|
|
|
|
{
|
|
|
|
m_flick = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_scalableFont->setJustification(FontBank::JUST_CENTRE);
|
|
|
|
m_scalableFont->print( 256, 50, "Checkpoint!" );
|
|
|
|
}
|
2001-07-17 22:30:13 +02:00
|
|
|
}
|
2001-07-17 21:34:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-08-03 23:04:12 +02:00
|
|
|
void CNpcCheckpointHazard::shutdown()
|
|
|
|
{
|
|
|
|
m_scalableFont->dump(); delete m_scalableFont;
|
|
|
|
|
|
|
|
CNpcHazard::shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-07-17 21:34:40 +02:00
|
|
|
void CNpcCheckpointHazard::render()
|
|
|
|
{
|
2001-07-17 22:15:28 +02:00
|
|
|
sFrameHdr *frameHdr;
|
2001-07-17 22:30:13 +02:00
|
|
|
POLY_FT4 *Ft4;
|
2001-07-17 22:15:28 +02:00
|
|
|
|
|
|
|
if ( m_isActive )
|
|
|
|
{
|
|
|
|
CHazardThing::render();
|
|
|
|
|
|
|
|
if (canRender())
|
|
|
|
{
|
|
|
|
DVECTOR &renderPos=getRenderPos();
|
|
|
|
|
|
|
|
m_modelGfx->Render(renderPos);
|
|
|
|
|
2001-08-03 23:04:12 +02:00
|
|
|
if ( CLevel::getCurrentCheckpoint() == this )
|
2001-07-17 22:15:28 +02:00
|
|
|
{
|
2001-08-03 23:04:12 +02:00
|
|
|
int scrnWidth = VidGetScrW();
|
|
|
|
int scrnHeight = VidGetScrH();
|
|
|
|
|
|
|
|
sBBox boundingBox = m_modelGfx->GetBBox();
|
|
|
|
|
|
|
|
CRECT polyArea;
|
|
|
|
|
|
|
|
polyArea.x1 = boundingBox.XMin + renderPos.vx;
|
|
|
|
polyArea.y1 = boundingBox.YMin + renderPos.vy;
|
|
|
|
polyArea.x2 = boundingBox.XMax + renderPos.vx;
|
|
|
|
polyArea.y2 = boundingBox.YMax + renderPos.vy;
|
|
|
|
|
|
|
|
if ( polyArea.x1 < 0 )
|
|
|
|
{
|
|
|
|
polyArea.x1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( polyArea.y1 < 0 )
|
|
|
|
{
|
|
|
|
polyArea.y1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( polyArea.x1 > scrnWidth )
|
|
|
|
{
|
|
|
|
polyArea.x1 = scrnWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( polyArea.y1 > scrnHeight )
|
|
|
|
{
|
|
|
|
polyArea.y1 = scrnHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
POLY_F4 *coverPoly;
|
|
|
|
coverPoly = GetPrimF4();
|
|
|
|
coverPoly->x0 = polyArea.x1;
|
|
|
|
coverPoly->y0 = polyArea.y1;
|
|
|
|
coverPoly->x1 = polyArea.x2;
|
|
|
|
coverPoly->y1 = polyArea.y1;
|
|
|
|
coverPoly->x2 = polyArea.x1;
|
|
|
|
coverPoly->y2 = polyArea.y2;
|
|
|
|
coverPoly->x3 = polyArea.x2;
|
|
|
|
coverPoly->y3 = polyArea.y2;
|
|
|
|
|
|
|
|
setRGB0( coverPoly, 255, 255, 0 );
|
|
|
|
|
|
|
|
AddPrimToList( coverPoly, 0 );
|
2001-07-17 22:15:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-17 21:34:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcCheckpointHazard::collidedWith(CThing *_thisThing)
|
|
|
|
{
|
|
|
|
if ( m_isActive && !m_triggered )
|
|
|
|
{
|
|
|
|
switch(_thisThing->getThingType())
|
|
|
|
{
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
{
|
2001-07-23 21:26:37 +02:00
|
|
|
CRECT const &collisionArea=getCollisionArea();
|
2001-07-17 21:34:40 +02:00
|
|
|
DVECTOR respawnPos;
|
|
|
|
respawnPos.vx=collisionArea.x1+((collisionArea.x2-collisionArea.x1)/2);
|
|
|
|
respawnPos.vy=collisionArea.y2;
|
|
|
|
((CPlayer*)_thisThing)->setRespawnPosAndRingTelephone(respawnPos);
|
|
|
|
m_triggered = true;
|
2001-08-03 23:04:12 +02:00
|
|
|
m_timer = GameState::getOneSecondInFrames();
|
|
|
|
m_flick = true;
|
|
|
|
CLevel::setCurrentCheckpoint( this );
|
2001-07-17 21:34:40 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|