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
|
|
|
|
|
2001-03-23 21:09:14 +01:00
|
|
|
#ifndef __PLAYER_PMODES_H__
|
|
|
|
#include "player\pmodes.h"
|
|
|
|
#endif
|
|
|
|
|
2001-01-19 23:54:48 +01:00
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
2001-04-03 18:47:07 +02:00
|
|
|
CPlayerStateRun s_stateRun;
|
|
|
|
CPlayerStateWalk s_stateWalk;
|
|
|
|
|
|
|
|
|
2001-01-19 23:54:48 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-03-25 22:36:28 +02:00
|
|
|
void CPlayerStateRun::enter(CPlayerModeBase *_playerMode)
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
2001-01-29 23:35:18 +01:00
|
|
|
int controlHeld;
|
2001-03-23 21:09:14 +01:00
|
|
|
controlHeld=_playerMode->getPadInputHeld();
|
2001-01-19 23:54:48 +01:00
|
|
|
|
2001-03-23 21:09:14 +01:00
|
|
|
if(_playerMode->getMoveVelocity().vx)
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
2001-04-03 18:47:07 +02:00
|
|
|
_playerMode->setAnimNo(getLoopFrame());
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-03 18:47:07 +02:00
|
|
|
int frame;
|
|
|
|
frame=getStartFrame();
|
|
|
|
if(frame==-1)
|
|
|
|
{
|
|
|
|
frame=getLoopFrame();
|
|
|
|
}
|
|
|
|
_playerMode->setAnimNo(frame);
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
|
|
|
|
2001-02-09 18:01:04 +01:00
|
|
|
if(controlHeld&PI_LEFT)
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
2001-03-23 21:09:14 +01:00
|
|
|
_playerMode->setFacing(FACING_LEFT);
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
2001-02-09 18:01:04 +01:00
|
|
|
else if(controlHeld&PI_RIGHT)
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
2001-03-23 21:09:14 +01:00
|
|
|
_playerMode->setFacing(FACING_RIGHT);
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
2001-01-25 16:25:46 +01:00
|
|
|
|
2001-04-03 18:47:07 +02:00
|
|
|
m_numberOfTimesAnimHasLooped=0;
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-03-25 22:36:28 +02:00
|
|
|
void CPlayerStateRun::think(CPlayerModeBase *_playerMode)
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
2001-01-29 23:35:18 +01:00
|
|
|
int controlDown,controlHeld;
|
2001-03-02 22:05:35 +01:00
|
|
|
int switchedState=false;
|
2001-03-23 21:09:14 +01:00
|
|
|
controlDown=_playerMode->getPadInputDown();
|
|
|
|
controlHeld=_playerMode->getPadInputHeld();
|
2001-01-19 23:54:48 +01:00
|
|
|
|
2001-04-10 22:12:39 +02:00
|
|
|
if(_playerMode->advanceAnimFrameAndCheckForEndOfAnim())
|
|
|
|
{
|
|
|
|
_playerMode->setAnimNo(getLoopFrame());
|
|
|
|
m_numberOfTimesAnimHasLooped++;
|
|
|
|
}
|
|
|
|
|
2001-02-09 18:01:04 +01:00
|
|
|
if(controlDown&PI_JUMP)
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
2001-03-23 21:09:14 +01:00
|
|
|
switchedState=_playerMode->setState(STATE_JUMP);
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
2001-04-05 16:40:50 +02:00
|
|
|
if(controlDown&PI_DOWN)
|
2001-01-22 22:02:59 +01:00
|
|
|
{
|
2001-05-29 17:54:26 +02:00
|
|
|
switchedState=_playerMode->setState(STATE_LOOKDOWN);
|
2001-01-22 22:02:59 +01:00
|
|
|
}
|
2001-06-19 17:23:50 +02:00
|
|
|
else if(controlDown&PI_UP)
|
|
|
|
{
|
|
|
|
switchedState=_playerMode->setState(STATE_LOOKUP);
|
|
|
|
}
|
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
|
|
|
{
|
2001-08-13 18:31:14 +02:00
|
|
|
CPlayer *player = _playerMode->getPlayer();
|
|
|
|
player->setMoveLeftRight( player->getMoveLeftRight() - 1 );
|
|
|
|
|
2001-03-23 21:09:14 +01:00
|
|
|
_playerMode->moveLeft();
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
2001-02-09 18:01:04 +01:00
|
|
|
else if(controlHeld&PI_RIGHT)
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
2001-08-13 18:31:14 +02:00
|
|
|
CPlayer *player = _playerMode->getPlayer();
|
|
|
|
player->setMoveLeftRight( player->getMoveLeftRight() + 1 );
|
|
|
|
|
2001-03-23 21:09:14 +01:00
|
|
|
_playerMode->moveRight();
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-23 21:09:14 +01:00
|
|
|
if(!switchedState)
|
2001-01-19 23:54:48 +01:00
|
|
|
{
|
2001-03-23 21:09:14 +01:00
|
|
|
if(_playerMode->slowdown())
|
2001-01-31 17:33:22 +01:00
|
|
|
{
|
2001-03-23 21:09:14 +01:00
|
|
|
_playerMode->setState(STATE_IDLE);
|
2001-04-03 18:47:07 +02:00
|
|
|
if(m_numberOfTimesAnimHasLooped>=4)
|
2001-03-02 22:05:35 +01:00
|
|
|
{
|
2001-04-03 18:47:07 +02:00
|
|
|
int frame;
|
|
|
|
frame=getStartFrame();
|
|
|
|
if(frame!=-1)
|
|
|
|
{
|
|
|
|
_playerMode->setAnimNo(getEndFrame());
|
|
|
|
}
|
2001-03-02 22:05:35 +01:00
|
|
|
}
|
2001-03-23 21:09:14 +01:00
|
|
|
return;
|
2001-01-31 17:33:22 +01:00
|
|
|
}
|
2001-01-19 23:54:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
|
|
end */
|