SBSPSS/source/player/psduck.cpp

169 lines
3.8 KiB
C++
Raw Normal View History

2001-01-22 21:58:36 +01:00
/*=========================================================================
psduck.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "player\psduck.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-05-15 00:08:19 +02:00
#ifndef __GAME_GAMEBUBS_H__
#include "game\gamebubs.h"
#endif
2001-01-22 21:58: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 21:58:36 +01:00
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
2001-04-03 18:47:07 +02:00
CPlayerStateDuck s_stateDuck;
CPlayerStateSoakUp s_stateSoakUp;
CPlayerStateGetUp s_stateGetUp;
2001-01-22 21:58:36 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateDuck::enter(CPlayerModeBase *_playerMode)
2001-01-22 21:58:36 +01:00
{
2001-03-23 21:09:14 +01:00
_playerMode->setAnimNo(ANIM_SPONGEBOB_SOAKUP);
2001-01-22 21:58:36 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateDuck::think(CPlayerModeBase *_playerMode)
2001-01-22 21:58:36 +01:00
{
2001-03-23 21:09:14 +01:00
_playerMode->slowdown();
if(_playerMode->advanceAnimFrameAndCheckForEndOfAnim())
2001-01-22 21:58:36 +01:00
{
2001-03-23 21:09:14 +01:00
_playerMode->setState(STATE_SOAKUP);
2001-01-22 21:58:36 +01:00
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateSoakUp::enter(CPlayerModeBase *_playerMode)
2001-01-22 21:58:36 +01:00
{
2001-03-23 21:09:14 +01:00
_playerMode->zeroMoveVelocity();
2001-05-03 21:18:31 +02:00
_playerMode->setAnimNo(ANIM_SPONGEBOB_SOAKUP);
_playerMode->setAnimFrame(_playerMode->getAnimFrameCount()-1);
2001-05-15 00:08:19 +02:00
m_breatheDelayFrames=0;
2001-01-22 21:58:36 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateSoakUp::think(CPlayerModeBase *_playerMode)
2001-01-22 21:58:36 +01:00
{
2001-05-15 00:08:19 +02:00
if(!_playerMode->getIsHealthFullSoICanStopSoakingUp())
2001-01-22 21:58:36 +01:00
{
2001-05-15 00:08:19 +02:00
if(m_breatheDelayFrames==0)
{
DVECTOR pos;
pos=_playerMode->getPlayerPos();
CGameBubicleFactory::spawnBubicles(pos.vx+BUBBLE_XOFF,pos.vy+BUBBLE_YOFF,BUBBLE_W,BUBBLE_H,CGameBubicleFactory::TYPE_SPONGEBOBSOAKUP);
m_breatheDelayFrames=0;
}
if(++m_breatheDelayFrames>BUBBLE_SPAWNDELAY)
{
m_breatheDelayFrames=0;
}
_playerMode->inSoakUpState();
2001-01-22 21:58:36 +01:00
}
2001-05-04 01:45:28 +02:00
else
{
2001-05-15 00:08:19 +02:00
_playerMode->setState(STATE_GETUP);
2001-05-04 01:45:28 +02:00
}
2001-01-22 21:58:36 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateGetUp::enter(CPlayerModeBase *_playerMode)
2001-01-22 21:58:36 +01:00
{
2001-03-23 21:09:14 +01:00
_playerMode->setAnimNo(ANIM_SPONGEBOB_GETUP);
2001-01-22 21:58:36 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-25 22:36:28 +02:00
void CPlayerStateGetUp::think(CPlayerModeBase *_playerMode)
2001-01-22 21:58:36 +01:00
{
2001-03-23 21:09:14 +01:00
if(_playerMode->advanceAnimFrameAndCheckForEndOfAnim())
2001-01-22 21:58:36 +01:00
{
2001-03-23 21:09:14 +01:00
_playerMode->setState(STATE_IDLE);
2001-01-22 21:58:36 +01:00
}
}
/*===========================================================================
end */