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
shot.h
00001 #ifndef SHOT_H 00002 #define SHOT_H 00003 00004 #include "mbed.h" 00005 #include "Gamepad.h" 00006 #include "N5110.h" 00007 #include <vector> 00008 #include <time.h> 00009 #include <stdlib.h> 00010 00011 /**struct of shot position type and direction*/ 00012 struct shot_posandtype { 00013 int x; 00014 int y; 00015 int type; 00016 int dir; 00017 }; 00018 00019 /** shot class 00020 *@brief set several kinds of shot and come from all around 00021 *@author Zeyu Feng 00022 *@13 April 2020 00023 */ 00024 class shot 00025 { 00026 00027 public: 00028 00029 /**constructor*/ 00030 shot(); 00031 /**destructor*/ 00032 ~shot(); 00033 /**generate first 7 shots vector include position type direction by iterating through the vector*/ 00034 void init(); 00035 00036 /**produce a init position of shots((21,0);(42,0);(63,0);(21,45);(42,45);(63,45)) 00037 *@param vector_i(shot_posandtype*) 00038 */ 00039 void init_pos(shot_posandtype *i); 00040 00041 /**update shots in their directions*/ 00042 void update(); 00043 00044 /**resize shots as time goes on 00045 generate shots in empty vector */ 00046 void update_shot(); 00047 00048 /**draw updated shots iterating through the vector*/ 00049 void draw(N5110 &lcd); 00050 00051 /**if beyoud border, delete it and generate new one, keep total number constant*/ 00052 void delete_shot(); 00053 00054 /**control difficulty of game(size) 00055 *@param timerflag(int) 00056 *@param increment(float) per 1/6 s 00057 *@param max(int) 00058 */ 00059 void gen_shot(int timer_flag, float increment, int max); 00060 00061 /**accessors set the size of shots 00062 *@param size(int) 00063 */ 00064 void set_size(int size); 00065 00066 /**accessors create a shot vector for testing*/ 00067 void set_shot(int x, int y, int type, int Direction); 00068 00069 /**mutators get size 00070 *@return current size 00071 */ 00072 int get_size(); 00073 00074 /** mutators get position of the shot for testing*/ 00075 Vector2D get_shot(); 00076 00077 private: 00078 /** creat vectors for my struct 'shot_posandtype' 00079 vector is useful as it is possible to remove or add elements*/ 00080 std::vector<shot_posandtype> _p; 00081 00082 /**vector size must an integer*/ 00083 int _size; 00084 00085 /**it's too fast to generate 1 shot per 1/6 second, 00086 generate a float number (0-1),use f_to_i convert to _size*/ 00087 float _size_f; 00088 00089 Vector2D _shot_pos; 00090 }; 00091 #endif 00092 00093 00094 00095
Generated on Thu Jul 14 2022 12:45:25 by
