Labyrinth of the Minotaur A simple roguelike/RPG using a nokia 5110 screen

Dependencies:   N5110 PowerControl mbed

Committer:
ThomasBGill
Date:
Mon May 11 22:29:04 2015 +0000
Revision:
37:a0ea57af9279
Parent:
35:2c290fa78f1d
Fixed error

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThomasBGill 33:4fc26476b2e0 1 /**
ThomasBGill 35:2c290fa78f1d 2 * @file Game.h
ThomasBGill 35:2c290fa78f1d 3 * @brief Header file containing the main game member functions and variables
ThomasBGill 35:2c290fa78f1d 4 * @brief Revision 1.0
ThomasBGill 35:2c290fa78f1d 5 *
ThomasBGill 35:2c290fa78f1d 6 * @brief Code for reading joystick by Craig Evans https://developer.mbed.org/users/eencae/code/Joystick/file/026fa541af7a/main.cpp
ThomasBGill 35:2c290fa78f1d 7 * @author Thomas Barnaby Gill
ThomasBGill 35:2c290fa78f1d 8 * @date 11th May 2015
ThomasBGill 33:4fc26476b2e0 9 */
ThomasBGill 33:4fc26476b2e0 10
ThomasBGill 26:0dd71fc0ede4 11 #include "N5110.h"
ThomasBGill 26:0dd71fc0ede4 12 #include "PowerControl/PowerControl.h"
ThomasBGill 26:0dd71fc0ede4 13 #include "PowerControl/EthernetPowerControl.h"
ThomasBGill 26:0dd71fc0ede4 14 #include "WorldBuilder.h"
ThomasBGill 26:0dd71fc0ede4 15 #include "Graphics.h"
ThomasBGill 26:0dd71fc0ede4 16
ThomasBGill 33:4fc26476b2e0 17 //vcc sce rst dc mosi clk led
ThomasBGill 31:5b4a4d225ab4 18 N5110 lcd(p7, p8, p9, p10, p11, p13, p26);
ThomasBGill 31:5b4a4d225ab4 19 InterruptIn Act(p27);
ThomasBGill 31:5b4a4d225ab4 20 InterruptIn Start(p28);
ThomasBGill 26:0dd71fc0ede4 21 AnalogIn Noise(p19);
ThomasBGill 31:5b4a4d225ab4 22 AnalogIn xPot(p15);
ThomasBGill 31:5b4a4d225ab4 23 AnalogIn yPot(p16);
ThomasBGill 31:5b4a4d225ab4 24
ThomasBGill 32:99ca304085e6 25 #define PH_MAX 20
ThomasBGill 32:99ca304085e6 26
ThomasBGill 31:5b4a4d225ab4 27 //Joystick stuff
ThomasBGill 31:5b4a4d225ab4 28 // timer to regularly read the joystick
ThomasBGill 31:5b4a4d225ab4 29 Ticker pollJoystick;
ThomasBGill 31:5b4a4d225ab4 30
ThomasBGill 31:5b4a4d225ab4 31 // change this to alter tolerance of joystick direction
ThomasBGill 31:5b4a4d225ab4 32 #define DIRECTION_TOLERANCE 0.05
ThomasBGill 31:5b4a4d225ab4 33
ThomasBGill 31:5b4a4d225ab4 34 // create enumerated type (0,1,2,3 etc. for direction)
ThomasBGill 31:5b4a4d225ab4 35 // could be extended for diagonals etc.
ThomasBGill 31:5b4a4d225ab4 36 enum DirectionName {
ThomasBGill 31:5b4a4d225ab4 37 Up,
ThomasBGill 31:5b4a4d225ab4 38 Down,
ThomasBGill 31:5b4a4d225ab4 39 Left,
ThomasBGill 31:5b4a4d225ab4 40 Right,
ThomasBGill 31:5b4a4d225ab4 41 Centre,
ThomasBGill 31:5b4a4d225ab4 42 Unknown
ThomasBGill 31:5b4a4d225ab4 43 };
ThomasBGill 35:2c290fa78f1d 44
ThomasBGill 35:2c290fa78f1d 45 /** Joystick Structure
ThomasBGill 35:2c290fa78f1d 46 *
ThomasBGill 35:2c290fa78f1d 47 * It includes the x, x0, y, y0 and direction members
ThomasBGill 35:2c290fa78f1d 48 * @param x - current x direction potentiometer value
ThomasBGill 35:2c290fa78f1d 49 * @param x0 - centred x direction potentiometer value
ThomasBGill 35:2c290fa78f1d 50 * @param y - current y direction potentiometer value
ThomasBGill 35:2c290fa78f1d 51 * @param y0 - centred y direction potentiometer value
ThomasBGill 35:2c290fa78f1d 52 * @param direction - allowed direction values
ThomasBGill 35:2c290fa78f1d 53 */
ThomasBGill 31:5b4a4d225ab4 54 typedef struct JoyStick Joystick;
ThomasBGill 31:5b4a4d225ab4 55 struct JoyStick {
ThomasBGill 31:5b4a4d225ab4 56 float x; // current x value
ThomasBGill 31:5b4a4d225ab4 57 float x0; // 'centred' x value
ThomasBGill 31:5b4a4d225ab4 58 float y; // current y value
ThomasBGill 31:5b4a4d225ab4 59 float y0; // 'centred' y value
ThomasBGill 31:5b4a4d225ab4 60 DirectionName direction; // current direction
ThomasBGill 31:5b4a4d225ab4 61 };
ThomasBGill 31:5b4a4d225ab4 62 // create struct variable
ThomasBGill 31:5b4a4d225ab4 63 Joystick joystick;
ThomasBGill 31:5b4a4d225ab4 64
ThomasBGill 35:2c290fa78f1d 65 /** Calibrate Joystick
ThomasBGill 35:2c290fa78f1d 66 *
ThomasBGill 35:2c290fa78f1d 67 * Reads defualt position of joystick for further readings
ThomasBGill 35:2c290fa78f1d 68 *
ThomasBGill 35:2c290fa78f1d 69 */
ThomasBGill 31:5b4a4d225ab4 70 void calibrateJoystick();
ThomasBGill 35:2c290fa78f1d 71
ThomasBGill 35:2c290fa78f1d 72 /** Update Joystick
ThomasBGill 35:2c290fa78f1d 73 *
ThomasBGill 35:2c290fa78f1d 74 * Reads cuurent position of joystick relative to the defualt position
ThomasBGill 35:2c290fa78f1d 75 *
ThomasBGill 35:2c290fa78f1d 76 */
ThomasBGill 31:5b4a4d225ab4 77 void updateJoystick();
ThomasBGill 26:0dd71fc0ede4 78
ThomasBGill 26:0dd71fc0ede4 79 #define USR_POWERDOWN (0x104)
ThomasBGill 26:0dd71fc0ede4 80
ThomasBGill 26:0dd71fc0ede4 81 LocalFileSystem local("local"); // create local filesystem
ThomasBGill 26:0dd71fc0ede4 82
ThomasBGill 35:2c290fa78f1d 83 /** Tile Structure
ThomasBGill 35:2c290fa78f1d 84 *
ThomasBGill 35:2c290fa78f1d 85 * It includes the symbol and passable members
ThomasBGill 35:2c290fa78f1d 86 * @param Symbol - contains the tile symbols for each tile type
ThomasBGill 35:2c290fa78f1d 87 * @param Passable - whether tile type can be walked on by player
ThomasBGill 35:2c290fa78f1d 88 */
ThomasBGill 26:0dd71fc0ede4 89 struct TILES {
ThomasBGill 26:0dd71fc0ede4 90 char Symbol; // Symbol for this tile
ThomasBGill 26:0dd71fc0ede4 91 bool Passable; // Can tile be walked on
ThomasBGill 26:0dd71fc0ede4 92 };
ThomasBGill 26:0dd71fc0ede4 93
ThomasBGill 26:0dd71fc0ede4 94 TILES TileList[] = {
ThomasBGill 26:0dd71fc0ede4 95 { '#', false }, // 0- WALL
ThomasBGill 26:0dd71fc0ede4 96 { '.', true }, // 1- FLOOR
ThomasBGill 26:0dd71fc0ede4 97 { '+', true }, // 2- ENTER
ThomasBGill 26:0dd71fc0ede4 98 { 'x', true }, // 3- EXIT
ThomasBGill 26:0dd71fc0ede4 99 { '.', true }, // 4- FLOOR_SEEN
ThomasBGill 26:0dd71fc0ede4 100 { '=', true }, // 5- CHEST
ThomasBGill 26:0dd71fc0ede4 101 { '/', true }, // 6- CHEST_OPENED
ThomasBGill 26:0dd71fc0ede4 102 };
ThomasBGill 26:0dd71fc0ede4 103
ThomasBGill 35:2c290fa78f1d 104 /** Item Structure
ThomasBGill 35:2c290fa78f1d 105 *
ThomasBGill 35:2c290fa78f1d 106 * It includes the ItemName and the ItemValue members
ThomasBGill 35:2c290fa78f1d 107 * @param ItemName - contains the name of the item as a char array
ThomasBGill 35:2c290fa78f1d 108 * @param ItemValue - contains damage/armour value of the item
ThomasBGill 35:2c290fa78f1d 109 */
ThomasBGill 26:0dd71fc0ede4 110 struct ITEMS {
ThomasBGill 26:0dd71fc0ede4 111 char ItemName[15]; //Item name
ThomasBGill 26:0dd71fc0ede4 112 int ItemValue; //Damage/ armour value
ThomasBGill 26:0dd71fc0ede4 113 };
ThomasBGill 26:0dd71fc0ede4 114
ThomasBGill 26:0dd71fc0ede4 115 ITEMS ItemList[] = {
ThomasBGill 26:0dd71fc0ede4 116 //Weapons
ThomasBGill 26:0dd71fc0ede4 117 { "Dagger", 4 }, //0
ThomasBGill 26:0dd71fc0ede4 118 { "Axe", 5 }, //1
ThomasBGill 26:0dd71fc0ede4 119 { "Mace", 6 }, //2
ThomasBGill 26:0dd71fc0ede4 120 { "Sword", 7 }, //3
ThomasBGill 26:0dd71fc0ede4 121 { "Warhammer", 8 }, //4
ThomasBGill 26:0dd71fc0ede4 122 //Armour
ThomasBGill 30:4a03611a3d99 123 { "Cloth armour", 0 }, //5
ThomasBGill 30:4a03611a3d99 124 { "Leather armour", 1 }, //6
ThomasBGill 30:4a03611a3d99 125 { "Studded armour", 2 }, //7
ThomasBGill 30:4a03611a3d99 126 { "Chainmail vest", 3 }, //8
ThomasBGill 30:4a03611a3d99 127 { "Plate armour", 4 }, //9
ThomasBGill 26:0dd71fc0ede4 128 };
ThomasBGill 26:0dd71fc0ede4 129
ThomasBGill 35:2c290fa78f1d 130 /** Enemy Structure
ThomasBGill 35:2c290fa78f1d 131 *
ThomasBGill 35:2c290fa78f1d 132 * It includes the EName, EHealth, EDamage, EArmour, EDodge, EHit, ESpd and EPoints members
ThomasBGill 35:2c290fa78f1d 133 * @param EName - contains the name of the enemy as a char array
ThomasBGill 35:2c290fa78f1d 134 * @param EHealth - contains the monster's full health value
ThomasBGill 35:2c290fa78f1d 135 * @param EADamage - contains the monster's damage value
ThomasBGill 35:2c290fa78f1d 136 * @param EArmour - contains the monster's armour value
ThomasBGill 35:2c290fa78f1d 137 * @param EDodge - contains the monster's dodge chance value
ThomasBGill 35:2c290fa78f1d 138 * @param EHit - contains the monster's hit chance value
ThomasBGill 35:2c290fa78f1d 139 * @param ESpd - contains the monster's speed value
ThomasBGill 35:2c290fa78f1d 140 * @param EPoints- contains the score value of the monster
ThomasBGill 35:2c290fa78f1d 141 */
ThomasBGill 26:0dd71fc0ede4 142 struct ENEMIES {
ThomasBGill 26:0dd71fc0ede4 143 char EName[9]; //Enemy name
ThomasBGill 26:0dd71fc0ede4 144 int EHealth; //Enemy health
ThomasBGill 26:0dd71fc0ede4 145 int EDamage; //Enemy damage
ThomasBGill 26:0dd71fc0ede4 146 int EArmour; //Enemy armour
ThomasBGill 26:0dd71fc0ede4 147 int EDodge; //Enemy dodge chance
ThomasBGill 26:0dd71fc0ede4 148 int EHit; //Enemy hit chance
ThomasBGill 26:0dd71fc0ede4 149 int ESpd; //Enemy speed (used for running away during fights)
ThomasBGill 26:0dd71fc0ede4 150 int EPoints; //How many points the monster is worth
ThomasBGill 26:0dd71fc0ede4 151 };
ThomasBGill 26:0dd71fc0ede4 152
ThomasBGill 26:0dd71fc0ede4 153 ENEMIES EnemyList[] = {
ThomasBGill 26:0dd71fc0ede4 154 //Name HP Dmg Arm Dg Ht Spd Pts
ThomasBGill 26:0dd71fc0ede4 155 { "Huge Rat", 5, 3, 0, 25, 70, 40, 1 }, //0- Huge Rat
ThomasBGill 26:0dd71fc0ede4 156 { "Goblin", 6, 3, 1, 25, 60, 30, 3 }, //1- Goblin
ThomasBGill 26:0dd71fc0ede4 157 { "Skeleton", 8, 4, 2, 10, 50, 10, 5 }, //2- Skeleton
ThomasBGill 26:0dd71fc0ede4 158 { "Wraith", 5, 4, 0, 40, 60, 50, 10 }, //3- Wraith
ThomasBGill 26:0dd71fc0ede4 159 { "Ogre", 10, 7, 3, 10, 35, 15, 15 }, //4- Ogre
ThomasBGill 26:0dd71fc0ede4 160 { "Minotaur", 15, 8, 4, 20, 45, 100, 50 }, //5- Minotaur
ThomasBGill 26:0dd71fc0ede4 161 };
ThomasBGill 26:0dd71fc0ede4 162
ThomasBGill 26:0dd71fc0ede4 163 //Variables
ThomasBGill 35:2c290fa78f1d 164 /** Act Flag
ThomasBGill 35:2c290fa78f1d 165 *
ThomasBGill 35:2c290fa78f1d 166 * @param ActFlag - Used in the ISR. It is set to 1 when the act button is pressed
ThomasBGill 35:2c290fa78f1d 167 *
ThomasBGill 35:2c290fa78f1d 168 */
ThomasBGill 26:0dd71fc0ede4 169 int ActFlag = 0;
ThomasBGill 35:2c290fa78f1d 170 /** Start Flag
ThomasBGill 35:2c290fa78f1d 171 *
ThomasBGill 35:2c290fa78f1d 172 * @param StartFlag - Used in the ISR. It is set to 1 when the start button is pressed
ThomasBGill 35:2c290fa78f1d 173 *
ThomasBGill 35:2c290fa78f1d 174 */
ThomasBGill 26:0dd71fc0ede4 175 int StartFlag = 0;
ThomasBGill 26:0dd71fc0ede4 176
ThomasBGill 35:2c290fa78f1d 177 /** Player Health
ThomasBGill 35:2c290fa78f1d 178 *
ThomasBGill 35:2c290fa78f1d 179 * @param ph - contains the player's current health value
ThomasBGill 35:2c290fa78f1d 180 *
ThomasBGill 35:2c290fa78f1d 181 */
ThomasBGill 35:2c290fa78f1d 182 //Player Health
ThomasBGill 35:2c290fa78f1d 183 int ph = PH_MAX;
ThomasBGill 26:0dd71fc0ede4 184
ThomasBGill 35:2c290fa78f1d 185 /** Player Weapon
ThomasBGill 35:2c290fa78f1d 186 *
ThomasBGill 35:2c290fa78f1d 187 * @param pw - contains the player's current weapon identifier value
ThomasBGill 35:2c290fa78f1d 188 *
ThomasBGill 35:2c290fa78f1d 189 */
ThomasBGill 26:0dd71fc0ede4 190 //Player weapon
ThomasBGill 26:0dd71fc0ede4 191 int pw = 0; //0 to 4
ThomasBGill 26:0dd71fc0ede4 192
ThomasBGill 35:2c290fa78f1d 193 /** Player Armour
ThomasBGill 35:2c290fa78f1d 194 *
ThomasBGill 35:2c290fa78f1d 195 * @param pa - contains the player's current armour identifier value
ThomasBGill 35:2c290fa78f1d 196 *
ThomasBGill 35:2c290fa78f1d 197 */
ThomasBGill 26:0dd71fc0ede4 198 //Player armour
ThomasBGill 26:0dd71fc0ede4 199 int pa = 5; //5 to 9
ThomasBGill 26:0dd71fc0ede4 200
ThomasBGill 35:2c290fa78f1d 201 /** Monster Health
ThomasBGill 35:2c290fa78f1d 202 *
ThomasBGill 35:2c290fa78f1d 203 * @param mh - contains the monster's current health value
ThomasBGill 35:2c290fa78f1d 204 *
ThomasBGill 35:2c290fa78f1d 205 */
ThomasBGill 34:e58c8322884d 206 //Monster health
ThomasBGill 34:e58c8322884d 207 int mh;
ThomasBGill 34:e58c8322884d 208
ThomasBGill 35:2c290fa78f1d 209 /** Score
ThomasBGill 35:2c290fa78f1d 210 *
ThomasBGill 35:2c290fa78f1d 211 * @param score - contains the player's current score value
ThomasBGill 35:2c290fa78f1d 212 *
ThomasBGill 35:2c290fa78f1d 213 */
ThomasBGill 26:0dd71fc0ede4 214 //Player score
ThomasBGill 26:0dd71fc0ede4 215 int score = -100; //100 level, x monster, 10 chest, -2 running away
ThomasBGill 26:0dd71fc0ede4 216
ThomasBGill 35:2c290fa78f1d 217 /** Highest Score
ThomasBGill 35:2c290fa78f1d 218 *
ThomasBGill 35:2c290fa78f1d 219 * @param HScore1 - contains the top high score value
ThomasBGill 35:2c290fa78f1d 220 */
ThomasBGill 26:0dd71fc0ede4 221 //High scores
ThomasBGill 26:0dd71fc0ede4 222 int HScore1;
ThomasBGill 35:2c290fa78f1d 223
ThomasBGill 35:2c290fa78f1d 224 /** Second Highest Score
ThomasBGill 35:2c290fa78f1d 225 *
ThomasBGill 35:2c290fa78f1d 226 * @param HScore2 - contains the second high score value
ThomasBGill 35:2c290fa78f1d 227 *
ThomasBGill 35:2c290fa78f1d 228 */
ThomasBGill 26:0dd71fc0ede4 229 int HScore2;
ThomasBGill 35:2c290fa78f1d 230
ThomasBGill 35:2c290fa78f1d 231 /** Third Highest Score
ThomasBGill 35:2c290fa78f1d 232 *
ThomasBGill 35:2c290fa78f1d 233 * @param HScore3 - contains the third high score value
ThomasBGill 35:2c290fa78f1d 234 *
ThomasBGill 35:2c290fa78f1d 235 */
ThomasBGill 26:0dd71fc0ede4 236 int HScore3;
ThomasBGill 35:2c290fa78f1d 237
ThomasBGill 35:2c290fa78f1d 238 /** Fourth Highest Score
ThomasBGill 35:2c290fa78f1d 239 *
ThomasBGill 35:2c290fa78f1d 240 * @param HScore4 - contains the fourth high score value
ThomasBGill 35:2c290fa78f1d 241 *
ThomasBGill 35:2c290fa78f1d 242 */
ThomasBGill 26:0dd71fc0ede4 243 int HScore4;
ThomasBGill 26:0dd71fc0ede4 244
ThomasBGill 35:2c290fa78f1d 245 /** Boss Fight
ThomasBGill 35:2c290fa78f1d 246 *
ThomasBGill 35:2c290fa78f1d 247 * @param BossFight - Defualt false. Set to true at the exit of every level that is a multiple of 5 (labyrinth levels). Causes a minotaur to appear in the fight function.
ThomasBGill 35:2c290fa78f1d 248 *
ThomasBGill 35:2c290fa78f1d 249 */
ThomasBGill 26:0dd71fc0ede4 250 bool BossFight = false;
ThomasBGill 26:0dd71fc0ede4 251
ThomasBGill 26:0dd71fc0ede4 252 //Voids
ThomasBGill 33:4fc26476b2e0 253 /** Semihost Powerdown
ThomasBGill 33:4fc26476b2e0 254 *
ThomasBGill 33:4fc26476b2e0 255 * Powers down the ethernet
ThomasBGill 33:4fc26476b2e0 256 *
ThomasBGill 33:4fc26476b2e0 257 */
ThomasBGill 26:0dd71fc0ede4 258 int semihost_powerdown();
ThomasBGill 26:0dd71fc0ede4 259
ThomasBGill 33:4fc26476b2e0 260 /** Act Button Pressed
ThomasBGill 33:4fc26476b2e0 261 *
ThomasBGill 33:4fc26476b2e0 262 * Interrupt Service Routine for the act button
ThomasBGill 33:4fc26476b2e0 263 *
ThomasBGill 33:4fc26476b2e0 264 */
ThomasBGill 26:0dd71fc0ede4 265 void ActPressed();
ThomasBGill 33:4fc26476b2e0 266
ThomasBGill 33:4fc26476b2e0 267 /** Start Button Pressed
ThomasBGill 33:4fc26476b2e0 268 *
ThomasBGill 33:4fc26476b2e0 269 * Interrupt Service Routine for the act button
ThomasBGill 33:4fc26476b2e0 270 *
ThomasBGill 33:4fc26476b2e0 271 */
ThomasBGill 26:0dd71fc0ede4 272 void StartPressed();
ThomasBGill 33:4fc26476b2e0 273
ThomasBGill 33:4fc26476b2e0 274 /** Write Data to File
ThomasBGill 33:4fc26476b2e0 275 *
ThomasBGill 33:4fc26476b2e0 276 * Writes the highscores to the .txt file
ThomasBGill 33:4fc26476b2e0 277 *
ThomasBGill 33:4fc26476b2e0 278 */
ThomasBGill 33:4fc26476b2e0 279 void writeDataToFile();
ThomasBGill 26:0dd71fc0ede4 280
ThomasBGill 33:4fc26476b2e0 281 /** Write Data to File
ThomasBGill 33:4fc26476b2e0 282 *
ThomasBGill 33:4fc26476b2e0 283 * Reads the highscores from the .txt file and stores the values obtained to the high score integers
ThomasBGill 33:4fc26476b2e0 284 *
ThomasBGill 33:4fc26476b2e0 285 */
ThomasBGill 27:1ad2408ba702 286 void readDataFromFile();
ThomasBGill 33:4fc26476b2e0 287
ThomasBGill 33:4fc26476b2e0 288 /** High Score Check
ThomasBGill 33:4fc26476b2e0 289 *
ThomasBGill 33:4fc26476b2e0 290 * Compares the current score with the saved high scores, arranges the scores in order and then saves the scores to the .txt file
ThomasBGill 33:4fc26476b2e0 291 *
ThomasBGill 33:4fc26476b2e0 292 */
ThomasBGill 27:1ad2408ba702 293 void HighScoreCheck();
ThomasBGill 26:0dd71fc0ede4 294
ThomasBGill 33:4fc26476b2e0 295 /** Flash Screen
ThomasBGill 33:4fc26476b2e0 296 *
ThomasBGill 33:4fc26476b2e0 297 * Inverts and then uninverts the screen's colours
ThomasBGill 35:2c290fa78f1d 298 * @param n - contains the number of times the screen flashes
ThomasBGill 33:4fc26476b2e0 299 *
ThomasBGill 33:4fc26476b2e0 300 */
ThomasBGill 33:4fc26476b2e0 301 void FlashScreen(int n);
ThomasBGill 33:4fc26476b2e0 302
ThomasBGill 33:4fc26476b2e0 303 /** Draw Graphic
ThomasBGill 33:4fc26476b2e0 304 *
ThomasBGill 33:4fc26476b2e0 305 * Draws a 38x38 pixel image from a starting point
ThomasBGill 35:2c290fa78f1d 306 * @param p - contains the which image to draw (0- Huge Rat, 1- Goblin, 2- Skeleton, 3- Wraith, 4- Ogre, 5- Minotaur)
ThomasBGill 35:2c290fa78f1d 307 * @param x - contains the x co-ordinate of starting position
ThomasBGill 35:2c290fa78f1d 308 * @param y - contains the y co-ordinate of starting position
ThomasBGill 33:4fc26476b2e0 309 *
ThomasBGill 33:4fc26476b2e0 310 */
ThomasBGill 28:b3a597b38b60 311 void DrawGraphic(int p, int x, int y);
ThomasBGill 28:b3a597b38b60 312
ThomasBGill 33:4fc26476b2e0 313 /** Intro
ThomasBGill 33:4fc26476b2e0 314 *
ThomasBGill 33:4fc26476b2e0 315 * Displays the game title when the system is turned on
ThomasBGill 33:4fc26476b2e0 316 *
ThomasBGill 33:4fc26476b2e0 317 */
ThomasBGill 26:0dd71fc0ede4 318 void Intro();
ThomasBGill 33:4fc26476b2e0 319
ThomasBGill 33:4fc26476b2e0 320 /** Initilize
ThomasBGill 33:4fc26476b2e0 321 *
ThomasBGill 33:4fc26476b2e0 322 * Initilizes the score, level number and player health and equipment
ThomasBGill 33:4fc26476b2e0 323 *
ThomasBGill 33:4fc26476b2e0 324 *
ThomasBGill 33:4fc26476b2e0 325 */
ThomasBGill 33:4fc26476b2e0 326 void Initilize();
ThomasBGill 34:e58c8322884d 327
ThomasBGill 34:e58c8322884d 328 /** Main Menu
ThomasBGill 34:e58c8322884d 329 *
ThomasBGill 34:e58c8322884d 330 * Displays a menu where the user can choose to start the game, view highscores or view the option menu
ThomasBGill 34:e58c8322884d 331 *
ThomasBGill 34:e58c8322884d 332 *
ThomasBGill 34:e58c8322884d 333 */
ThomasBGill 26:0dd71fc0ede4 334 void MainMenu();
ThomasBGill 34:e58c8322884d 335
ThomasBGill 34:e58c8322884d 336 /** Options Menu
ThomasBGill 34:e58c8322884d 337 *
ThomasBGill 34:e58c8322884d 338 * Allows the user to turn the screen backlight on or off
ThomasBGill 34:e58c8322884d 339 *
ThomasBGill 34:e58c8322884d 340 *
ThomasBGill 34:e58c8322884d 341 */
ThomasBGill 26:0dd71fc0ede4 342 void Options();
ThomasBGill 34:e58c8322884d 343
ThomasBGill 34:e58c8322884d 344 /** Level Screen
ThomasBGill 34:e58c8322884d 345 *
ThomasBGill 34:e58c8322884d 346 * Displays which level the user is about to enter
ThomasBGill 34:e58c8322884d 347 *
ThomasBGill 34:e58c8322884d 348 *
ThomasBGill 34:e58c8322884d 349 */
ThomasBGill 26:0dd71fc0ede4 350 void LevelScreen();
ThomasBGill 34:e58c8322884d 351
ThomasBGill 34:e58c8322884d 352 /** Next Level
ThomasBGill 34:e58c8322884d 353 *
ThomasBGill 34:e58c8322884d 354 * Increases the score, generates the next level and then initilizes the random seed
ThomasBGill 34:e58c8322884d 355 *
ThomasBGill 34:e58c8322884d 356 *
ThomasBGill 34:e58c8322884d 357 */
ThomasBGill 34:e58c8322884d 358 void NextLevel();
ThomasBGill 34:e58c8322884d 359
ThomasBGill 34:e58c8322884d 360 /** Game Loop
ThomasBGill 34:e58c8322884d 361 *
ThomasBGill 34:e58c8322884d 362 * The main loop while the game is running.
ThomasBGill 34:e58c8322884d 363 * Checks if the user is interacting with a chest, moving the analogue stick or pressing a button and then calls the corresponding function
ThomasBGill 34:e58c8322884d 364 *
ThomasBGill 34:e58c8322884d 365 *
ThomasBGill 34:e58c8322884d 366 */
ThomasBGill 26:0dd71fc0ede4 367 void GameLoop();
ThomasBGill 34:e58c8322884d 368
ThomasBGill 34:e58c8322884d 369 /** Player Camera
ThomasBGill 34:e58c8322884d 370 *
ThomasBGill 34:e58c8322884d 371 * Displays the map around the player as characters on the screen
ThomasBGill 34:e58c8322884d 372 *
ThomasBGill 34:e58c8322884d 373 */
ThomasBGill 26:0dd71fc0ede4 374 void PlayerCamera();
ThomasBGill 34:e58c8322884d 375
ThomasBGill 34:e58c8322884d 376 /** Player Move
ThomasBGill 34:e58c8322884d 377 *
ThomasBGill 34:e58c8322884d 378 * Checks which way the analogue stick was moved and then moves the player into that space if the tile is passable
ThomasBGill 34:e58c8322884d 379 *
ThomasBGill 34:e58c8322884d 380 */
ThomasBGill 26:0dd71fc0ede4 381 void PlayerMove();
ThomasBGill 34:e58c8322884d 382
ThomasBGill 34:e58c8322884d 383 /** Fight
ThomasBGill 34:e58c8322884d 384 *
ThomasBGill 34:e58c8322884d 385 * Function called during a fight.
ThomasBGill 34:e58c8322884d 386 * It first displays the opponent and then gives the user the option to fight or run away.
ThomasBGill 34:e58c8322884d 387 * The loop ends if the player runs away, kills the opponent or is killed.
ThomasBGill 34:e58c8322884d 388 *
ThomasBGill 34:e58c8322884d 389 */
ThomasBGill 26:0dd71fc0ede4 390 void Fight();
ThomasBGill 34:e58c8322884d 391
ThomasBGill 34:e58c8322884d 392 /** Monster Attack
ThomasBGill 34:e58c8322884d 393 *
ThomasBGill 34:e58c8322884d 394 * Calculates the damage the opponent does to the player
ThomasBGill 35:2c290fa78f1d 395 * @param m - contains the current monster identifier
ThomasBGill 34:e58c8322884d 396 *
ThomasBGill 34:e58c8322884d 397 */
ThomasBGill 26:0dd71fc0ede4 398 void MonsterAttack(int m);
ThomasBGill 34:e58c8322884d 399
ThomasBGill 34:e58c8322884d 400 /** Player Attack
ThomasBGill 34:e58c8322884d 401 *
ThomasBGill 34:e58c8322884d 402 * Calculates the damage the player does to the opponent
ThomasBGill 35:2c290fa78f1d 403 * @param m - contains the current monster identifier
ThomasBGill 34:e58c8322884d 404 *
ThomasBGill 34:e58c8322884d 405 */
ThomasBGill 34:e58c8322884d 406 void PlayerAttack(int m);
ThomasBGill 34:e58c8322884d 407
ThomasBGill 34:e58c8322884d 408 /** Start Menu
ThomasBGill 34:e58c8322884d 409 *
ThomasBGill 34:e58c8322884d 410 * Displays a screen showing the player's current health and a menu where the user can view the map, map legend and inventory
ThomasBGill 34:e58c8322884d 411 *
ThomasBGill 34:e58c8322884d 412 */
ThomasBGill 26:0dd71fc0ede4 413 void StartMenu();
ThomasBGill 34:e58c8322884d 414
ThomasBGill 34:e58c8322884d 415 /** Map
ThomasBGill 34:e58c8322884d 416 *
ThomasBGill 34:e58c8322884d 417 * Calls the functions which displays the map of the current level on the screen and flashes the player's current location
ThomasBGill 34:e58c8322884d 418 *
ThomasBGill 34:e58c8322884d 419 */
ThomasBGill 26:0dd71fc0ede4 420 void Map();
ThomasBGill 34:e58c8322884d 421
ThomasBGill 34:e58c8322884d 422 /** Draw Map
ThomasBGill 34:e58c8322884d 423 *
ThomasBGill 34:e58c8322884d 424 * Displays the map of the current level on the screen
ThomasBGill 34:e58c8322884d 425 *
ThomasBGill 34:e58c8322884d 426 */
ThomasBGill 26:0dd71fc0ede4 427 void DrawMap();
ThomasBGill 34:e58c8322884d 428
ThomasBGill 34:e58c8322884d 429 /** Flash Player Location
ThomasBGill 34:e58c8322884d 430 *
ThomasBGill 34:e58c8322884d 431 * Flashes the player's current location on the screen
ThomasBGill 34:e58c8322884d 432 *
ThomasBGill 34:e58c8322884d 433 */
ThomasBGill 26:0dd71fc0ede4 434 void FlashPlayerLocation();
ThomasBGill 34:e58c8322884d 435
ThomasBGill 34:e58c8322884d 436 /** Map legend
ThomasBGill 34:e58c8322884d 437 *
ThomasBGill 34:e58c8322884d 438 * Displays a screen showing what each character represents on the main game screen
ThomasBGill 34:e58c8322884d 439 *
ThomasBGill 34:e58c8322884d 440 */
ThomasBGill 26:0dd71fc0ede4 441 void MapLegend();
ThomasBGill 34:e58c8322884d 442
ThomasBGill 34:e58c8322884d 443 /** Inventory
ThomasBGill 34:e58c8322884d 444 *
ThomasBGill 34:e58c8322884d 445 * Displays a screen showing what weapon and armour the player has equipped.
ThomasBGill 34:e58c8322884d 446 *
ThomasBGill 34:e58c8322884d 447 */
ThomasBGill 26:0dd71fc0ede4 448 void Inventory();
ThomasBGill 34:e58c8322884d 449
ThomasBGill 34:e58c8322884d 450 /** Chest
ThomasBGill 34:e58c8322884d 451 *
ThomasBGill 34:e58c8322884d 452 * Generates either an item, potion, map or booby trap in the chest as it is opened.
ThomasBGill 34:e58c8322884d 453 *
ThomasBGill 34:e58c8322884d 454 */
ThomasBGill 26:0dd71fc0ede4 455 void Chest();
ThomasBGill 34:e58c8322884d 456
ThomasBGill 34:e58c8322884d 457 /** Get Item
ThomasBGill 34:e58c8322884d 458 *
ThomasBGill 34:e58c8322884d 459 * Generates an item from the list of items and asks if the player wants to equip it.
ThomasBGill 34:e58c8322884d 460 *
ThomasBGill 34:e58c8322884d 461 */
ThomasBGill 26:0dd71fc0ede4 462 void getItem();
ThomasBGill 34:e58c8322884d 463
ThomasBGill 34:e58c8322884d 464 /** Booby Trap
ThomasBGill 34:e58c8322884d 465 *
ThomasBGill 34:e58c8322884d 466 * Damages the player for 0-5 damage. If the damage is 0 the trap will display as having failed.
ThomasBGill 34:e58c8322884d 467 *
ThomasBGill 34:e58c8322884d 468 */
ThomasBGill 26:0dd71fc0ede4 469 void BoobyTrap();
ThomasBGill 34:e58c8322884d 470
ThomasBGill 34:e58c8322884d 471 /** Reveal Map
ThomasBGill 34:e58c8322884d 472 *
ThomasBGill 34:e58c8322884d 473 * Turns all the unseen floors into seen ones.
ThomasBGill 34:e58c8322884d 474 *
ThomasBGill 34:e58c8322884d 475 */
ThomasBGill 26:0dd71fc0ede4 476 void RevealMap();
ThomasBGill 34:e58c8322884d 477
ThomasBGill 34:e58c8322884d 478 /** Potion
ThomasBGill 34:e58c8322884d 479 *
ThomasBGill 34:e58c8322884d 480 * Generates either a potion that heals the player, damages the player or transports them to the next level
ThomasBGill 34:e58c8322884d 481 *
ThomasBGill 34:e58c8322884d 482 */
ThomasBGill 26:0dd71fc0ede4 483 void Potion();
ThomasBGill 34:e58c8322884d 484
ThomasBGill 34:e58c8322884d 485 /** Game Over
ThomasBGill 34:e58c8322884d 486 *
ThomasBGill 34:e58c8322884d 487 * Displays the game over screen
ThomasBGill 34:e58c8322884d 488 *
ThomasBGill 34:e58c8322884d 489 */
ThomasBGill 26:0dd71fc0ede4 490 void GameOver();
ThomasBGill 34:e58c8322884d 491
ThomasBGill 34:e58c8322884d 492 /** Score Screen
ThomasBGill 34:e58c8322884d 493 *
ThomasBGill 34:e58c8322884d 494 * Displays the user's final score
ThomasBGill 34:e58c8322884d 495 *
ThomasBGill 34:e58c8322884d 496 */
ThomasBGill 26:0dd71fc0ede4 497 void ScoreScreen();
ThomasBGill 34:e58c8322884d 498
ThomasBGill 34:e58c8322884d 499 /** High Score Screen
ThomasBGill 34:e58c8322884d 500 *
ThomasBGill 34:e58c8322884d 501 * Displays the top 4 high scores
ThomasBGill 34:e58c8322884d 502 *
ThomasBGill 34:e58c8322884d 503 */
ThomasBGill 33:4fc26476b2e0 504 void HighScoreScreen();