299 lines
6.6 KiB
C++
299 lines
6.6 KiB
C++
/*=========================================================================
|
|
|
|
pstates.cpp
|
|
|
|
Author: PKG
|
|
Created:
|
|
Project: Spongebob
|
|
Purpose:
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Includes
|
|
-------- */
|
|
|
|
#include "player\pstates.h"
|
|
|
|
#ifndef __PLAYER_PLAYER_H__
|
|
#include "player\player.h"
|
|
#endif
|
|
|
|
|
|
/* Std Lib
|
|
------- */
|
|
|
|
/* Data
|
|
---- */
|
|
|
|
/*----------------------------------------------------------------------
|
|
Tyepdefs && Defines
|
|
------------------- */
|
|
|
|
/*----------------------------------------------------------------------
|
|
Structure defintions
|
|
-------------------- */
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function Prototypes
|
|
------------------- */
|
|
|
|
/*----------------------------------------------------------------------
|
|
Vars
|
|
---- */
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
const PlayerMetrics *CPlayerState::getPlayerMetrics(CPlayer *_player)
|
|
{
|
|
return _player->getPlayerMetrics();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::setState(CPlayer *_player,int _state)
|
|
{
|
|
_player->setState((PLAYER_STATE)_state);
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
int CPlayerState::getFacing(CPlayer *_player)
|
|
{
|
|
return _player->getFacing();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::setFacing(CPlayer *_player,int _facing)
|
|
{
|
|
_player->setFacing(_facing);
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
int CPlayerState::getAnimNo(CPlayer *_player)
|
|
{
|
|
return _player->getAnimNo();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::setAnimNo(CPlayer *_player,int _animNo)
|
|
{
|
|
_player->setAnimNo(_animNo);
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::setAnimFrame(CPlayer *_player,int _animFrame)
|
|
{
|
|
_player->setAnimFrame(_animFrame);
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
int CPlayerState::advanceAnimFrameAndCheckForEndOfAnim(class CPlayer *_player)
|
|
{
|
|
int animFrame,frameCount;
|
|
int looped;
|
|
animFrame=_player->getAnimFrame()+1;
|
|
frameCount=_player->getAnimFrameCount();
|
|
looped=false;
|
|
if(animFrame>=frameCount)
|
|
{
|
|
looped=true;
|
|
animFrame=0;
|
|
}
|
|
_player->setAnimFrame(animFrame);
|
|
return looped;
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
int CPlayerState::retreatAnimFrameAndCheckForEndOfAnim(class CPlayer *_player)
|
|
{
|
|
int animFrame;
|
|
int looped;
|
|
animFrame=_player->getAnimFrame()-1;
|
|
looped=false;
|
|
if(animFrame<0)
|
|
{
|
|
looped=true;
|
|
animFrame=_player->getAnimFrameCount()-1;
|
|
}
|
|
_player->setAnimFrame(animFrame);
|
|
return looped;
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
DVECTOR CPlayerState::getMoveVelocity(CPlayer *_player)
|
|
{
|
|
return _player->getMoveVelocity();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::setMoveVelocity(CPlayer *_player,DVECTOR *_moveVel)
|
|
{
|
|
_player->setMoveVelocity(_moveVel);
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
DVECTOR CPlayerState::getPlayerPos(CPlayer *_player)
|
|
{
|
|
return _player->getPlayerPos();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
int CPlayerState::getPadInput(CPlayer *_player)
|
|
{
|
|
return _player->getPadInput();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
int CPlayerState::isOnSolidGround(CPlayer *_player)
|
|
{
|
|
return _player->isOnSolidGround();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::moveLeft(CPlayer *_player)
|
|
{
|
|
_player->moveLeft();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::moveRight(CPlayer *_player)
|
|
{
|
|
_player->moveRight();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::slowdown(CPlayer *_player)
|
|
{
|
|
_player->slowdown();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::jump(CPlayer *_player)
|
|
{
|
|
_player->jump();
|
|
}
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
Function:
|
|
Purpose:
|
|
Params:
|
|
Returns:
|
|
---------------------------------------------------------------------- */
|
|
void CPlayerState::fall(CPlayer *_player)
|
|
{
|
|
_player->fall();
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
end */
|