SBSPSS/source/player/player.h

383 lines
8.5 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
-------- */
2001-02-27 17:59:50 +01:00
#ifndef __THING_THING_H__
#include "thing/thing.h"
2001-01-16 20:27:14 +01:00
#endif
2001-04-01 22:22:49 +02:00
#include "gfx/actor.h"
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-02-27 23:06:24 +01:00
typedef enum
{
PLAYER_MODE_BASICUNARMED,
2001-03-25 23:33:20 +02:00
PLAYER_MODE_FULLUNARMED,
2001-03-25 22:36:28 +02:00
PLAYER_MODE_BALLOON,
2001-03-30 19:47:00 +02:00
PLAYER_MODE_BUBBLE_MIXTURE,
2001-03-31 20:22:38 +02:00
PLAYER_MODE_NET,
2001-03-30 19:47:00 +02:00
PLAYER_MODE_CORALBLOWER,
2001-04-03 23:36:35 +02:00
PLAYER_MODE_JELLY_LAUNCHER,
2001-03-02 17:02:30 +01:00
2001-03-25 23:33:20 +02:00
PLAYER_MODE_DEAD,
2001-02-27 23:06:24 +01:00
PLAYER_MODE_FLY,
NUM_PLAYERMODES,
}PLAYER_MODE;
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,
2001-05-01 20:39:41 +02:00
STATE_SPRINGUP,
2001-01-20 00:37:40 +01:00
STATE_RUN,
STATE_FALL,
STATE_FALLFAR,
2001-04-04 17:40:38 +02:00
STATE_HITGROUND,
2001-01-22 22:02:59 +01:00
STATE_BUTTBOUNCE,
STATE_BUTTFALL,
STATE_BUTTLAND,
STATE_DUCK,
STATE_SOAKUP,
STATE_GETUP,
2001-02-06 22:09:45 +01:00
2001-01-20 00:37:40 +01:00
NUM_STATES,
}PLAYER_STATE;
2001-04-30 23:27:46 +02:00
typedef enum
{
PLAYER_ADDON_NET,
PLAYER_ADDON_CORALBLOWER,
PLAYER_ADDON_JELLYLAUNCHER,
PLAYER_ADDON_GLASSES,
PLAYER_ADDON_BUBBLEWAND,
NUM_PLAYER_ADDONS,
NO_ADDON,
}PLAYER_ADDONS;
2001-01-20 00:37:40 +01:00
enum
{
FACING_LEFT=+1,
FACING_RIGHT=-1,
};
2001-02-06 22:09:45 +01:00
typedef enum
{
2001-03-05 22:11:51 +01:00
DAMAGE__NONE, // put in so that an item can push the user but not damage them
2001-02-06 22:09:45 +01:00
DAMAGE__FALL,
DAMAGE__ELECTROCUTION,
DAMAGE__LAVA,
2001-02-27 17:59:50 +01:00
DAMAGE__HIT_ENEMY,
2001-03-05 22:11:51 +01:00
DAMAGE__SHOCK_ENEMY,
DAMAGE__GAS_ENEMY,
DAMAGE__POISON_ENEMY,
DAMAGE__SWALLOW_ENEMY,
DAMAGE__PINCH_ENEMY,
DAMAGE__SQUASH_ENEMY,
DAMAGE__BURN_ENEMY,
DAMAGE__BITE_ENEMY,
2001-02-06 22:09:45 +01:00
}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-04-12 20:48:33 +02:00
// For getAttackState()
typedef enum
{
ATTACK_STATE__NONE,
ATTACK_STATE__KARATE,
ATTACK_STATE__BUTT_BOUNCE,
} ATTACK_STATE;
2001-01-16 20:27:14 +01:00
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
2001-01-12 23:40:39 +01:00
2001-02-26 21:42:25 +01:00
class CPlayer : public CPlayerThing
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-03-23 21:09:14 +01:00
MAX_HEALTH=5,
MAX_LIVES=99,
2001-01-22 22:02:59 +01:00
};
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-04-11 22:59:16 +02:00
virtual void shove(DVECTOR move);
2001-04-25 20:38:33 +02:00
virtual int moveVertical(int _moveDistance);
virtual int moveHorizontal(int _moveDistance);
2001-03-31 00:43:35 +02:00
virtual void setHasPlatformCollided( bool newVal );
virtual bool getHasPlatformCollided();
2001-01-15 23:09:47 +01:00
2001-05-01 23:43:14 +02:00
int isTryingToConversateWithFriend() {return m_allowConversation;}
2001-03-23 21:09:14 +01:00
DVECTOR getCameraPos() {return m_cameraPos;}
2001-01-25 16:25:46 +01:00
2001-03-23 21:09:14 +01:00
void setLayerCollision(class CLayerCollision *_layer) {m_layerCollision=_layer;}
2001-02-12 16:26:00 +01:00
void setMapSize(DVECTOR _mapSize);
2001-03-23 21:09:14 +01:00
void setRespawnPos(DVECTOR _respawn) {m_respawnPos=_respawn;}
2001-02-06 18:15:28 +01:00
2001-03-29 21:19:33 +02:00
int getHeightFromGround(int _x,int _y,int _maxHeight=32);
2001-04-07 21:52:45 +02:00
int getHeightFromGroundNoPlatform(int _x,int _y,int _maxHeight=32);
2001-03-29 21:19:33 +02:00
2001-04-17 22:09:33 +02:00
void setLedgeLookAhead(int _lookAhead) {m_ledgeLookAhead=_lookAhead;}
2001-03-01 21:30:25 +01:00
void addHealth(int _health);
void addLife();
2001-04-12 20:48:33 +02:00
ATTACK_STATE getAttackState();
2001-04-20 23:29:14 +02:00
int isRecoveringFromHit() {return m_invincibleFrameCount!=0||m_currentMode==PLAYER_MODE_DEAD;}
2001-03-01 21:30:25 +01:00
2001-04-30 23:27:46 +02:00
void registerAddon(PLAYER_ADDONS _addon);
2001-05-01 18:26:31 +02:00
DVECTOR *getMoveVelocity() {return &m_moveVelocity;}
void setMoveVelocity(const DVECTOR *_moveVelocity) {m_moveVelocity=*_moveVelocity;}
2001-04-30 23:27:46 +02:00
2001-02-27 23:06:24 +01:00
public:
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);
2001-05-01 20:39:41 +02:00
void springPlayerUp();
2001-04-19 01:37:52 +02:00
private:
void playAnimFrameSfx(int _animNo,int _animFrame);
2001-05-01 18:26:31 +02:00
DVECTOR m_moveVelocity;
2001-05-01 23:43:14 +02:00
int m_allowConversation;
2001-05-01 18:26:31 +02:00
2001-04-19 01:37:52 +02:00
public:
2001-03-23 21:09:14 +01:00
DVECTOR getPlayerPos() {return Pos;}
void setPlayerPos(DVECTOR *_pos) {Pos=*_pos;}
PLAYERINPUT getPadInputHeld() {return m_padInput;}
PLAYERINPUT getPadInputDown() {return m_padInputDown;}
class CLayerCollision *getLayerCollision() {return m_layerCollision;}
2001-02-06 22:09:45 +01:00
void takeDamage(DAMAGE_TYPE _damage);
2001-03-23 21:09:14 +01:00
void respawn();
2001-01-25 16:25:46 +01:00
2001-02-01 18:01:12 +01:00
public:
typedef struct
{
int m_frame;
CSoundMediator::SFXID m_sfxId;
} AnimFrameSfx;
2001-04-05 18:26:17 +02:00
void renderSb(DVECTOR *_pos,int _animNo,int _animFrame);
2001-04-18 18:35:26 +02:00
int canDoLookAround();
2001-02-01 18:01:12 +01:00
private:
typedef struct
{
2001-04-19 01:37:52 +02:00
int m_animNumber;
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-04-19 01:37:52 +02:00
static const int s_numAnimSfx;
2001-01-20 00:37:40 +01:00
int m_animFrame;
2001-01-16 20:27:14 +01:00
int m_animNo;
2001-04-01 22:22:49 +02:00
CActorGfx *m_actorGfx;
2001-01-16 20:27:14 +01:00
2001-02-14 21:28:57 +01:00
DVECTOR m_cameraPos;
2001-04-12 00:37:57 +02:00
DVECTOR m_currentCamFocusPointTarget;
DVECTOR m_currentCamFocusPoint;
2001-01-15 23:09:47 +01:00
int m_facing;
2001-04-12 00:37:57 +02:00
int m_padLookAroundTimer;
2001-04-17 22:09:33 +02:00
int m_ledgeLookAhead,m_lastLedgeLookAhead;
int m_ledgeLookOffset;
int m_ledgeLookTimer;
2001-05-01 18:51:01 +02:00
int m_leftRightScrollPosition;
2001-04-12 00:37:57 +02:00
2001-01-15 23:09:47 +01:00
2001-01-22 23:58:12 +01:00
enum
{
2001-04-19 01:49:41 +02:00
INVINCIBLE_FRAMES__START=200, // Invincible for this many frames at start of life
INVINCIBLE_FRAMES__HIT=100, // Invincible for this many frames after taking damage
2001-01-22 23:58:12 +01:00
};
2001-03-02 17:02:30 +01:00
int m_invincibleFrameCount; // Initial invincibility and also invincibility after taking damage
2001-01-22 23:58:12 +01:00
2001-03-23 21:09:14 +01:00
static class CPlayerMode *s_playerModes[NUM_PLAYERMODES];
class CPlayerMode *m_currentPlayerModeClass;
int m_currentMode;
2001-01-22 23:58:12 +01:00
int m_lives;
2001-04-06 20:50:47 +02:00
int m_health;
int m_healthReactFrames;
2001-01-22 23:58:12 +01:00
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 21:14:31 +01:00
DVECTOR m_mapEdge;
2001-02-12 18:55:01 +01:00
DVECTOR m_respawnPos;
2001-02-26 21:42:25 +01:00
2001-03-02 17:02:30 +01:00
// Powerups
private:
enum
{
SQUEAKY_BOOTS_TIME=60*10,
INVINCIBILITY_RING_TIME=60*10,
};
public:
void giveGlasses() {m_glassesFlag=true;}
2001-04-18 21:32:26 +02:00
int isWearingGlasses() {return m_glassesFlag;}
2001-03-02 17:02:30 +01:00
void giveSqueakyBoots() {m_squeakyBootsTimer=SQUEAKY_BOOTS_TIME;}
2001-04-18 22:31:14 +02:00
int isWearingBoots() {return m_squeakyBootsTimer;}
2001-04-25 20:38:33 +02:00
void giveInvincibilityRing() {m_invincibilityRingTimer=INVINCIBILITY_RING_TIME;}
2001-03-29 23:30:34 +02:00
void giveDivingHelmet() {m_divingHelmet=true;}
2001-03-31 04:05:24 +02:00
2001-03-31 20:22:38 +02:00
void giveBubbleAmmo() {m_bubbleAmmo+=10;if(m_bubbleAmmo>99)m_bubbleAmmo=99;}
2001-03-31 04:05:24 +02:00
void useOneBubble() {m_bubbleAmmo--;}
int getBubbleAmmo() {return m_bubbleAmmo;}
2001-04-08 20:57:16 +02:00
void giveJellyAmmo() {m_jellyAmmo+=6;if(m_jellyAmmo>99)m_jellyAmmo=99;}
void useOneJelly() {m_jellyAmmo--;}
int getJellyAmmo() {return m_jellyAmmo;}
2001-03-02 17:02:30 +01:00
private:
int m_glassesFlag;
int m_squeakyBootsTimer;
2001-04-25 20:38:33 +02:00
int m_invincibilityRingTimer;
2001-03-29 23:30:34 +02:00
int m_divingHelmet;
2001-03-31 04:05:24 +02:00
int m_bubbleAmmo;
2001-04-08 20:57:16 +02:00
int m_jellyAmmo;
2001-03-06 21:13:16 +01:00
// Platforms
public:
2001-03-29 21:19:33 +02:00
void setPlatform(CThing *_newPlatform);
void clearPlatform();
CThing *isOnPlatform() {return m_platform;}
private:
CThing *m_platform;
2001-03-23 21:09:14 +01:00
2001-03-31 00:43:35 +02:00
private:
bool m_hasPlatformCollided;
2001-03-31 20:22:38 +02:00
2001-04-18 18:35:26 +02:00
// Player collision size
public:
enum
{
COLSIZE_BASE_WIDTH=30,
COLSIZE_BASE_HEIGHT=60,
};
void resetPlayerCollisionSizeToBase();
void setPlayerCollisionSize(int _x,int _y,int _w,int _h);
2001-05-01 22:23:32 +02:00
void getPlayerCollisionSize(int *_x,int *_y,int *_w,int *_h);
2001-04-18 18:35:26 +02:00
2001-03-31 20:22:38 +02:00
// Graphical resources
public:
class FontBank *getFontBank() {return m_fontBank;}
class SpriteBank *getSpriteBank() {return m_spriteBank;}
enum
{
POWERUPUI_ICONX=40,
POWERUPUI_ICONY=200,
POWERUPUI_TEXTX=60,
POWERUPUI_TEXTY=200,
2001-05-02 01:27:30 +02:00
POWERUPUI_OT=0,
2001-03-31 20:22:38 +02:00
};
private:
class FontBank *m_fontBank;
class SpriteBank *m_spriteBank;
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 */