SBSPSS/source/player/psbutt.cpp

275 lines
5.8 KiB
C++
Raw Normal View History

2001-01-22 18:48:36 +01:00
/*=========================================================================
psbutt.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "player\psbutt.h"
2001-06-28 21:14:44 +02:00
#ifndef __PAD_VIBE_H__
#include "pad\vibe.h"
#endif
2001-01-22 18:48:36 +01:00
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
2001-03-23 21:09:14 +01:00
#ifndef __PLAYER_PMODES_H__
#include "player\pmodes.h"
#endif
2001-01-26 19:20:41 +01:00
#ifndef __GAME_GAMEBUBS_H__
#include "game\gamebubs.h"
#endif
2001-05-29 20:55:55 +02:00
#ifndef __LEVEL_LEVEL_H__
#include "level\level.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-01-22 18:48:36 +01:00
/* Std Lib
------- */
/* Data
---- */
2001-02-26 21:05:31 +01:00
#ifndef __ANIM_SPONGEBOB_HEADER__
#include <ACTOR_SPONGEBOB_ANIM.h>
2001-01-22 18:48:36 +01:00
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
2001-04-03 18:47:07 +02:00
CPlayerStateButtBounce s_stateButtBounce;
CPlayerStateButtBounceFall s_stateButtBounceFall;
CPlayerStateButtBounceLand s_stateButtBounceLand;
2001-05-11 22:56:43 +02:00
CPlayerStateButtBounceUp s_stateButtBounceUp;
2001-04-03 18:47:07 +02:00
2001-01-22 18:48:36 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateButtBounce::enter(CPlayerModeBase *_playerMode)
2001-01-22 18:48:36 +01:00
{
2001-06-25 18:01:46 +02:00
DVECTOR move;
2001-03-23 21:09:14 +01:00
_playerMode->setAnimNo(ANIM_SPONGEBOB_BUTTBOUNCESTART);
2001-06-25 18:01:46 +02:00
move=_playerMode->getMoveVelocity();
move.vy=0;
_playerMode->setMoveVelocity(&move);
2001-01-22 18:48:36 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateButtBounce::think(CPlayerModeBase *_playerMode)
2001-01-22 18:48:36 +01:00
{
2001-06-25 18:01:46 +02:00
int controlHeld;
controlHeld=_playerMode->getPadInputHeld();
if(controlHeld&PI_LEFT)
{
_playerMode->moveLeft();
}
else if(controlHeld&PI_RIGHT)
{
_playerMode->moveRight();
}
else
{
_playerMode->slowdown();
}
2001-03-23 21:09:14 +01:00
if(_playerMode->advanceAnimFrameAndCheckForEndOfAnim())
2001-01-22 18:48:36 +01:00
{
2001-03-23 21:09:14 +01:00
_playerMode->setState(STATE_BUTTFALL);
2001-01-22 18:48:36 +01:00
}
}
2001-01-31 17:53:23 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateButtBounceFall::enter(CPlayerModeBase *_playerMode)
2001-01-31 17:53:23 +01:00
{
2001-03-23 21:09:14 +01:00
_playerMode->setAnimNo(ANIM_SPONGEBOB_BUTTBOUNCEEND);
2001-01-31 17:53:23 +01:00
}
2001-02-06 22:09:45 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateButtBounceFall::think(CPlayerModeBase *_playerMode)
2001-02-06 22:09:45 +01:00
{
2001-06-25 18:01:46 +02:00
int controlHeld;
controlHeld=_playerMode->getPadInputHeld();
if(controlHeld&PI_LEFT)
{
_playerMode->moveLeft();
}
else if(controlHeld&PI_RIGHT)
{
_playerMode->moveRight();
}
else
{
_playerMode->slowdown();
}
2001-04-11 17:48:16 +02:00
_playerMode->buttFall();
2001-02-06 22:09:45 +01:00
}
2001-01-22 18:48:36 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateButtBounceLand::enter(CPlayerModeBase *_playerMode)
2001-01-22 18:48:36 +01:00
{
2001-05-30 23:00:50 +02:00
m_bounceOffFloor=false;
2001-05-15 00:08:19 +02:00
if(_playerMode->getIsInWater())
{
2001-07-23 21:26:37 +02:00
DVECTOR const &pos=_playerMode->getPlayerPos();
2001-05-29 20:55:55 +02:00
2001-05-30 23:00:50 +02:00
if((CGameScene::getCollision()->getCollisionBlock(pos.vx,pos.vy)&COLLISION_TYPE_MASK)==COLLISION_TYPE_FLAG_DESTRUCTABLE_WALL)
{
CLevel &level=GameScene.GetLevel();
level.destroyMapArea(pos);
m_bounceOffFloor=true;
}
2001-05-15 00:08:19 +02:00
}
2001-06-28 21:14:44 +02:00
if(!m_bounceOffFloor)
{
CPadVibrationManager::setVibration(0,CPadVibrationManager::VIBE_SHORT);
2001-06-28 22:21:02 +02:00
CGameScene::setCameraShake(0,8);
2001-06-28 21:14:44 +02:00
}
2001-01-22 18:48:36 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateButtBounceLand::think(CPlayerModeBase *_playerMode)
2001-01-22 18:48:36 +01:00
{
2001-05-30 23:00:50 +02:00
if(m_bounceOffFloor)
{
_playerMode->setState(STATE_BUTTBOUNCEUP);
}
2001-03-23 21:09:14 +01:00
if(_playerMode->advanceAnimFrameAndCheckForEndOfAnim())
2001-01-22 18:48:36 +01:00
{
2001-03-23 21:09:14 +01:00
_playerMode->setState(STATE_IDLE);
2001-01-22 18:48:36 +01:00
}
2001-06-25 18:01:46 +02:00
_playerMode->zeroMoveVelocity();
2001-01-22 18:48:36 +01:00
}
2001-05-11 22:56:43 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayerStateButtBounceUp::enter(CPlayerModeBase *_playerMode)
{
2001-05-15 00:08:19 +02:00
if(_playerMode->getIsInWater())
{
2001-07-23 21:26:37 +02:00
DVECTOR const &pos=_playerMode->getPlayerPos();
2001-05-15 00:08:19 +02:00
CGameBubicleFactory::spawnBubicles(pos.vx-20,pos.vy,40,10,CGameBubicleFactory::TYPE_MEDIUM);
2001-06-28 21:14:44 +02:00
CPadVibrationManager::setVibration(0,CPadVibrationManager::VIBE_MEDIUM);
2001-06-28 22:21:02 +02:00
CGameScene::setCameraShake(0,8);
2001-05-15 00:08:19 +02:00
}
2001-05-11 22:56:43 +02:00
_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);
}
}
2001-01-22 18:48:36 +01:00
/*===========================================================================
end */