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
Fire.h
00001 #ifndef FIRE_H 00002 #define FIRE_H 00003 00004 #include "mbed.h" 00005 00006 /** Fire Class 00007 * @brief Generates a fire ball that will end the game if the skateboarder touches it 00008 * @author Lewis Wooltorton 00009 * @date April 2019 00010 00011 @code 00012 00013 #include "mbed.h" 00014 #include "N5110.h" 00015 #include "Gamepad.h" 00016 #include "Fire.h" 00017 #include <cstdlib> 00018 #include <ctime> 00019 00020 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); 00021 Gamepad gamepad; 00022 Fire _fire; 00023 00024 int _skater_y; 00025 int _fire_y; 00026 00027 int main() { 00028 _fire.init(); 00029 _fire_y = 20; 00030 while(1) { 00031 00032 // Generates the x coordinate of the fire. 00033 _fire.generate_fire(); // Generates X coord of fire. 00034 // Y is calculated from parabolic relation to game counter. 00035 00036 // Check for a collision. 00037 if (_skater_x == _fire.get_fire_x() 00038 && _skater_y > _fire_y - 10 00039 && _skater_y < _fire_y + 10 00040 ) { // A range of Y coords to make collision 00041 // more frequent. 00042 00043 // Print fire. 00044 lcd.drawSprite(_fire.get_fire_x(),_fire_y,5,8, 00045 (int*)_fire.get_fire_sprite()); 00046 } 00047 } 00048 } 00049 00050 @endcode 00051 */ 00052 00053 class Fire { 00054 public: 00055 /** Constructor, non user specified.*/ 00056 Fire(); 00057 /** Destructor, non user specified.*/ 00058 ~Fire(); 00059 00060 // Mutators. 00061 /** Initialises Fire object. */ 00062 void init(); 00063 00064 // Accessors 00065 /** Gets the sprite. 00066 * @returns The Fire sprite (an integer array) 00067 */ 00068 int * get_fire_sprite(); 00069 /** Gets the x coordinate. 00070 * @returns The x coordinate of the Fire 00071 */ 00072 int get_fire_x(); 00073 00074 // Member methods. 00075 /** Generates Fire parameters @details Increments Fire x coordinate and toggles fire sprite.*/ 00076 void generate_fire(); 00077 00078 private: 00079 int _x; 00080 bool _fire_counter; 00081 }; 00082 #endif
Generated on Mon Jul 18 2022 14:06:02 by
1.7.2