2001-01-19 23:54:48 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
psrun.cpp
|
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#include "player\psrun.h"
|
|
|
|
|
|
|
|
#ifndef __PLAYER_PLAYER_H__
|
|
|
|
#include "player\player.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __UTILS_HEADER__
|
|
|
|
#include "utils\utils.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PAD_PADS_H__
|
|
|
|
#include "pad\pads.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
|
|
|
#ifndef __ANIM_PLAYER_ANIM_HEADER__
|
|
|
|
#include <player_anim.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CPlayerStateRun::enter(CPlayer *_player)
|
|
|
|
{
|
2001-01-29 23:35:18 +01:00
|
|
|
int controlHeld;
|
|
|
|
controlHeld=getPadInputHeld(_player);
|
2001-01-19 23:54:48 +01:00
|
|
|
|
|
|
|
if(getMoveVelocity(_player).vx)
|
|
|
|
{
|
|
|
|
setAnimNo(_player,ANIM_PLAYER_ANIM_RUN);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setAnimNo(_player,ANIM_PLAYER_ANIM_RUNSTART);
|
|
|
|
}
|
|
|
|
|
2001-01-29 23:35:18 +01:00
|
|
|
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
|
|
|
setFacing(_player,FACING_LEFT);
|
|
|
|
}
|
2001-01-29 23:35:18 +01:00
|
|
|
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
|
|
|
setFacing(_player,FACING_RIGHT);
|
|
|
|
}
|
2001-01-25 16:25:46 +01:00
|
|
|
|
2001-01-25 23:18:09 +01:00
|
|
|
// m_numberOfTimeAnimHasLooped=0;
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CPlayerStateRun::think(CPlayer *_player)
|
|
|
|
{
|
2001-01-29 23:35:18 +01:00
|
|
|
int controlDown,controlHeld;
|
|
|
|
controlDown=getPadInputDown(_player);
|
|
|
|
controlHeld=getPadInputHeld(_player);
|
2001-01-19 23:54:48 +01:00
|
|
|
|
2001-01-29 23:35:18 +01:00
|
|
|
if(controlDown&CPadConfig::getButton(CPadConfig::PAD_CFG_JUMP))
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
|
|
|
setState(_player,STATE_JUMP);
|
|
|
|
}
|
2001-01-29 23:35:18 +01:00
|
|
|
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN))
|
2001-01-22 22:02:59 +01:00
|
|
|
{
|
|
|
|
setState(_player,STATE_DUCK);
|
|
|
|
}
|
2001-01-29 23:35:18 +01:00
|
|
|
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION))
|
2001-01-22 22:02:59 +01:00
|
|
|
{
|
2001-01-25 16:25:46 +01:00
|
|
|
setState(_player,STATE_RUNATTACK);
|
2001-01-22 22:02:59 +01:00
|
|
|
}
|
2001-01-29 20:23:04 +01:00
|
|
|
|
2001-01-29 23:35:18 +01:00
|
|
|
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
|
|
|
moveLeft(_player);
|
|
|
|
}
|
2001-01-29 23:35:18 +01:00
|
|
|
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
|
|
|
moveRight(_player);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-01-22 23:58:12 +01:00
|
|
|
if(getMoveVelocity(_player).vx==0)
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
|
|
|
setState(_player,STATE_IDLE);
|
2001-01-25 23:18:09 +01:00
|
|
|
// if(m_numberOfTimeAnimHasLooped>=2)
|
|
|
|
// {
|
|
|
|
// setAnimNo(_player,ANIM_PLAYER_ANIM_RUNSTOP);
|
|
|
|
// }
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
slowdown(_player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(advanceAnimFrameAndCheckForEndOfAnim(_player))
|
|
|
|
{
|
|
|
|
setAnimNo(_player,ANIM_PLAYER_ANIM_RUN);
|
2001-01-25 23:18:09 +01:00
|
|
|
// m_numberOfTimeAnimHasLooped++;
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
|
|
end */
|