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: mbed
Grid.h
00001 #ifndef GRID_H 00002 #define GRID_H 00003 00004 #include "mbed.h" 00005 #include "N5110.h" 00006 #include "Gamepad.h" 00007 #include "ScreenArray.h" 00008 #include "Charactersprites.h" 00009 #include "Ghost.h" 00010 #include <vector> 00011 #include <stdlib.h> 00012 #include <time.h> 00013 00014 /** Grid Class 00015 @author Mr Nigel TK Vere, University of Leeds 00016 @brief Controls and models the grid or maze used in the game main character for the badman game 00017 @date April 2019 00018 */ 00019 00020 /** Grid Class 00021 00022 @brief Controls and models the grid or maze used in the game main character for the badman game 00023 00024 @version 1.0 00025 00026 @author Mr Nigel TK Vere 00027 00028 @date April 2019 00029 00030 00031 */ 00032 00033 class Grid 00034 { 00035 00036 public: 00037 /** Grid object Constructor */ 00038 Grid(); 00039 /**Grid object Destructor */ 00040 ~Grid(); 00041 /** Displays the grid maze where the game takes place 00042 * @param lcd @details Reference Nokia 5110 LCD screen object 00043 * @param ghostnumber @details Integer value representing the maximum number of ghost characters that can be generated in the badman game 00044 */ 00045 void drawGrid(N5110 &lcd,int ghostnumber); 00046 /** 00047 * @brief Mutator method initialises the grid object by subsequently initialising the screen array object and the number of ghosts that can be generated in the game 00048 * @param screen @details Reference screen array object used to initalise the screen array object used in the game 00049 * @param ghostnumber @details Integer value representing the maximum number of ghost characters that can be generated in the badman game 00050 00051 */ 00052 void init(ScreenArray &screen,int ghostnumber); 00053 /** 00054 * @brief Mutator method used to remove a fruit from the grid when badman eats it 00055 * @param x @details X coordinate of the point of impact between badman and the fruit 00056 * @param y @details Y coordinate of the point of impact between badman and the fruit 00057 * @param screen @details Reference screen array object for the removal of the fruit from the screen array object 00058 00059 */ 00060 void updateFruit(int x,int y,ScreenArray &screen); 00061 /** 00062 * @brief Mutator method used for ghost-badman collision detection 00063 * @param screen @details Reference screen array object for the ghost-grid collision detection 00064 * @param ghostnumber @details Integer value representing the number of ghosts currently observed at the current level 00065 * @param x @details Current x coordinate of the centre of the badman character object 00066 * @param y @details Current y coordinate of the centre of the badman character object 00067 * @param r @details Current radius(_size value) the badman character object 00068 00069 00070 */ 00071 bool update(ScreenArray &screen,int ghostnumber,int x,int y,int r); 00072 00073 /** 00074 * @brief Accessor method gets the number of the charactersrpite objects(Fruits) currently on the screen 00075 @returns Returns the number of charactersprite objects on the screen 00076 00077 */ 00078 int getFruitNumber(); 00079 00080 /** 00081 // FORMAT_CODE_START 00082 * @brief Mutator method used for generating fruits in the game 00083 // FORMAT_CODE_END 00084 * @param screen @details Reference screen array object for the ghost-grid collision detection 00085 00086 00087 00088 */ 00089 void generateFruits(ScreenArray &screen); 00090 /** 00091 * @brief Mutator method used for generating ghost characters within the grid of the game 00092 * @param screen @details Reference screen array object for the ghost-grid collision detection 00093 * @param ghostnumber @details Integer value representing the number of ghosts currently observed at the current level 00094 00095 */ 00096 void generateGhosts(ScreenArray &screen,int ghostnumber); 00097 00098 00099 private: 00100 std::vector<Charactersprites> fruits;//Vector holds all the fruit charactersprite objects that will be used in the badman game for a respective level 00101 std::vector<Ghost> ghosts;//Vector holds all the ghost character objects that will be used in the badman game 00102 00103 00104 }; 00105 #endif
Generated on Thu Aug 4 2022 12:05:20 by
