SBSPSS/source/player/psrun.cpp

153 lines
2.8 KiB
C++
Raw Normal View History

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-02-09 18:01:04 +01:00
if(controlHeld&PI_LEFT)
2001-01-19 23:54:48 +01:00
{
setFacing(_player,FACING_LEFT);
}
2001-02-09 18:01:04 +01:00
else if(controlHeld&PI_RIGHT)
2001-01-19 23:54:48 +01:00
{
setFacing(_player,FACING_RIGHT);
}
2001-01-25 16:25:46 +01:00
2001-01-31 17:33:22 +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-02-09 18:01:04 +01:00
if(controlDown&PI_JUMP)
2001-01-19 23:54:48 +01:00
{
setState(_player,STATE_JUMP);
}
2001-02-09 18:01:04 +01:00
if(controlHeld&PI_DOWN)
2001-01-22 22:02:59 +01:00
{
setState(_player,STATE_DUCK);
}
2001-02-09 22:41:55 +01:00
if(controlDown&PI_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-02-09 18:01:04 +01:00
if(controlHeld&PI_LEFT)
2001-01-19 23:54:48 +01:00
{
moveLeft(_player);
}
2001-02-09 18:01:04 +01:00
else if(controlHeld&PI_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-31 17:33:22 +01:00
if(m_numberOfTimeAnimHasLooped>=4)
{
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-31 17:33:22 +01:00
m_numberOfTimeAnimHasLooped++;
2001-01-19 23:54:48 +01:00
}
}
/*===========================================================================
end */