From b60fd2be0ece6caafdf5c0234e735c1070999491 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 9 Jun 2001 20:35:28 +0000 Subject: [PATCH] --- source/backend/party.cpp | 390 +++++++++++++++++++++++++++++++++++++++ source/backend/party.h | 113 ++++++++++++ 2 files changed, 503 insertions(+) create mode 100644 source/backend/party.cpp create mode 100644 source/backend/party.h diff --git a/source/backend/party.cpp b/source/backend/party.cpp new file mode 100644 index 000000000..bcc331fb7 --- /dev/null +++ b/source/backend/party.cpp @@ -0,0 +1,390 @@ +/*========================================================================= + + gameover.cpp + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#include "backend\gameover.h" + +#ifndef __GFX_FONT_H__ +#include "gfx\font.h" +#endif + +#ifndef __PAD_PADS_H__ +#include "pad\pads.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + +#ifndef __FRONTEND_FRONTEND_H__ +#include "frontend\frontend.h" +#endif + +#ifndef __GFX_FADER_H__ +#include "gfx\fader.h" +#endif + +#ifndef _FILEIO_HEADER_ +#include "fileio\fileio.h" +#endif + +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + +#ifndef __MATHTABLE_HEADER__ +#include "utils\mathtab.h" +#endif + +#ifndef __LOCALE_TEXTDBASE_H__ +#include "locale\textdbase.h" +#endif + + +/* Std Lib + ------- */ + +/* Data + ---- */ + +#ifndef __STRING_ENUMS__ +#include +#endif + + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +/*---------------------------------------------------------------------- + Function Prototypes + ------------------- */ + +/*---------------------------------------------------------------------- + Vars + ---- */ + +CGameOverScene GameOverScene; + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGameOverScene::init() +{ + m_image=CFileIO::loadFile(BACKDROP_GAMEOVER_GFX); + ASSERT(m_image); + SetScreenImage((u8*)m_image); + + m_font=new ("game over font") ScalableFontBank(); + m_font->initialise(&standardFont); + m_font->setJustification(ScalableFontBank::JUST_CENTRE); + m_font->setOt(5); + + m_readyToExit=false; + CFader::setFadingIn(CFader::BLACK_FADE); + + initContinue(); + initGameOver(); + + m_state=STATE__CONTINUE; +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGameOverScene::shutdown() +{ + m_font->dump(); delete m_font; + + MemFree(m_image); +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGameOverScene::render() +{ + switch(m_state) + { + case STATE__CONTINUE: + renderContinue(); + break; + case STATE__CONTINUE_TIMED_OUT: + renderContinue(); + renderGameOver(); + break; + case STATE__GAME_OVER: + renderGameOver(); + break; + case STATE__EXITING_TO_GAME: + renderContinue(); + break; + case STATE__EXITING_TO_FRONT_END: + renderGameOver(); + break; + } +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGameOverScene::think(int _frames) +{ + switch(m_state) + { + case STATE__CONTINUE: + thinkContinue(_frames); + break; + case STATE__CONTINUE_TIMED_OUT: + thinkContinue(_frames); + thinkGameOver(_frames); + break; + case STATE__GAME_OVER: + thinkGameOver(_frames); + break; + case STATE__EXITING_TO_GAME: + thinkContinue(_frames); + break; + case STATE__EXITING_TO_FRONT_END: + break; + } +PAUL_DBGMSG("%d",m_state); +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CGameOverScene::readyToShutdown() +{ + return m_readyToExit&&!CFader::isFading(); +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGameOverScene::initContinue() +{ + m_continueFontSin=0; + m_continueFontOffset=100<<2; + m_continueTimer=10*COUNTDOWN_TIME_SECOND_LENGTH; +} +void CGameOverScene::thinkContinue(int _frames) +{ + int move; + + // Slide the text onscreen + if(m_state==STATE__CONTINUE) + { + if(!CFader::isFading()) + { + if(m_continueFontOffset) + { + move=m_continueFontOffset/10; + if(move==0) + { + move=1; + } + m_continueFontOffset-=move; + if(m_continueFontOffset<0) + { + m_continueFontOffset=0; + } + } + else + { + // Countdown ( wait for text to stop first ) + if(m_continueTimer) + { + int pad=PadGetDown(0); + if(pad&PAD_CROSS) + { + m_continueTimer-=m_continueTimer%COUNTDOWN_TIME_SECOND_LENGTH; + } + else if(pad&PAD_START) + { + m_readyToExit=true; + CFader::setFadingOut(CFader::BLACK_FADE); + GameState::setNextScene(&GameScene); + m_state=STATE__EXITING_TO_GAME; + } + else + { + m_continueTimer-=_frames; + } + + if(m_continueTimer<=0) + { + m_continueTimer=0; + m_state=STATE__CONTINUE_TIMED_OUT; + } + } + } + } + } + else if(m_state==STATE__CONTINUE_TIMED_OUT||STATE__EXITING_TO_GAME) + { + // Slide text back off the screen + m_continueFontOffset=(100<<2)-m_continueFontOffset; + move=m_continueFontOffset/10; + if(move==0) + { + move=1; + } + m_continueFontOffset-=move; + if(m_continueFontOffset<0) + { + if(m_state==STATE__CONTINUE_TIMED_OUT) + { + m_state=STATE__GAME_OVER; + } + } + m_continueFontOffset=(100<<2)-m_continueFontOffset; + } + + // Change the text size + m_continueFontSin=(m_continueFontSin+(_frames*CONTINUE_STROBE_SPEED))&4095; +} +void CGameOverScene::renderContinue() +{ + int yOfs; + char buf[100]; + + m_font->setColour(242/2,245/2,15/2); + yOfs=m_continueFontOffset>>2; + + sprintf(buf,TranslationDatabase::getString(STR__BACKEND__CONTINUE)); + m_font->setScale(((msin(m_continueFontSin)*CONTINUE_FONT_SCALE)>>12)+CONTINUE_FONT_BASE_SIZE); + m_font->print(256,50-m_font->getStringHeight(buf)-yOfs,buf); + + sprintf(buf,"%d",m_continueTimer/COUNTDOWN_TIME_SECOND_LENGTH); + m_font->setScale(CONTINUE_FONT_SCALE+CONTINUE_FONT_BASE_SIZE); + m_font->print(256,80-m_font->getStringHeight(buf)-yOfs,buf); + + if(!CFader::isFading()) + { + if(m_continueFontSin>512&m_state==STATE__CONTINUE) + { + sprintf(buf,TranslationDatabase::getString(STR__BACKEND__PRESS_START)); + m_font->setColour(255,0,0); + m_font->print(256,200-m_font->getStringHeight(buf),buf); + } + } +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGameOverScene::initGameOver() +{ + m_gameOverTimer=0; + m_finishedGrowingText=false; +} +void CGameOverScene::thinkGameOver(int _frames) +{ + if(!m_finishedGrowingText) + { + m_gameOverTimer+=_frames; + } + else + { + if(!CFader::isFading()&&!m_readyToExit&& + PadGetDown(0)&(PAD_START|PAD_CROSS)) + { + m_readyToExit=true; + CFader::setFadingOut(CFader::BLACK_FADE); + GameState::setNextScene(&FrontEndScene); + m_state=STATE__EXITING_TO_FRONT_END; + } + } +} +void CGameOverScene::renderGameOver() +{ + char buf[100],*bufPtr; + char letter[]=" \0"; + int i,len,step,x; + + m_font->setColour(80/2,143/2,248/2); + + sprintf(buf,TranslationDatabase::getString(STR__BACKEND__GAME_OVER)); + + bufPtr=buf; + len=strlen(buf); + step=(400<<2)/len; + x=(256<<2)-(((len-1)*step)/2); + + for(i=0;i0) + { + if(sin>GAMEOVER_FONT_MAXSIN) + { + sin=GAMEOVER_FONT_MAXSIN; + if(i==strlen(buf)-1) + { + m_finishedGrowingText=true; + } + } + scale=(msin(sin)*GAMEOVER_FONT_SCALE)>>12; + if(scale>50) + { + m_font->setScale(scale); + letter[0]=*bufPtr; + m_font->print(x>>2,100,letter); + } + } + bufPtr++; + x+=step; + } +} + +/*=========================================================================== + end */ \ No newline at end of file diff --git a/source/backend/party.h b/source/backend/party.h new file mode 100644 index 000000000..ef2a4abdf --- /dev/null +++ b/source/backend/party.h @@ -0,0 +1,113 @@ +/*========================================================================= + + gameover.h + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __BACKEND_GAMEOVER_H__ +#define __BACKEND_GAMEOVER_H__ + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#ifndef __SYSTEM_GSTATE_H__ +#include "system\gstate.h" +#endif + + +/* Std Lib + ------- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +class CGameOverScene: public CScene +{ +public: + void init(); + void shutdown(); + void render(); + void think(int _frames); + int readyToShutdown(); + char *getSceneName() {return"GameOver/Continue";} + + +private: + typedef enum + { + STATE__CONTINUE, + STATE__CONTINUE_TIMED_OUT, + STATE__GAME_OVER, + STATE__EXITING_TO_GAME, + STATE__EXITING_TO_FRONT_END, + } GAMEOVER_STATE; + + + // Continue + enum + { + CONTINUE_STROBE_SPEED=75, + CONTINUE_FONT_SCALE=100, + CONTINUE_FONT_BASE_SIZE=400, + COUNTDOWN_TIME_SECOND_LENGTH=100, // Each 'second' on the countdown lasts this long + }; + void initContinue(); + void thinkContinue(int _frames); + void renderContinue(); + int m_continueFontOffset; + int m_continueFontSin; + int m_continueTimer; + + // Game over + enum + { + GAMEOVER_FONT_SCALE=511, + GAMEOVER_FONT_GROWSPEED=150, + GAMEOVER_FONT_GROWSPACING=900, + GAMEOVER_FONT_MAXSIN=1500, + }; + void initGameOver(); + void thinkGameOver(int _frames); + void renderGameOver(); + int m_gameOverTimer; + int m_finishedGrowingText; + + + GAMEOVER_STATE m_state; + class ScalableFontBank *m_font; + int m_readyToExit; + unsigned char *m_image; + +}; + + +/*---------------------------------------------------------------------- + Globals + ------- */ + +extern CGameOverScene GameOverScene; + + +/*---------------------------------------------------------------------- + Functions + --------- */ + +/*---------------------------------------------------------------------- */ + +#endif /* __BACKEND_GAMEOVER_H__ */ + +/*=========================================================================== + end */