This commit is contained in:
parent
d7e13123b1
commit
e890f6ce88
@ -1,22 +1,55 @@
|
|||||||
/**************/
|
/*=========================================================================
|
||||||
/*** Player ***/
|
|
||||||
/**************/
|
|
||||||
|
|
||||||
#include "system\global.h"
|
player.cpp
|
||||||
#include "Game\Thing.h"
|
|
||||||
#include "Gfx\Skel.h"
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#include "player\player.h"
|
||||||
|
|
||||||
|
#ifndef __ANIM_HEADER__
|
||||||
#include "gfx\anim.h"
|
#include "gfx\anim.h"
|
||||||
#include "Player\Player.h"
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PAD_PADS_H__
|
||||||
#include "pad\pads.h"
|
#include "pad\pads.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __UTILS_HEADER__
|
||||||
|
#include "utils\utils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// to be removed
|
// to be removed
|
||||||
#include "fileio\fileio.h"
|
//#include "fileio\fileio.h"
|
||||||
#include "utils\utils.h"
|
|
||||||
#include "gfx\tpage.h"
|
#include "gfx\tpage.h"
|
||||||
#include "gfx\prim.h"
|
//#include "gfx\prim.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/* Data
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
#define ANIM_IDLE_SHORT 15
|
#define ANIM_IDLE_SHORT 15
|
||||||
#define ANIM_IDLE_LONG 16
|
#define ANIM_IDLE_LONG 16
|
||||||
@ -25,8 +58,20 @@
|
|||||||
#define ANIM_RUNSTOP 30
|
#define ANIM_RUNSTOP 30
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function Prototypes
|
||||||
|
------------------- */
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*----------------------------------------------------------------------
|
||||||
|
Vars
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
void CPlayer::init()
|
void CPlayer::init()
|
||||||
{
|
{
|
||||||
CThing::init();
|
CThing::init();
|
||||||
@ -38,17 +83,26 @@ void CPlayer::init()
|
|||||||
|
|
||||||
setState(STATE_IDLE);
|
setState(STATE_IDLE);
|
||||||
m_runVel=0;
|
m_runVel=0;
|
||||||
m_facing=-1;
|
setFacing(FACING_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
void CPlayer::shutdown()
|
void CPlayer::shutdown()
|
||||||
{
|
{
|
||||||
CThing::shutdown();
|
CThing::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
/*****************************************************************************/
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
void CPlayer::think(int _frames)
|
void CPlayer::think(int _frames)
|
||||||
{
|
{
|
||||||
CThing::think(_frames);
|
CThing::think(_frames);
|
||||||
@ -57,8 +111,7 @@ void CPlayer::think(int _frames)
|
|||||||
|
|
||||||
if(_frames>=3)_frames=2;
|
if(_frames>=3)_frames=2;
|
||||||
|
|
||||||
// PKG - Needs to come from somewhere local rather than direct from pad handler..
|
padInput=getPadInput();
|
||||||
padInput=PadGetHeld(0);
|
|
||||||
|
|
||||||
switch(m_state)
|
switch(m_state)
|
||||||
{
|
{
|
||||||
@ -67,13 +120,11 @@ if(_frames>=3)_frames=2;
|
|||||||
{
|
{
|
||||||
if(padInput&PAD_LEFT)
|
if(padInput&PAD_LEFT)
|
||||||
{
|
{
|
||||||
m_facing=FACING_LEFT;
|
setFacing(FACING_LEFT);
|
||||||
m_skel.setAng(512);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_facing=FACING_RIGHT;
|
setFacing(FACING_RIGHT);
|
||||||
m_skel.setAng(3096+512);
|
|
||||||
}
|
}
|
||||||
setState(STATE_RUNSTART);
|
setState(STATE_RUNSTART);
|
||||||
m_runVel=RUN_SPEEDUP;
|
m_runVel=RUN_SPEEDUP;
|
||||||
@ -101,8 +152,7 @@ if(_frames>=3)_frames=2;
|
|||||||
if(m_runVel<1)
|
if(m_runVel<1)
|
||||||
{
|
{
|
||||||
m_runVel=0;
|
m_runVel=0;
|
||||||
m_facing=FACING_RIGHT;
|
setFacing(FACING_RIGHT);
|
||||||
m_skel.setAng(3096+512);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,8 +173,7 @@ if(_frames>=3)_frames=2;
|
|||||||
if(m_runVel<1)
|
if(m_runVel<1)
|
||||||
{
|
{
|
||||||
m_runVel=0;
|
m_runVel=0;
|
||||||
m_facing=FACING_LEFT;
|
setFacing(FACING_LEFT);
|
||||||
m_skel.setAng(512);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,8 +230,12 @@ if(_frames>=3)_frames=2;
|
|||||||
if(Pos.vy<0)Pos.vy=0;
|
if(Pos.vy<0)Pos.vy=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
/*****************************************************************************/
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
void CPlayer::render()
|
void CPlayer::render()
|
||||||
{
|
{
|
||||||
CThing::render();
|
CThing::render();
|
||||||
@ -194,8 +247,12 @@ void CPlayer::render()
|
|||||||
m_skel.Render(this);
|
m_skel.Render(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
/*****************************************************************************/
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
int CPlayer::s_stateAnims[NUM_STATES]=
|
int CPlayer::s_stateAnims[NUM_STATES]=
|
||||||
{
|
{
|
||||||
ANIM_IDLE_SHORT, // STATE_IDLE
|
ANIM_IDLE_SHORT, // STATE_IDLE
|
||||||
@ -213,9 +270,36 @@ if(panim!=-1)m_animNo=panim;
|
|||||||
m_frame=0;
|
m_frame=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void CPlayer::setFacing(int _facing)
|
||||||
|
{
|
||||||
|
switch(_facing)
|
||||||
|
{
|
||||||
|
case FACING_LEFT:
|
||||||
|
m_facing=FACING_LEFT;
|
||||||
|
m_skel.setAng(512);
|
||||||
|
break;
|
||||||
|
case FACING_RIGHT:
|
||||||
|
m_facing=FACING_RIGHT;
|
||||||
|
m_skel.setAng(3096+512);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
/*****************************************************************************/
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
void CPlayer::finishedAnim()
|
void CPlayer::finishedAnim()
|
||||||
{
|
{
|
||||||
switch(m_state)
|
switch(m_state)
|
||||||
@ -239,6 +323,16 @@ void CPlayer::finishedAnim()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int CPlayer::getPadInput()
|
||||||
|
{
|
||||||
|
return PadGetHeld(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
||||||
|
@ -1,16 +1,46 @@
|
|||||||
/**************/
|
/*=========================================================================
|
||||||
/*** Player ***/
|
|
||||||
/**************/
|
player.h
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
#ifndef __PLAYER_PLAYER_H__
|
#ifndef __PLAYER_PLAYER_H__
|
||||||
#define __PLAYER_PLAYER_H__
|
#define __PLAYER_PLAYER_H__
|
||||||
|
|
||||||
#include <dstructs.h>
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#ifndef __GAME_THING_H__
|
||||||
#include "Game/Thing.h"
|
#include "Game/Thing.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SKEL_HEADER__
|
||||||
#include "Gfx/Skel.h"
|
#include "Gfx/Skel.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __DATA_STRUCTS_HEADER__
|
||||||
|
#include <dstructs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
class CPlayer : public CThing
|
class CPlayer : public CThing
|
||||||
{
|
{
|
||||||
@ -32,15 +62,6 @@ private:
|
|||||||
NUM_STATES,
|
NUM_STATES,
|
||||||
}PLAYER_STATE;
|
}PLAYER_STATE;
|
||||||
|
|
||||||
void setState(PLAYER_STATE _state);
|
|
||||||
void finishedAnim();
|
|
||||||
|
|
||||||
int m_frame;
|
|
||||||
int m_animNo;
|
|
||||||
PLAYER_STATE m_state;
|
|
||||||
CSkel m_skel;
|
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MAX_RUN_VELOCITY=8,
|
MAX_RUN_VELOCITY=8,
|
||||||
@ -48,13 +69,24 @@ private:
|
|||||||
RUN_REVERSESLOWDOWN=2,
|
RUN_REVERSESLOWDOWN=2,
|
||||||
RUN_SLOWDOWN=1,
|
RUN_SLOWDOWN=1,
|
||||||
};
|
};
|
||||||
int m_runVel;
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
FACING_LEFT=+1,
|
FACING_LEFT=+1,
|
||||||
FACING_RIGHT=-1,
|
FACING_RIGHT=-1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void setState(PLAYER_STATE _state);
|
||||||
|
void setFacing(int _facing);
|
||||||
|
void finishedAnim();
|
||||||
|
virtual int getPadInput();
|
||||||
|
|
||||||
|
int m_frame;
|
||||||
|
int m_animNo;
|
||||||
|
PLAYER_STATE m_state;
|
||||||
|
CSkel m_skel;
|
||||||
|
|
||||||
|
int m_runVel;
|
||||||
int m_facing;
|
int m_facing;
|
||||||
|
|
||||||
static int s_stateAnims[NUM_STATES];
|
static int s_stateAnims[NUM_STATES];
|
||||||
@ -62,5 +94,17 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*----------------------------------------------------------------------
|
||||||
#endif
|
Globals
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Functions
|
||||||
|
--------- */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __PLAYER_PLAYER_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
||||||
|
Loading…
Reference in New Issue
Block a user