1 2 /** 3 * 4 * @file player.h 5 * 6 * Part of the OpenJazz project 7 * 8 * @par History: 9 * - 23rd August 2005: Created OpenJazz.h 10 * - 31st January 2006: Created player.h from parts of OpenJazz.h 11 * - 24th June 2010: Created levelplayer.h from parts of player.h 12 * - 24th June 2010: Created bonusplayer.h from parts of player.h 13 * 14 * @par Licence: 15 * Copyright (c) 2005-2013 Alister Thomson 16 * 17 * OpenJazz is distributed under the terms of 18 * the GNU General Public License, version 2.0 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 * 24 */ 25 26 27 /* "Tile" is a flexible term. Here it is used to refer specifically to the 28 individual elements of the tile set. 29 "Tiles" in the context of level units are referred to as grid elements. */ 30 31 32 #ifndef _PLAYER_H 33 #define _PLAYER_H 34 35 36 #include "level/level.h" 37 38 39 // Constants 40 41 // Player defaults 42 #define CHAR_NAME "jazz" 43 #define CHAR_FUR 4 44 #define CHAR_BAND 3 45 #define CHAR_GUN 2 46 #define CHAR_WBAND 8 47 48 // General 49 #define PCONTROLS 8 /* Number of player controls. */ 50 51 // Number of configurable player colour ranges 52 #define PCOLOURS 4 53 54 55 // Enums 56 57 /// Player colours 58 enum PlayerColour { 59 60 PC_GREY = 0, 61 PC_SGREEN = 1, 62 PC_BLUE = 2, 63 PC_RED = 3, 64 PC_LGREEN = 4, 65 PC_LEVEL1 = 5, 66 PC_YELLOW = 6, 67 PC_LEVEL2 = 7, 68 PC_ORANGE = 8, 69 PC_LEVEL3 = 9, 70 PC_LEVEL4 = 10, 71 PC_SANIM = 11, 72 PC_LANIM = 12, 73 PC_LEVEL5 = 13 74 75 }; 76 77 78 // Classes 79 80 class Anim; 81 class JJ1LevelPlayer; 82 class JJ1BonusLevelPlayer; 83 class JJ2LevelPlayer; 84 class LevelPlayer; 85 86 /// Game player 87 class Player { 88 89 private: 90 Game* game; 91 LevelPlayer* levelPlayer; ///< Level player base class 92 93 char* name; ///< Name 94 bool pcontrols[PCONTROLS]; ///< Control status 95 unsigned char cols[PCOLOURS]; ///< Character colours 96 int ammo[5]; ///< Amount of ammo 97 int ammoType; ///< Ammo type. -1 = blaster, 0 = toaster, 1 = missiles, 2 = bouncer, 3 = unknown, 4 = TNT 98 int score; ///< Total score 99 int lives; ///< Remaining lives 100 int fireSpeed; ///< Rapid-fire rate 101 int flockSize; ///< Number of accompanying birds 102 unsigned char team; ///< Team ID 103 104 void addAmmo (int type, int amount); 105 106 public: 107 int teamScore; ///< Team's total score 108 109 Player (); 110 ~Player (); 111 112 void init (Game* owner, char* playerName, unsigned char* cols, unsigned char newTeam); 113 void deinit (); 114 void clearAmmo (); 115 void reset (int x, int y); 116 117 void createLevelPlayer (LevelType levelType, Anim** anims, Anim** flippedAnims, unsigned char x, unsigned char y); 118 LevelPlayer* getLevelPlayer (); 119 JJ1BonusLevelPlayer* getJJ1BonusLevelPlayer (); 120 JJ1LevelPlayer* getJJ1LevelPlayer (); 121 JJ2LevelPlayer* getJJ2LevelPlayer (); 122 123 void addLife (); 124 void addScore (int addedScore); 125 bool endOfLevel (int gridX, int gridY); 126 int getAmmoType (); 127 int getAmmo (); 128 unsigned char* getCols (); 129 bool getControl (int control); 130 int getLives (); 131 char* getName (); 132 int getScore (); 133 unsigned char getTeam (); 134 bool hit (Player* source); 135 bool kill (Player* source); 136 void setCheckpoint (int gridX, int gridY); 137 void setControl (int control, bool state); 138 139 void send (unsigned char* buffer); 140 void receive (unsigned char* buffer); 141 142 friend class JJ1LevelPlayer; 143 friend class JJ2LevelPlayer; 144 145 }; 146 147 148 // Variables 149 150 EXTERN Player* players; 151 EXTERN Player* localPlayer; 152 EXTERN int nPlayers; 153 154 #endif 155 156