From 469fa455eee1d73f0960b7252e3afe21dba43334 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Feb 2001 21:41:55 +0000 Subject: [PATCH] --- source/game/game.cpp | 19 ++++++- source/game/game.h | 5 +- source/game/pause.cpp | 118 +++++++++++++++++++++++++-------------- source/game/pause.h | 7 ++- source/player/player.cpp | 58 +++++++++++++++++-- source/player/psfall.cpp | 17 ++++-- source/player/psidle.cpp | 2 +- source/player/psjump.cpp | 5 +- source/player/psrun.cpp | 2 +- 9 files changed, 173 insertions(+), 60 deletions(-) diff --git a/source/game/game.cpp b/source/game/game.cpp index 29bc20e95..510562a40 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -47,6 +47,10 @@ #include "gfx\animtex.h" #endif +#ifndef __GAME_PAUSE_H__ +#include "game\pause.h" +#endif + int GX=248; int GY=129; @@ -88,6 +92,9 @@ void CGameScene::init() m_player->init(); m_player->setLayerCollision(Level.getCollisionLayer()); + m_pauseMenu=new ("Pause Menu") CPauseMenu(); + m_pauseMenu->init(); + CFader::setFadingIn(); SetGeomOffset( GX, GY ); @@ -108,6 +115,8 @@ void CGameScene::createPlayer() void CGameScene::shutdown() { + m_pauseMenu->shutdown(); + m_player->shutdown(); delete m_player; CThing::shutdownAndDeleteAllThings(); @@ -121,6 +130,7 @@ void CGameScene::render() { CamMtx.t[2]=ZPos; // Temp + m_pauseMenu->render(); CConversation::render(); CThing::renderAllThings(); Level.render(); @@ -136,8 +146,15 @@ void CGameScene::think(int _frames) // } //#endif + if(PadGetDown(0)&PAD_START) + { + m_pauseMenu->select(); + } + CConversation::think(_frames); - if(!CConversation::isActive()) + m_pauseMenu->think(_frames); + if(!CConversation::isActive()&& + !m_pauseMenu->isActive()) { DVECTOR camPos; CThing::thinkAllThings(_frames); diff --git a/source/game/game.h b/source/game/game.h index 27a3973e4..99127e4a8 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -40,8 +40,9 @@ virtual void createPlayer(); protected: - CLevel Level; - class CPlayer *m_player; + CLevel Level; + class CPauseMenu *m_pauseMenu; + class CPlayer *m_player; static FontBank *s_genericFont; static MATRIX CamMtx; //static class SpriteBank *s_sprites; <-- Was causing compile error, sorry diff --git a/source/game/pause.cpp b/source/game/pause.cpp index cab46d073..f7c08cf31 100644 --- a/source/game/pause.cpp +++ b/source/game/pause.cpp @@ -22,12 +22,12 @@ #include "gui\gframe.h" #endif -#ifndef __GUI_GSPRITE_H__ -#include "gui\gsprite.h" +#ifndef __GUI_GFACTORY_H__ +#include "gui\gfactory.h" #endif -#ifndef __GUI_GTEXTBOX_H__ -#include "gui\gtextbox.h" +#ifndef __MEMORY_HEADER__ +#include "mem\memory.h" #endif @@ -68,27 +68,45 @@ Params: Returns: ---------------------------------------------------------------------- */ -void CConversation::init() +#define FRAME_WIDTH 400 +#define FRAME_HEIGHT 180 +#define TEXT_BOX_WIDTH 300 +#define TEXT_BOX_HEIGHT 20 +#define OT_POS 5 +int m_exitFlag; +extern int newmode; +void CPauseMenu::init() { -/* - s_guiFrame=new ("Conversation GUI") CGUIGroupFrame(); - s_guiFrame->init(0); - s_guiFrame->setObjectXYWH((512-FRAME_WIDTH)/2,256-FRAME_BOTTOM_OFFSET-FRAME_HEIGHT,FRAME_WIDTH,FRAME_HEIGHT); - s_guiFrame->setOt(OT_POS); - s_guiFrame->setFlags(CGUIObject::FLAG_DRAWBORDER); + m_guiFrame=new ("Conversation GUI") CGUIControlFrame(); + m_guiFrame->init(0); + m_guiFrame->setObjectXYWH((512-FRAME_WIDTH)/2,(256-FRAME_HEIGHT)/2,FRAME_WIDTH,FRAME_HEIGHT); + m_guiFrame->setOt(OT_POS); + m_guiFrame->setFlags(CGUIObject::FLAG_DRAWBORDER); - s_guiIcon=new("Conversation Icon") CGUISprite(); - s_guiIcon->init(s_guiFrame); - s_guiIcon->setObjectXYWH(0,0,FRAME_HEIGHT,FRAME_HEIGHT); - s_guiIcon->setOt(OT_POS); - s_guiIcon->setSpriteBank(UI_UIGFX_SPR); - s_guiIcon->setFrame(0); - - s_guiText=new("Conversation Text") CGUITextBox(); - s_guiText->init(s_guiFrame); - s_guiText->setObjectXYWH(FRAME_HEIGHT,TEXT_BORDER,FRAME_WIDTH-FRAME_HEIGHT-TEXT_BORDER,FRAME_HEIGHT-(TEXT_BORDER*2)); - s_guiText->setOt(OT_POS); -*/ + CGUIFactory::createValueButtonFrame(m_guiFrame, + (FRAME_WIDTH-TEXT_BOX_WIDTH)/2,10,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT, + STR__PAUSE_MENU__CONTINUE, + &m_exitFlag,true); + CGUIFactory::createValueButtonFrame(m_guiFrame, + (FRAME_WIDTH-TEXT_BOX_WIDTH)/2,40,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT, + STR__DEBUG__BASICUNARMED_MODE, + &newmode,0); + CGUIFactory::createValueButtonFrame(m_guiFrame, + (FRAME_WIDTH-TEXT_BOX_WIDTH)/2,60,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT, + STR__DEBUG__FULLUNARMED_MODE, + &newmode,1); + CGUIFactory::createValueButtonFrame(m_guiFrame, + (FRAME_WIDTH-TEXT_BOX_WIDTH)/2,80,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT, + STR__DEBUG__SQUEAKYBOOTS_MODE, + &newmode,2); + CGUIFactory::createValueButtonFrame(m_guiFrame, + (FRAME_WIDTH-TEXT_BOX_WIDTH)/2,100,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT, + STR__DEBUG__NET_MODE, + &newmode,3); + CGUIFactory::createValueButtonFrame(m_guiFrame, + (FRAME_WIDTH-TEXT_BOX_WIDTH)/2,120,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT, + STR__DEBUG__CORALBLOWER_MODE, + &newmode,4); m_active=false; } @@ -100,9 +118,9 @@ void CConversation::init() Params: Returns: ---------------------------------------------------------------------- */ -void CConversation::shutdown() +void CPauseMenu::shutdown() { -// s_guiFrame->shutdown(); + m_guiFrame->shutdown(); } @@ -112,9 +130,11 @@ void CConversation::shutdown() Params: Returns: ---------------------------------------------------------------------- */ -void CConversation::select() +void CPauseMenu::select() { m_active=true; + m_exitFlag=false; + m_guiFrame->select(); } @@ -124,29 +144,30 @@ void CConversation::select() Params: Returns: ---------------------------------------------------------------------- */ -void CConversation::think(int _frames) +void CPauseMenu::unselect() { - ASSERT(m_active); -// if(isActive()) -// { -// s_guiFrame->think(_frames); -// } + m_active=false; + m_exitFlag=false; + m_guiFrame->unselect(); } - - /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ -void CConversation::render() +#include "game\game.h" +#include "player\player.h" +void CPauseMenu::think(int _frames) { - ASSERT(m_active); -// if(s_currentState==STATE_ACTIVE) -// { -// s_guiFrame->render(); -// } + if(m_active) + { + m_guiFrame->think(_frames); + if(m_exitFlag||newmode!=-1) + { + unselect(); + } + } } @@ -156,7 +177,22 @@ void CConversation::render() Params: Returns: ---------------------------------------------------------------------- */ -int CConversation::isActive() +void CPauseMenu::render() +{ + if(m_active) + { + m_guiFrame->render(); + } +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CPauseMenu::isActive() { return m_active; } diff --git a/source/game/pause.h b/source/game/pause.h index 1985fa8bf..3cdef9ca3 100644 --- a/source/game/pause.h +++ b/source/game/pause.h @@ -36,6 +36,7 @@ public: void shutdown(); void select(); + void unselect(); void think(int _frames); void render(); @@ -43,7 +44,9 @@ public: private: - int m_active; + int m_active; + + class CGUIControlFrame *m_guiFrame; }; @@ -58,7 +61,7 @@ private: /*---------------------------------------------------------------------- */ -#endif /* __GAME_CONVO_H__ */ +#endif /* __GAME_PAUSE_H__ */ /*=========================================================================== end */ diff --git a/source/player/player.cpp b/source/player/player.cpp index 35c9db81d..b940d8b00 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -57,6 +57,9 @@ ------------------- */ //#define _RECORD_DEMO_MODE_ +#ifdef __USER_paul__ +#define _STATE_DEBUG_ +#endif /*---------------------------------------------------------------------- @@ -102,6 +105,38 @@ static void writeDemoControls() #endif +#ifdef _STATE_DEBUG_ +static const char *s_stateText[NUM_STATES]= +{ + "IDLE", + "IDLETEETER", + "JUMP", + "RUN", + "FALL", + "FALLFAR", + "BUTTBOUNCE", + "BUTTFALL", + "BUTTLAND", + "ATTACK", + "RUNATTACK", + "AIRATTACK", + "DUCK", + "SOAKUP", + "GETUP", + "DEAD", +}; +static const char *s_modeText[NUM_PLAYERMODES]= +{ + "BASICUNARMED", + "FULLUNARMED", + "SQUEAKYBOOTS", + "NET", + "CORALBLOWER", +}; +#include "gfx\font.h" +FontBank s_debugFont; +#endif + int s_health; int s_screenPos; @@ -179,6 +214,11 @@ m_animFrame=0; m_skel.setAng(512); //m_skel.setAngInc(678); + +#ifdef _STATE_DEBUG_ + s_debugFont.initialise(&standardFont); + s_debugFont.setJustification(FontBank::JUST_LEFT); +#endif } /*---------------------------------------------------------------------- @@ -189,6 +229,9 @@ m_skel.setAng(512); ---------------------------------------------------------------------- */ void CPlayer::shutdown() { +#ifdef _STATE_DEBUG_ + s_debugFont.dump(); +#endif CThing::shutdown(); } @@ -198,9 +241,7 @@ void CPlayer::shutdown() Params: Returns: ---------------------------------------------------------------------- */ -#ifdef __USER_paul__ int newmode=-1; -#endif void CPlayer::think(int _frames) { @@ -216,12 +257,12 @@ if(PadGetHeld(0)&PAD_L1&&PadGetHeld(0)&PAD_L2) Pos.vx=23*16; Pos.vy=10*16; } +#endif if(newmode!=-1) { setMode((PLAYER_MODE)newmode); newmode=-1; } -#endif #ifndef __USER_paul__ int padInput=PadGetHeld(0); @@ -351,7 +392,7 @@ Pos.vy=((Pos.vy-16)&0xfffffff0)+colHeight; // Look around int pad=getPadInputHeld(); -if(getPadInputDown()&PAD_CIRCLE) +if(PadGetDown(0)&PAD_CIRCLE) { m_skel.blink(); } @@ -502,6 +543,15 @@ if(eyes!=-1) m_skel.Animate(this); m_skel.Render(this); } + + +#ifdef _STATE_DEBUG_ + char buf[128]; + sprintf(buf,"STATE: %s",s_stateText[m_currentState]); + s_debugFont.print(40,200,buf); + sprintf(buf,"MODE: %s",s_modeText[m_currentMode]); + s_debugFont.print(40,210,buf); +#endif } diff --git a/source/player/psfall.cpp b/source/player/psfall.cpp index e86c5454b..2499fb2f3 100644 --- a/source/player/psfall.cpp +++ b/source/player/psfall.cpp @@ -77,11 +77,12 @@ void CPlayerStateFall::enter(CPlayer *_player) void CPlayerStateFall::think(CPlayer *_player) { const PlayerMetrics *metrics; - int controlHeld; + int controlHeld,controlDown; DVECTOR move; metrics=getPlayerMetrics(_player); controlHeld=getPadInputHeld(_player); + controlDown=getPadInputDown(_player); if(controlHeld&PI_LEFT) { @@ -98,16 +99,20 @@ void CPlayerStateFall::think(CPlayer *_player) fall(_player); - if(controlHeld&PI_ACTION) + if(controlDown&PI_ACTION) { setState(_player,STATE_AIRATTACK); } else if(controlHeld&PI_DOWN) { - move.vx=0; - move.vy=0; - setMoveVelocity(_player,&move); - setState(_player,STATE_BUTTBOUNCE); + if(setState(_player,STATE_BUTTBOUNCE)) + { + // Only do this if this mode allows us to go into butt bounce, otherwise + // SB just floats in the air :) + move.vx=0; + move.vy=0; + setMoveVelocity(_player,&move); + } } advanceAnimFrameAndCheckForEndOfAnim(_player); } diff --git a/source/player/psidle.cpp b/source/player/psidle.cpp index dcc1bea02..d008ed0e4 100644 --- a/source/player/psidle.cpp +++ b/source/player/psidle.cpp @@ -85,7 +85,7 @@ void CPlayerStateBaseIdle::thinkControl(CPlayer *_player) if(canMoveRight(_player)) setState(_player,STATE_RUN); } - else if(controlHeld&PI_ACTION) + else if(controlDown&PI_ACTION) { setState(_player,STATE_ATTACK); } diff --git a/source/player/psjump.cpp b/source/player/psjump.cpp index 2f4654093..19cb35986 100644 --- a/source/player/psjump.cpp +++ b/source/player/psjump.cpp @@ -90,10 +90,11 @@ void CPlayerStateJump::enter(CPlayer *_player) void CPlayerStateJump::think(CPlayer *_player) { const PlayerMetrics *metrics; - int controlHeld; + int controlHeld,controlDown; metrics=getPlayerMetrics(_player); controlHeld=getPadInputHeld(_player); + controlDown=getPadInputDown(_player); if(m_jumpFrames<=metrics->m_metric[PM__MAX_JUMP_FRAMES]&&PI_JUMP) { @@ -104,7 +105,7 @@ void CPlayerStateJump::think(CPlayer *_player) setState(_player,STATE_FALL); } - if(controlHeld&PI_ACTION) + if(controlDown&PI_ACTION) { setState(_player,STATE_AIRATTACK); } diff --git a/source/player/psrun.cpp b/source/player/psrun.cpp index 1d3f826cf..1537d3aee 100644 --- a/source/player/psrun.cpp +++ b/source/player/psrun.cpp @@ -111,7 +111,7 @@ void CPlayerStateRun::think(CPlayer *_player) { setState(_player,STATE_DUCK); } - if(controlHeld&PI_ACTION) + if(controlDown&PI_ACTION) { setState(_player,STATE_RUNATTACK); }