SBSPSS/source/player/player.h

286 lines
5.6 KiB
C
Raw Normal View History

2001-01-16 20:27:14 +01:00
/*=========================================================================
player.h
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
2001-01-09 21:38:20 +01:00
2001-01-16 17:20:45 +01:00
#ifndef __PLAYER_PLAYER_H__
2001-01-16 20:27:14 +01:00
#define __PLAYER_PLAYER_H__
2001-01-09 21:38:20 +01:00
2001-01-16 20:27:14 +01:00
/*----------------------------------------------------------------------
Includes
-------- */
#ifndef __GAME_THING_H__
2001-02-02 18:19:51 +01:00
#include "game/thing.h"
2001-01-16 20:27:14 +01:00
#endif
2001-02-02 18:19:51 +01:00
#ifndef __GFX_SKELSPNG_H__
#include "gfx/skelspng.h"
2001-01-16 20:27:14 +01:00
#endif
2001-01-09 21:38:20 +01:00
2001-01-16 20:27:14 +01:00
#ifndef __DATA_STRUCTS_HEADER__
#include <dstructs.h>
#endif
2001-01-15 23:09:47 +01:00
2001-01-20 00:37:40 +01:00
#ifndef __PLAYER_PSTATES_H__
#include "player\pstates.h"
#endif
2001-02-01 18:01:12 +01:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
2001-01-16 20:27:14 +01:00
/* Std Lib
------- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
2001-01-20 00:37:40 +01:00
typedef enum
{
STATE_IDLE,
2001-02-06 18:15:28 +01:00
STATE_IDLETEETER,
2001-01-20 00:37:40 +01:00
STATE_JUMP,
STATE_RUN,
STATE_FALL,
STATE_FALLFAR,
2001-01-22 22:02:59 +01:00
STATE_BUTTBOUNCE,
STATE_BUTTFALL,
STATE_BUTTLAND,
2001-01-25 16:25:46 +01:00
STATE_ATTACK,
STATE_RUNATTACK,
STATE_AIRATTACK,
2001-01-22 22:02:59 +01:00
STATE_DUCK,
STATE_SOAKUP,
STATE_GETUP,
2001-02-06 22:09:45 +01:00
STATE_DEAD,
2001-01-20 00:37:40 +01:00
NUM_STATES,
}PLAYER_STATE;
2001-01-26 19:20:41 +01:00
typedef enum
{
PLAYER_MODE_BASICUNARMED,
PLAYER_MODE_FULLUNARMED,
2001-02-08 17:51:16 +01:00
PLAYER_MODE_SQUEAKYBOOTS,
2001-02-09 20:26:57 +01:00
PLAYER_MODE_NET,
2001-01-29 23:35:18 +01:00
PLAYER_MODE_CORALBLOWER,
2001-01-26 19:20:41 +01:00
NUM_PLAYERMODES,
}PLAYER_MODE;
2001-01-20 00:37:40 +01:00
enum
{
FACING_LEFT=+1,
FACING_RIGHT=-1,
};
2001-01-22 22:02:59 +01:00
typedef enum
{
PM__JUMP_VELOCITY,
PM__MAX_JUMP_FRAMES,
PM__MAX_SAFE_FALL_FRAMES,
PM__MAX_RUN_VELOCITY,
PM__RUN_SPEEDUP,
PM__RUN_REVERSESLOWDOWN,
PM__RUN_SLOWDOWN,
NUM_PLAYER_METRICS
}PLAYER_METRIC;
2001-01-20 00:37:40 +01:00
2001-02-06 22:09:45 +01:00
typedef enum
{
DAMAGE__FALL,
DAMAGE__ELECTROCUTION,
DAMAGE__LAVA,
}DAMAGE_TYPE;
2001-01-20 00:37:40 +01:00
2001-02-09 18:01:04 +01:00
// The input from the control pad is remapped to this rather than keeping it in the
// normal pad format. This allows us to store all input in one byte ( as opposed to
// two bytes ) for demo recording and means that the player state codes don't have
// to keep using CPadConfig to remap the controls internally.
typedef enum
{
PI_NONE =0,
PI_UP =1<<0,
PI_DOWN =1<<1,
PI_LEFT =1<<2,
PI_RIGHT =1<<3,
PI_JUMP =1<<4,
PI_ACTION =1<<5,
}PLAYERINPUT;
2001-01-16 20:27:14 +01:00
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
2001-01-12 23:40:39 +01:00
2001-01-22 22:02:59 +01:00
struct PlayerMetrics
{
s16 m_metric[NUM_PLAYER_METRICS];
};
2001-01-20 00:37:40 +01:00
class CPlayer : public CThing
2001-01-09 21:38:20 +01:00
{
public:
2001-01-22 22:02:59 +01:00
enum
2001-01-20 00:37:40 +01:00
{
2001-01-22 22:02:59 +01:00
VELOCITY_SHIFT=2
};
2001-01-20 00:37:40 +01:00
2001-02-09 18:01:04 +01:00
virtual void init();
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
2001-01-15 23:09:47 +01:00
2001-01-25 16:25:46 +01:00
DVECTOR getCameraPos();
2001-02-06 18:15:28 +01:00
void setLayerCollision(class CLayerCollision *_layer) {m_layerCollision=_layer;}
2001-02-12 16:26:00 +01:00
void setMapSize(DVECTOR _mapSize);
2001-02-06 18:15:28 +01:00
2001-01-20 00:37:40 +01:00
protected:
2001-01-31 21:16:34 +01:00
enum
{
2001-02-06 18:15:28 +01:00
DEFAULT_PLAYER_JUMP_VELOCITY=4,
DEFAULT_PLAYER_MAX_JUMP_FRAMES=12,
2001-01-31 21:16:34 +01:00
DEFAULT_PLAYER_MAX_SAFE_FALL_FRAMES=20,
DEFAULT_PLAYER_MAX_RUN_VELOCITY=8,
DEFAULT_PLAYER_RUN_SPEEDUP=4,
DEFAULT_PLAYER_RUN_REVERSESLOWDOWN=2,
DEFAULT_PLAYER_RUN_SLOWDOWN=1,
PLAYER_GRAVITY=4,
PLAYER_TERMINAL_VELOCITY=8,
};
2001-01-22 23:58:12 +01:00
const PlayerMetrics *getPlayerMetrics();
2001-01-16 20:27:14 +01:00
2001-01-25 23:19:47 +01:00
// State
2001-01-31 23:50:59 +01:00
int setState(PLAYER_STATE _state);
2001-01-26 19:20:41 +01:00
void setMode(PLAYER_MODE _mode);
2001-01-20 00:37:40 +01:00
int getFacing();
2001-01-16 20:27:14 +01:00
void setFacing(int _facing);
2001-01-20 00:37:40 +01:00
int getAnimFrame();
void setAnimFrame(int _animFrame);
int getAnimFrameCount();
int getAnimNo();
void setAnimNo(int _animNo);
DVECTOR getMoveVelocity();
void setMoveVelocity(DVECTOR *_moveVel);
2001-01-26 19:20:41 +01:00
DVECTOR getPlayerPos();
2001-02-09 18:01:04 +01:00
PLAYERINPUT getPadInputHeld();
PLAYERINPUT getPadInputDown();
2001-01-16 20:27:14 +01:00
2001-01-25 23:19:47 +01:00
// Collision
2001-01-20 00:37:40 +01:00
int isOnSolidGround();
2001-02-06 18:15:28 +01:00
int isOnEdge();
int canMoveLeft();
int canMoveRight();
2001-01-20 00:37:40 +01:00
2001-01-25 23:19:47 +01:00
// Movement
2001-01-20 00:37:40 +01:00
void moveLeft();
void moveRight();
void slowdown();
void jump();
void fall();
2001-02-12 18:55:01 +01:00
void respawn();
2001-02-06 22:09:45 +01:00
void takeDamage(DAMAGE_TYPE _damage);
2001-01-20 00:37:40 +01:00
friend class CPlayerState;
private:
2001-01-25 16:25:46 +01:00
typedef struct
{
PlayerMetrics m_metrics;
class CPlayerState *m_states[NUM_STATES];
}PlayerMode;
2001-02-01 18:01:12 +01:00
public:
typedef struct
{
int m_frame;
CSoundMediator::SFXID m_sfxId;
} AnimFrameSfx;
private:
typedef struct
{
2001-02-01 18:32:16 +01:00
int m_numAnimFrameSfx;
const struct AnimFrameSfx *m_animFrameSfx;
2001-02-01 18:01:12 +01:00
} AnimSfx;
2001-02-01 18:32:16 +01:00
static const AnimSfx s_animSfx[];
2001-01-20 00:37:40 +01:00
int m_animFrame;
2001-01-16 20:27:14 +01:00
int m_animNo;
2001-02-02 18:19:51 +01:00
CSkelSpongeBob m_skel;
2001-01-16 20:27:14 +01:00
2001-01-20 00:37:40 +01:00
DVECTOR m_moveVel;
2001-01-15 23:09:47 +01:00
int m_facing;
2001-01-25 16:25:46 +01:00
int m_fallFrames;
2001-01-15 23:09:47 +01:00
2001-01-22 23:58:12 +01:00
enum
{
INVIBCIBLE_FRAMES__START=120, // Invincible for this many frames at start of life
2001-02-06 22:09:45 +01:00
INVINCIBLE_FRAMES__HIT=50, // Invincible for this many frames after taking damage
2001-01-31 22:05:12 +01:00
LOOKAROUND_DELAY=90, // Frames before look around starts
LOOKAROUND_SCROLLSPEED=2, // Speed to scroll at
LOOKAROUND_MAXSCROLL=60, // Maximum distance to scroll
LOOKAROUND_RESETSPEED=6, // Speed of scroll back when look around ended
2001-01-22 23:58:12 +01:00
};
int m_invincibleFrameCount;
2001-01-26 19:20:41 +01:00
static PlayerMode s_modes[NUM_PLAYERMODES];
int m_currentMode;
class CPlayerState *m_currentStateClass;
PLAYER_STATE m_currentState;
2001-01-22 23:58:12 +01:00
int m_lives;
2001-01-25 16:25:46 +01:00
DVECTOR m_cameraOffset;
2001-01-29 23:35:18 +01:00
void updatePadInput();
2001-02-09 18:01:04 +01:00
protected:
virtual PLAYERINPUT readPadInput();
private:
PLAYERINPUT m_padInput; // Controls that are being held down
PLAYERINPUT m_lastPadInput; // Last frames controls
PLAYERINPUT m_padInputDown; // Controls that were pressed this frame
2001-01-29 23:35:18 +01:00
2001-02-09 18:01:04 +01:00
2001-02-12 16:26:00 +01:00
// Various info about the current map
2001-02-06 18:15:28 +01:00
class CLayerCollision *m_layerCollision;
2001-02-12 16:26:00 +01:00
DVECTOR m_mapCameraEdges;
2001-02-12 18:55:01 +01:00
DVECTOR m_respawnPos;
2001-01-09 21:38:20 +01:00
};
2001-01-15 23:09:47 +01:00
2001-01-16 20:27:14 +01:00
/*----------------------------------------------------------------------
Globals
------- */
/*----------------------------------------------------------------------
Functions
--------- */
/*---------------------------------------------------------------------- */
#endif /* __PLAYER_PLAYER_H__ */
/*===========================================================================
end */