Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: N5110 PowerControl mbed
Diff: Game.h
- Revision:
- 35:2c290fa78f1d
- Parent:
- 34:e58c8322884d
diff -r e58c8322884d -r 2c290fa78f1d Game.h --- a/Game.h Mon May 11 12:56:26 2015 +0000 +++ b/Game.h Mon May 11 22:03:41 2015 +0000 @@ -1,9 +1,11 @@ /** -@file Game.h -@brief Header file containing the main game member functions and variables -@brief Revision 1.0 -@author Thomas Barnaby Gill -@date 11th May 2015 +* @file Game.h +* @brief Header file containing the main game member functions and variables +* @brief Revision 1.0 +* +* @brief Code for reading joystick by Craig Evans https://developer.mbed.org/users/eencae/code/Joystick/file/026fa541af7a/main.cpp +* @author Thomas Barnaby Gill +* @date 11th May 2015 */ #include "N5110.h" @@ -39,28 +41,51 @@ Centre, Unknown }; - -// struct for Joystick + +/** Joystick Structure +* +* It includes the x, x0, y, y0 and direction members +* @param x - current x direction potentiometer value +* @param x0 - centred x direction potentiometer value +* @param y - current y direction potentiometer value +* @param y0 - centred y direction potentiometer value +* @param direction - allowed direction values +*/ typedef struct JoyStick Joystick; struct JoyStick { float x; // current x value float x0; // 'centred' x value float y; // current y value float y0; // 'centred' y value - int button; // button state (assume pull-down used, so 1 = pressed, 0 = unpressed) DirectionName direction; // current direction }; // create struct variable Joystick joystick; -// function prototypes +/** Calibrate Joystick +* +* Reads defualt position of joystick for further readings +* +*/ void calibrateJoystick(); + +/** Update Joystick +* +* Reads cuurent position of joystick relative to the defualt position +* +*/ void updateJoystick(); #define USR_POWERDOWN (0x104) LocalFileSystem local("local"); // create local filesystem +/** Tile Structure +* +* It includes the symbol and passable members +* @param Symbol - contains the tile symbols for each tile type +* @param Passable - whether tile type can be walked on by player +*/ struct TILES { char Symbol; // Symbol for this tile bool Passable; // Can tile be walked on @@ -76,6 +101,12 @@ { '/', true }, // 6- CHEST_OPENED }; +/** Item Structure +* +* It includes the ItemName and the ItemValue members +* @param ItemName - contains the name of the item as a char array +* @param ItemValue - contains damage/armour value of the item +*/ struct ITEMS { char ItemName[15]; //Item name int ItemValue; //Damage/ armour value @@ -96,6 +127,18 @@ { "Plate armour", 4 }, //9 }; +/** Enemy Structure +* +* It includes the EName, EHealth, EDamage, EArmour, EDodge, EHit, ESpd and EPoints members +* @param EName - contains the name of the enemy as a char array +* @param EHealth - contains the monster's full health value +* @param EADamage - contains the monster's damage value +* @param EArmour - contains the monster's armour value +* @param EDodge - contains the monster's dodge chance value +* @param EHit - contains the monster's hit chance value +* @param ESpd - contains the monster's speed value +* @param EPoints- contains the score value of the monster +*/ struct ENEMIES { char EName[9]; //Enemy name int EHealth; //Enemy health @@ -118,34 +161,92 @@ }; //Variables +/** Act Flag +* +* @param ActFlag - Used in the ISR. It is set to 1 when the act button is pressed +* +*/ int ActFlag = 0; +/** Start Flag +* +* @param StartFlag - Used in the ISR. It is set to 1 when the start button is pressed +* +*/ int StartFlag = 0; -//int DirFlag = 0; -//Space type player is on -int pSpace; +/** Player Health +* +* @param ph - contains the player's current health value +* +*/ +//Player Health +int ph = PH_MAX; -//Player Health -int ph = PH_MAX; - +/** Player Weapon +* +* @param pw - contains the player's current weapon identifier value +* +*/ //Player weapon int pw = 0; //0 to 4 +/** Player Armour +* +* @param pa - contains the player's current armour identifier value +* +*/ //Player armour int pa = 5; //5 to 9 +/** Monster Health +* +* @param mh - contains the monster's current health value +* +*/ //Monster health int mh; +/** Score +* +* @param score - contains the player's current score value +* +*/ //Player score int score = -100; //100 level, x monster, 10 chest, -2 running away +/** Highest Score +* +* @param HScore1 - contains the top high score value +*/ //High scores int HScore1; + +/** Second Highest Score +* +* @param HScore2 - contains the second high score value +* +*/ int HScore2; + +/** Third Highest Score +* +* @param HScore3 - contains the third high score value +* +*/ int HScore3; + +/** Fourth Highest Score +* +* @param HScore4 - contains the fourth high score value +* +*/ int HScore4; +/** Boss Fight +* +* @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. +* +*/ bool BossFight = false; //Voids @@ -194,7 +295,7 @@ /** Flash Screen * * Inverts and then uninverts the screen's colours -* @param n- Number of times the screen flashes +* @param n - contains the number of times the screen flashes * */ void FlashScreen(int n); @@ -202,9 +303,9 @@ /** Draw Graphic * * Draws a 38x38 pixel image from a starting point -* @param p- Which image to draw (0- Huge Rat, 1- Goblin, 2- Skeleton, 3- Wraith, 4- Ogre, 5- Minotaur) -* @param x- x co-ordinate of starting position -* @param y- y co-ordinate of starting position +* @param p - contains the which image to draw (0- Huge Rat, 1- Goblin, 2- Skeleton, 3- Wraith, 4- Ogre, 5- Minotaur) +* @param x - contains the x co-ordinate of starting position +* @param y - contains the y co-ordinate of starting position * */ void DrawGraphic(int p, int x, int y); @@ -291,6 +392,7 @@ /** Monster Attack * * Calculates the damage the opponent does to the player +* @param m - contains the current monster identifier * */ void MonsterAttack(int m); @@ -298,6 +400,7 @@ /** Player Attack * * Calculates the damage the player does to the opponent +* @param m - contains the current monster identifier * */ void PlayerAttack(int m);