This commit is contained in:
Charles 2001-08-03 21:04:12 +00:00
parent f108a3aab2
commit d95c3a1178
5 changed files with 100 additions and 16 deletions

View File

@ -75,7 +75,7 @@ public:
virtual void init();
virtual void setGraphic( sThingHazard *ThisHazard );
void shutdown();
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
virtual void setWaypoints( sThingHazard *ThisHazard );

View File

@ -27,6 +27,10 @@
#include "game\game.h"
#endif
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -39,20 +43,45 @@ void CNpcCheckpointHazard::init()
m_spriteFrame = 0; // Change by dave cos the checkpoint gfx aint there no more
m_timer = 0;
m_flick = false;
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;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcCheckpointHazard::think(int _frames)
{
if ( m_flick )
{
m_timer -= _frames;
if ( m_timer <= 0 )
{
m_flick = !m_flick;
m_timer = GameState::getOneSecondInFrames();
m_flick = false;
}
else
{
m_scalableFont->setJustification(FontBank::JUST_CENTRE);
m_scalableFont->print( 256, 50, "Checkpoint!" );
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcCheckpointHazard::shutdown()
{
m_scalableFont->dump(); delete m_scalableFont;
CNpcHazard::shutdown();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -72,21 +101,54 @@ void CNpcCheckpointHazard::render()
m_modelGfx->Render(renderPos);
if ( m_triggered )
if ( CLevel::getCurrentCheckpoint() == this )
{
int x,y;
int scrnWidth = VidGetScrW();
int scrnHeight = VidGetScrH();
DVECTOR const &offset = CLevel::getCameraPos();
sBBox boundingBox = m_modelGfx->GetBBox();
int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth(m_spriteFrame);
int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight(m_spriteFrame);
CRECT polyArea;
x = Pos.vx - offset.vx - ( spriteWidth >> 1 );
y = Pos.vy - 100 - offset.vy - ( spriteHeight >> 1 );
polyArea.x1 = boundingBox.XMin + renderPos.vx;
polyArea.y1 = boundingBox.YMin + renderPos.vy;
polyArea.x2 = boundingBox.XMax + renderPos.vx;
polyArea.y2 = boundingBox.YMax + renderPos.vy;
frameHdr = CGameScene::getSpriteBank()->getFrameHeader( m_spriteFrame );
Ft4 = CGameScene::getSpriteBank()->printFT4( frameHdr, x, y, 0, 0, 10 );
setSemiTrans( Ft4, m_flick );
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 );
}
}
}
@ -108,6 +170,9 @@ void CNpcCheckpointHazard::collidedWith(CThing *_thisThing)
respawnPos.vy=collisionArea.y2;
((CPlayer*)_thisThing)->setRespawnPosAndRingTelephone(respawnPos);
m_triggered = true;
m_timer = GameState::getOneSecondInFrames();
m_flick = true;
CLevel::setCurrentCheckpoint( this );
break;
}

View File

@ -18,12 +18,19 @@
#include "hazard\hazard.h"
#endif
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
#endif
class CNpcCheckpointHazard : public CNpcHazard
{
public:
void init();
void render();
void think(int _frames);
void shutdown();
bool alwaysThink() {return(m_flick);}
protected:
void collidedWith(CThing *_thisThing);
@ -31,6 +38,7 @@ protected:
int m_spriteFrame;
int m_timer;
u8 m_flick;
class ScalableFontBank *m_scalableFont;
};
#endif

View File

@ -192,6 +192,7 @@ sLevelHdr *CLevel::LevelHdr;
u8 CLevel::m_isBossRespawn;
s32 CLevel::m_bossHealth;
CNpcCheckpointHazard *CLevel::m_checkpoint;
/*****************************************************************************/
CLevel::CLevel()
@ -253,6 +254,7 @@ sLvlTab *lvlTab=&LvlTable[LevelNo];
initLayers();
m_isBossRespawn = false;
m_checkpoint = NULL;
m_bossHealth = 0;
int level=GameScene.getLevelNumber();

View File

@ -13,6 +13,10 @@
#include "level/layertile.h"
#include "level/layercollision.h"
#ifndef __HAZARD_HCHECK_H__
#include "hazard\hcheck.h"
#endif
/*****************************************************************************/
struct sLvlTab
{
@ -84,6 +88,9 @@ static s32 getBossHealth() {return m_bossHealth;}
static void setIsBossRespawn( u8 newIsBossRespawn) {m_isBossRespawn=newIsBossRespawn;}
static void setBossHealth( s32 newBossHealth ) {m_bossHealth=newBossHealth;}
static CNpcCheckpointHazard *getCurrentCheckpoint() {return( m_checkpoint );}
static void setCurrentCheckpoint( CNpcCheckpointHazard *newCheckpoint ) {m_checkpoint = newCheckpoint;}
static void DisplayLoadingScreen(int LevelNo=25);
private:
@ -122,6 +129,8 @@ static DVECTOR s_playerSpawnPos;
static u8 m_isBossRespawn;
static s32 m_bossHealth;
static CNpcCheckpointHazard *m_checkpoint;
// Level Repair stuff
void CreateTileStore();
void ApplyTileStore();