/*========================================================================= psbutt.cpp Author: PKG Created: Project: Spongebob Purpose: Copyright (c) 2001 Climax Development Ltd ===========================================================================*/ /*---------------------------------------------------------------------- Includes -------- */ #include "player\psbutt.h" #ifndef __PLAYER_PLAYER_H__ #include "player\player.h" #endif #ifndef __PLAYER_PMODES_H__ #include "player\pmodes.h" #endif #ifndef __GAME_GAMEBUBS_H__ #include "game\gamebubs.h" #endif #ifndef __LEVEL_LEVEL_H__ #include "level\level.h" #endif #ifndef __GAME_GAME_H__ #include "game\game.h" #endif /* Std Lib ------- */ /* Data ---- */ #ifndef __ANIM_SPONGEBOB_HEADER__ #include #endif /*---------------------------------------------------------------------- Tyepdefs && Defines ------------------- */ /*---------------------------------------------------------------------- Structure defintions -------------------- */ /*---------------------------------------------------------------------- Function Prototypes ------------------- */ /*---------------------------------------------------------------------- Vars ---- */ CPlayerStateButtBounce s_stateButtBounce; CPlayerStateButtBounceFall s_stateButtBounceFall; CPlayerStateButtBounceLand s_stateButtBounceLand; CPlayerStateButtBounceUp s_stateButtBounceUp; /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ void CPlayerStateButtBounce::enter(CPlayerModeBase *_playerMode) { _playerMode->zeroMoveVelocity(); _playerMode->setAnimNo(ANIM_SPONGEBOB_BUTTBOUNCESTART); } /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ void CPlayerStateButtBounce::think(CPlayerModeBase *_playerMode) { if(_playerMode->advanceAnimFrameAndCheckForEndOfAnim()) { _playerMode->setState(STATE_BUTTFALL); } } /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ void CPlayerStateButtBounceFall::enter(CPlayerModeBase *_playerMode) { _playerMode->setAnimNo(ANIM_SPONGEBOB_BUTTBOUNCEEND); } /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ void CPlayerStateButtBounceFall::think(CPlayerModeBase *_playerMode) { _playerMode->buttFall(); } /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ void CPlayerStateButtBounceLand::enter(CPlayerModeBase *_playerMode) { m_bounceOffFloor=false; if(_playerMode->getIsInWater()) { DVECTOR pos; pos=_playerMode->getPlayerPos(); if((CGameScene::getCollision()->getCollisionBlock(pos.vx,pos.vy)&COLLISION_TYPE_MASK)==COLLISION_TYPE_FLAG_DESTRUCTABLE_WALL) { CLevel &level=GameScene.GetLevel(); CGameBubicleFactory::spawnBubicles(pos.vx-20,pos.vy,40,10,CGameBubicleFactory::TYPE_MEDIUM); level.destroyMapArea(pos); m_bounceOffFloor=true; } } } /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ void CPlayerStateButtBounceLand::think(CPlayerModeBase *_playerMode) { if(m_bounceOffFloor) { _playerMode->setState(STATE_BUTTBOUNCEUP); } if(_playerMode->advanceAnimFrameAndCheckForEndOfAnim()) { _playerMode->setState(STATE_IDLE); } } /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ void CPlayerStateButtBounceUp::enter(CPlayerModeBase *_playerMode) { if(_playerMode->getIsInWater()) { DVECTOR pos; pos=_playerMode->getPlayerPos(); CGameBubicleFactory::spawnBubicles(pos.vx-20,pos.vy,40,10,CGameBubicleFactory::TYPE_MEDIUM); } _playerMode->setAnimNo(ANIM_SPONGEBOB_BUTTBOUNCEEND); m_bounceFrames=0; } /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ int bounceUpFrames=5; void CPlayerStateButtBounceUp::think(CPlayerModeBase *_playerMode) { int controlHeld; controlHeld=_playerMode->getPadInputHeld(); if(controlHeld&PI_LEFT) { _playerMode->moveLeft(); } else if(controlHeld&PI_RIGHT) { _playerMode->moveRight(); } else { _playerMode->slowdown(); } if(m_bounceFrames<=bounceUpFrames) { m_bounceFrames++; _playerMode->jump(); } else { _playerMode->setState(STATE_FALL); } } /*=========================================================================== end */