SBSPSS/source/player/psbutt.cpp

222 lines
4.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"
#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-03-23 21:09:14 +01:00
_playerMode->zeroMoveVelocity();
_playerMode->setAnimNo(ANIM_SPONGEBOB_BUTTBOUNCESTART);
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-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-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-15 00:08:19 +02:00
if(_playerMode->getIsInWater())
{
DVECTOR pos;
2001-05-29 20:55:55 +02:00
CLevel &level=GameScene.GetLevel();
2001-05-15 00:08:19 +02:00
pos=_playerMode->getPlayerPos();
CGameBubicleFactory::spawnBubicles(pos.vx-20,pos.vy,40,10,CGameBubicleFactory::TYPE_MEDIUM);
2001-05-29 20:55:55 +02:00
level.destroyMapArea(pos);
2001-05-15 00:08:19 +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-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-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())
{
DVECTOR pos;
pos=_playerMode->getPlayerPos();
CGameBubicleFactory::spawnBubicles(pos.vx-20,pos.vy,40,10,CGameBubicleFactory::TYPE_MEDIUM);
}
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 */