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
Wall.h
00001 #ifndef WALL_H 00002 #define WALL_H 00003 00004 #include "mbed.h" 00005 #include "N5110.h" 00006 #include "Gamepad.h" 00007 00008 /** Wall Class 00009 @author Adam Jones, University of Leeds 00010 @brief Controls the Cross Hairs in the Wall Defence game 00011 @date April 2017 00012 00013 @code 00014 #include "N5110.h" 00015 #include "Wall.h" 00016 00017 00018 00019 int main() 00020 { 00021 Wall _wall; 00022 00023 00024 //initialise wall object with 100 life 00025 _wall.init(100); 00026 00027 //draw wall 00028 _wall.draw(lcd); 00029 00030 //decrease walls health by 1 00031 _wall.take_damage(1); 00032 00033 //get wall health 00034 int wallHealth = _wall.get_wall_health() 00035 } 00036 00037 @endcode 00038 00039 00040 00041 */ 00042 class Wall 00043 { 00044 00045 00046 00047 00048 public: 00049 Wall(); 00050 ~Wall(); 00051 /** 00052 * @brief Initialises the Wall with a max health 00053 * @param max health @details integer representing the life of the wall 00054 */ 00055 void init(int maxHealth); 00056 /** 00057 * @brief Draws the wall on the display 00058 * @param lcd @details the N5110 screen object 00059 */ 00060 void draw(N5110 &lcd); 00061 00062 /** Health struct */ 00063 struct Health { 00064 int current; /**< int for current */ 00065 int max; /**< int for max */ 00066 }; 00067 00068 /** 00069 * @brief sets the wall health 00070 * @param health @details integer value 00071 */ 00072 void set_wall_health(int wall_health); 00073 /** 00074 * @brief Returns integer value of wall health 00075 * @return wall health @details an integer value 00076 */ 00077 int get_wall_health(); 00078 00079 /** 00080 * @brief Does damage to the wall 00081 * @param damage @details an integer representing the amount of damage to the wall health 00082 */ 00083 void Wall::take_damage(int damage); 00084 00085 private: 00086 00087 Health _wallHealth; 00088 00089 }; 00090 #endif
Generated on Mon Nov 11 2024 22:48:00 by
1.7.2