From d3062a046c3971aa4ddbdccb4bc220ba8b29621f Mon Sep 17 00:00:00 2001 From: Daveo Date: Thu, 28 Jun 2001 20:21:02 +0000 Subject: [PATCH] --- source/game/game.cpp | 58 ++++++++++++++++++++++++++++++++++------ source/game/game.h | 4 +++ source/player/player.cpp | 1 + source/player/psbutt.cpp | 2 ++ 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/source/game/game.cpp b/source/game/game.cpp index 93d9cc1be..ce978a2ea 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -156,15 +156,16 @@ CGameScene::ACTOR_TYPE CGameScene::actorType[40] = /*****************************************************************************/ -int s_globalLevelSelectThing=0; -int CGameScene::s_readyToExit; -int CGameScene::s_levelFinished; +int s_globalLevelSelectThing=0; +int CGameScene::s_readyToExit; +int CGameScene::s_levelFinished; #ifdef __VERSION_DEBUG__ -int CGameScene::s_skipToNextLevel; +int CGameScene::s_skipToNextLevel; #endif -int CGameScene::s_restartLevel; -int CGameScene::s_bossHasBeenKilled; -int CGameScene::s_justHitBossArenaTrigger; +int CGameScene::s_restartLevel; +int CGameScene::s_bossHasBeenKilled; +int CGameScene::s_justHitBossArenaTrigger; +DVECTOR CGameScene::s_CamShake={0,0}; /*****************************************************************************/ static const CSoundMediator::SONGID s_bossMusicIds[]= @@ -574,6 +575,7 @@ void CGameScene::think_playing(int _frames) CBubicleFactory::setMapOffset(&camPos); Level.setCameraCentre(camPos); Level.think(_frames); + thinkCameraShake(_frames); m_HealthManager->think(_frames); m_HealthManager->checkPlayerCol(getPlayer()); @@ -721,4 +723,44 @@ void CGameScene::shutdownLevel() Level.shutdown(); } -/*****************************************************************************/ \ No newline at end of file +/*****************************************************************************/ +void CGameScene::setCameraShake(s16 X,s16 Y) +{ + s_CamShake.vx=X; + s_CamShake.vy=Y; +} + +/*****************************************************************************/ +void CGameScene::shakeCamera(DVECTOR &CamPos) +{ + CamPos.vx+=s_CamShake.vx; + CamPos.vy+=s_CamShake.vy; +} + +/*****************************************************************************/ +void CGameScene::thinkCameraShake(int _frames) +{ + if (s_CamShake.vx) + { + if (s_CamShake.vx<0) + { + s_CamShake.vx=-(s_CamShake.vx+1); + } + else + { + s_CamShake.vx=-(s_CamShake.vx-1); + } + } + if (s_CamShake.vy) + { + if (s_CamShake.vy<0) + { + s_CamShake.vy=-(s_CamShake.vy+1); + } + else + { + s_CamShake.vy=-(s_CamShake.vy-1); + } + } + +} diff --git a/source/game/game.h b/source/game/game.h index 89d785dcb..891083343 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -67,6 +67,9 @@ static int getBossHasBeenKilled() {return s_bossHasBeenKilled;} static void dropHealth(DVECTOR &Pos,int Amount,int Vel); +static void setCameraShake(s16 X,s16 Y); +static void shakeCamera(DVECTOR &CamPos); + void thinkCameraShake(int _frames); private: typedef enum { @@ -128,6 +131,7 @@ static CLayerCollision *getCollision() {return(s_GlobalCollision);} static SpriteBank *s_GlobalSpritebank; static CLayerCollision *s_GlobalCollision; static int s_bossHasBeenKilled; +static DVECTOR s_CamShake; int m_levelHasTimer; diff --git a/source/player/player.cpp b/source/player/player.cpp index 5091b56ef..98b95f7b6 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -1161,6 +1161,7 @@ if(PadGetDown(0)&PAD_TRIANGLE) { m_cameraPos.vx=m_currentCamFocusPoint.vx; m_cameraPos.vy=m_currentCamFocusPoint.vy+yoff; + CGameScene::shakeCamera(m_cameraPos); } // Limit camera scroll to the edges of the map diff --git a/source/player/psbutt.cpp b/source/player/psbutt.cpp index b492f69d6..0888ef1c4 100644 --- a/source/player/psbutt.cpp +++ b/source/player/psbutt.cpp @@ -187,6 +187,7 @@ void CPlayerStateButtBounceLand::enter(CPlayerModeBase *_playerMode) if(!m_bounceOffFloor) { CPadVibrationManager::setVibration(0,CPadVibrationManager::VIBE_SHORT); + CGameScene::setCameraShake(0,8); } } @@ -226,6 +227,7 @@ void CPlayerStateButtBounceUp::enter(CPlayerModeBase *_playerMode) pos=_playerMode->getPlayerPos(); CGameBubicleFactory::spawnBubicles(pos.vx-20,pos.vy,40,10,CGameBubicleFactory::TYPE_MEDIUM); CPadVibrationManager::setVibration(0,CPadVibrationManager::VIBE_MEDIUM); + CGameScene::setCameraShake(0,8); } _playerMode->setAnimNo(ANIM_SPONGEBOB_BUTTBOUNCEEND);