From d95c3a11786f86e806d4c4638f1aa6276723177f Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Aug 2001 21:04:12 +0000 Subject: [PATCH] --- source/hazard/hazard.h | 2 +- source/hazard/hcheck.cpp | 95 +++++++++++++++++++++++++++++++++------- source/hazard/hcheck.h | 8 ++++ source/level/level.cpp | 2 + source/level/level.h | 9 ++++ 5 files changed, 100 insertions(+), 16 deletions(-) diff --git a/source/hazard/hazard.h b/source/hazard/hazard.h index 9538e2808..27fa2c285 100644 --- a/source/hazard/hazard.h +++ b/source/hazard/hazard.h @@ -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 ); diff --git a/source/hazard/hcheck.cpp b/source/hazard/hcheck.cpp index 7bc7b052c..7dd517b26 100644 --- a/source/hazard/hcheck.cpp +++ b/source/hazard/hcheck.cpp @@ -27,6 +27,10 @@ #include "game\game.h" #endif +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -39,24 +43,49 @@ 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) { - m_timer -= _frames; - - if ( m_timer <= 0 ) + if ( m_flick ) { - m_flick = !m_flick; + m_timer -= _frames; - m_timer = GameState::getOneSecondInFrames(); + if ( m_timer <= 0 ) + { + 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(); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcCheckpointHazard::render() { sFrameHdr *frameHdr; @@ -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; } diff --git a/source/hazard/hcheck.h b/source/hazard/hcheck.h index ca5fa8c38..9e8a595fd 100644 --- a/source/hazard/hcheck.h +++ b/source/hazard/hcheck.h @@ -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 \ No newline at end of file diff --git a/source/level/level.cpp b/source/level/level.cpp index 8df78fab5..e3908a7a8 100644 --- a/source/level/level.cpp +++ b/source/level/level.cpp @@ -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(); diff --git a/source/level/level.h b/source/level/level.h index b708c089e..a9256fb22 100644 --- a/source/level/level.h +++ b/source/level/level.h @@ -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();