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
EnemySpawner.h
00001 #ifndef ENEMYSPAWNER_H 00002 #define ENEMYSPAWNER_H 00003 00004 #include "mbed.h" 00005 #include "Gamepad.h" 00006 #include "Enemy.h" 00007 00008 00009 /** EnemySpawner Class 00010 @author Adam Jones, University of Leeds 00011 @brief Creates and controls the levels of the game 00012 @date April 2019 00013 @brief Revision 1.0 00014 00015 @code 00016 #include "Enemy.h" 00017 #include "mbed.h" 00018 #include "Gamepad.h" 00019 00020 00021 int main() 00022 { 00023 //setup pointer to enemy array 00024 Enemy *_enemies; 00025 //setup level enemy spawner object 00026 EnemySpawner _level; 00027 00028 00029 //create level and return array of enemies 00030 int _levelNumber = 1 //integer level number 00031 _enemies = _level.init(_levelNumber); 00032 00033 //returns number of enemies in level 00034 int numOfEnemies = _level.get_number_of_enemies() 00035 00036 //updates level 00037 _level.update(_fps); 00038 } 00039 00040 @endcode 00041 00042 00043 */ 00044 00045 00046 class EnemySpawner 00047 { 00048 00049 public: 00050 EnemySpawner(); 00051 ~EnemySpawner(); 00052 00053 /** 00054 * @brief Initialises the game level 00055 * @param level @details the number of the level of the game 00056 * @returns Enemy* @details a pointer to an array of enemy objects 00057 */ 00058 Enemy* init(int level); 00059 00060 /** 00061 * @brief Updates to keep track of the time and tell indicidual enemies when to begin moving 00062 * @param fps @details the fps of the game 00063 */ 00064 void update(int fps); 00065 00066 /** 00067 * @brief Gets the number of enemies in level 00068 * @returns number of enemies @details an integer value of the number of enemies in the level 00069 */ 00070 int get_number_of_enemies(); 00071 00072 private: 00073 float _minTimeBetweenSpawns; 00074 float _timeIntoLevel; 00075 int _number_of_enemies; 00076 Enemy *_enemies; 00077 int _level; 00078 }; 00079 00080 #endif
Generated on Mon Nov 11 2024 22:48:00 by
