This commit is contained in:
parent
b8a82dd6fe
commit
f7614f78e0
8 changed files with 808 additions and 0 deletions
132
source/player/psfall.cpp
Normal file
132
source/player/psfall.cpp
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
psfall.cpp
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#include "player\psfall.h"
|
||||||
|
|
||||||
|
#ifndef __PLAYER_PLAYER_H__
|
||||||
|
#include "player\player.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 CPlayerStateFall::enter(CPlayer *_player)
|
||||||
|
{
|
||||||
|
setAnimNo(_player,ANIM_PLAYER_ANIM_JUMPSTART);
|
||||||
|
m_fallFrames=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void CPlayerStateFall::think(CPlayer *_player)
|
||||||
|
{
|
||||||
|
int control;
|
||||||
|
DVECTOR move;
|
||||||
|
|
||||||
|
control=getPadInput(_player);
|
||||||
|
|
||||||
|
move=getMoveVelocity(_player);
|
||||||
|
move.vy+=GRAVITY_VALUE;
|
||||||
|
if(move.vy>=TERMINAL_VELOCITY<<PSHIFT)
|
||||||
|
{
|
||||||
|
move.vy=TERMINAL_VELOCITY<<PSHIFT;
|
||||||
|
m_fallFrames++;
|
||||||
|
if(m_fallFrames>MAX_SAFE_FALL_FRAMES)
|
||||||
|
{
|
||||||
|
setState(_player,STATE_FALLFAR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setMoveVelocity(_player,&move);
|
||||||
|
|
||||||
|
if(control&PAD_LEFT)
|
||||||
|
{
|
||||||
|
moveLeft(_player);
|
||||||
|
}
|
||||||
|
else if(control&PAD_RIGHT)
|
||||||
|
{
|
||||||
|
moveRight(_player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slowdown(_player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(isOnSolidGround(_player))
|
||||||
|
{
|
||||||
|
move=getMoveVelocity(_player);
|
||||||
|
// if(move.vx)
|
||||||
|
// {
|
||||||
|
// setState(_player,STATE_RUN);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
setState(_player,STATE_IDLE);
|
||||||
|
}
|
||||||
|
move.vy=0;
|
||||||
|
setMoveVelocity(_player,&move);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
68
source/player/psfall.h
Normal file
68
source/player/psfall.h
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
psfall.h
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLAYER_PSFALL_H__
|
||||||
|
#define __PLAYER_PSFALL_H__
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#include "player\pstates.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
class CPlayerStateFall : public CPlayerState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void enter(class CPlayer *_player);
|
||||||
|
void think(class CPlayer *_player);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_fallFrames;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CPlayerStateFallFar : public CPlayerStateFall
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Globals
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Functions
|
||||||
|
--------- */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __PLAYER_PSFALL_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
||||||
|
|
||||||
|
|
||||||
|
|
120
source/player/psjump.cpp
Normal file
120
source/player/psjump.cpp
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
psjump.cpp
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#include "player\psjump.h"
|
||||||
|
|
||||||
|
#ifndef __PLAYER_PLAYER_H__
|
||||||
|
#include "player\player.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 CPlayerStateJump::enter(CPlayer *_player)
|
||||||
|
{
|
||||||
|
setAnimNo(_player,ANIM_PLAYER_ANIM_JUMPSTART);
|
||||||
|
m_jumpFrames=0;
|
||||||
|
DVECTOR move=getMoveVelocity(_player);
|
||||||
|
move.vy=-JUMP_VELOCITY<<PSHIFT;
|
||||||
|
setMoveVelocity(_player,&move);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void CPlayerStateJump::think(CPlayer *_player)
|
||||||
|
{
|
||||||
|
int control;
|
||||||
|
control=getPadInput(_player);
|
||||||
|
|
||||||
|
if(m_jumpFrames<=MAX_JUMP_FRAMES&&control&PAD_CROSS)
|
||||||
|
{
|
||||||
|
m_jumpFrames++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DVECTOR move;
|
||||||
|
move=getMoveVelocity(_player);
|
||||||
|
if(move.vy>=0)
|
||||||
|
{
|
||||||
|
setState(_player,STATE_FALL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
move.vy+=GRAVITY_VALUE;
|
||||||
|
}
|
||||||
|
setMoveVelocity(_player,&move);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(control&PAD_LEFT)
|
||||||
|
{
|
||||||
|
moveLeft(_player);
|
||||||
|
}
|
||||||
|
else if(control&PAD_RIGHT)
|
||||||
|
{
|
||||||
|
moveRight(_player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slowdown(_player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
63
source/player/psjump.h
Normal file
63
source/player/psjump.h
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
psjump.h
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLAYER_PSJUMP_H__
|
||||||
|
#define __PLAYER_PSJUMP_H__
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#include "player\pstates.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
class CPlayerStateJump : public CPlayerState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void enter(class CPlayer *_player);
|
||||||
|
void think(class CPlayer *_player);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_jumpFrames;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Globals
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Functions
|
||||||
|
--------- */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __PLAYER_PSJUMP_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
||||||
|
|
||||||
|
|
||||||
|
|
138
source/player/psrun.cpp
Normal file
138
source/player/psrun.cpp
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
int control;
|
||||||
|
control=getPadInput(_player);
|
||||||
|
|
||||||
|
if(getMoveVelocity(_player).vx)
|
||||||
|
{
|
||||||
|
setAnimNo(_player,ANIM_PLAYER_ANIM_RUN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setAnimNo(_player,ANIM_PLAYER_ANIM_RUNSTART);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(control&PAD_LEFT)
|
||||||
|
{
|
||||||
|
setFacing(_player,FACING_LEFT);
|
||||||
|
}
|
||||||
|
else if(control&PAD_RIGHT)
|
||||||
|
{
|
||||||
|
setFacing(_player,FACING_RIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void CPlayerStateRun::think(CPlayer *_player)
|
||||||
|
{
|
||||||
|
int control;
|
||||||
|
control=getPadInput(_player);
|
||||||
|
|
||||||
|
if(control&PAD_CROSS)
|
||||||
|
{
|
||||||
|
setState(_player,STATE_JUMP);
|
||||||
|
}
|
||||||
|
if(control&PAD_LEFT)
|
||||||
|
{
|
||||||
|
moveLeft(_player);
|
||||||
|
}
|
||||||
|
else if(control&PAD_RIGHT)
|
||||||
|
{
|
||||||
|
moveRight(_player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DVECTOR move;
|
||||||
|
move=getMoveVelocity(_player);
|
||||||
|
if(move.vx==0)
|
||||||
|
{
|
||||||
|
setState(_player,STATE_IDLE);
|
||||||
|
setAnimNo(_player,ANIM_PLAYER_ANIM_RUNSTOP);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slowdown(_player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(advanceAnimFrameAndCheckForEndOfAnim(_player))
|
||||||
|
{
|
||||||
|
setAnimNo(_player,ANIM_PLAYER_ANIM_RUN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
59
source/player/psrun.h
Normal file
59
source/player/psrun.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
psjump.h
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLAYER_PSRUN_H__
|
||||||
|
#define __PLAYER_PSRUN_H__
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#include "player\pstates.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
class CPlayerStateRun : public CPlayerState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void enter(class CPlayer *_player);
|
||||||
|
void think(class CPlayer *_player);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Globals
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Functions
|
||||||
|
--------- */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __PLAYER_PSRUN_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
||||||
|
|
||||||
|
|
||||||
|
|
135
source/player/pstates.cpp
Normal file
135
source/player/pstates.cpp
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
#include "player\pstates.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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __ANIM_PLAYER_ANIM_HEADER__
|
||||||
|
#include <player_anim.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------*/
|
||||||
|
void CPlayerState::setState(CPlayer *_player,int _state)
|
||||||
|
{
|
||||||
|
_player->setState((PLAYER_STATE)_state);
|
||||||
|
}
|
||||||
|
int CPlayerState::getFacing(CPlayer *_player)
|
||||||
|
{
|
||||||
|
return _player->getFacing();
|
||||||
|
}
|
||||||
|
void CPlayerState::setFacing(CPlayer *_player,int _facing)
|
||||||
|
{
|
||||||
|
_player->setFacing(_facing);
|
||||||
|
}
|
||||||
|
int CPlayerState::getAnimNo(CPlayer *_player)
|
||||||
|
{
|
||||||
|
return _player->getAnimNo();
|
||||||
|
}
|
||||||
|
void CPlayerState::setAnimNo(CPlayer *_player,int _animNo)
|
||||||
|
{
|
||||||
|
_player->setAnimNo(_animNo);
|
||||||
|
}
|
||||||
|
void CPlayerState::setAnimFrame(CPlayer *_player,int _animFrame)
|
||||||
|
{
|
||||||
|
_player->setAnimFrame(_animFrame);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
DVECTOR CPlayerState::getMoveVelocity(CPlayer *_player)
|
||||||
|
{
|
||||||
|
return _player->getMoveVelocity();
|
||||||
|
}
|
||||||
|
void CPlayerState::setMoveVelocity(CPlayer *_player,DVECTOR *_moveVel)
|
||||||
|
{
|
||||||
|
_player->setMoveVelocity(_moveVel);
|
||||||
|
}
|
||||||
|
int CPlayerState::getPadInput(CPlayer *_player)
|
||||||
|
{
|
||||||
|
return _player->getPadInput();
|
||||||
|
}
|
||||||
|
int CPlayerState::isOnSolidGround(CPlayer *_player)
|
||||||
|
{
|
||||||
|
return _player->isOnSolidGround();
|
||||||
|
}
|
||||||
|
void CPlayerState::moveLeft(CPlayer *_player)
|
||||||
|
{
|
||||||
|
_player->moveLeft();
|
||||||
|
}
|
||||||
|
void CPlayerState::moveRight(CPlayer *_player)
|
||||||
|
{
|
||||||
|
_player->moveRight();
|
||||||
|
}
|
||||||
|
void CPlayerState::slowdown(CPlayer *_player)
|
||||||
|
{
|
||||||
|
_player->slowdown();
|
||||||
|
}
|
||||||
|
void CPlayerState::jump(CPlayer *_player)
|
||||||
|
{
|
||||||
|
_player->jump();
|
||||||
|
}
|
||||||
|
void CPlayerState::fall(CPlayer *_player)
|
||||||
|
{
|
||||||
|
_player->fall();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------*/
|
||||||
|
void CPlayerStateIdle::enter(CPlayer *_player)
|
||||||
|
{
|
||||||
|
setAnimNo(_player,ANIM_PLAYER_ANIM_IDLEGENERIC04);
|
||||||
|
}
|
||||||
|
void CPlayerStateIdle::think(CPlayer *_player)
|
||||||
|
{
|
||||||
|
int control;
|
||||||
|
control=getPadInput(_player);
|
||||||
|
|
||||||
|
if(control&PAD_CROSS)
|
||||||
|
{
|
||||||
|
setState(_player,STATE_JUMP);
|
||||||
|
}
|
||||||
|
else if(control&(PAD_LEFT|PAD_RIGHT))
|
||||||
|
{
|
||||||
|
setState(_player,STATE_RUN);
|
||||||
|
}
|
||||||
|
else if(advanceAnimFrameAndCheckForEndOfAnim(_player))
|
||||||
|
{
|
||||||
|
if(getRndRange(100)<95)
|
||||||
|
setAnimNo(_player,ANIM_PLAYER_ANIM_IDLEGENERIC04);
|
||||||
|
else
|
||||||
|
setAnimNo(_player,ANIM_PLAYER_ANIM_IDLEGENERIC03);
|
||||||
|
}
|
||||||
|
}
|
93
source/player/pstates.h
Normal file
93
source/player/pstates.h
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
pstates.h
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLAYER_PSTATES_H__
|
||||||
|
#define __PLAYER_PSTATES_H__
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#ifndef _GLOBAL_HEADER_
|
||||||
|
#include "system\global.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
class CPlayerState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void enter(class CPlayer *_player)=0;
|
||||||
|
virtual void think(class CPlayer *_player)=0;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setState(class CPlayer *_player,int _state);
|
||||||
|
int getFacing(class CPlayer *_player);
|
||||||
|
void setFacing(class CPlayer *_player,int _facing);
|
||||||
|
int getAnimNo(class CPlayer *_player);
|
||||||
|
void setAnimNo(class CPlayer *_player,int _animNo);
|
||||||
|
void setAnimFrame(class CPlayer *_player,int _animFrame);
|
||||||
|
int advanceAnimFrameAndCheckForEndOfAnim(class CPlayer *_player);
|
||||||
|
DVECTOR getMoveVelocity(class CPlayer *_player);
|
||||||
|
void setMoveVelocity(class CPlayer *_player,DVECTOR *_moveVel);
|
||||||
|
int getPadInput(class CPlayer *_player);
|
||||||
|
|
||||||
|
int isOnSolidGround(class CPlayer *_player);
|
||||||
|
|
||||||
|
void moveLeft(class CPlayer *_player);
|
||||||
|
void moveRight(class CPlayer *_player);
|
||||||
|
void slowdown(class CPlayer *_player);
|
||||||
|
void jump(class CPlayer *_player);
|
||||||
|
void fall(class CPlayer *_player);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class CPlayerStateIdle : public CPlayerState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void enter(class CPlayer *_player);
|
||||||
|
void think(class CPlayer *_player);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Globals
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Functions
|
||||||
|
--------- */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __PLAYER_PSTATES_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue