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
Diff: shot/shot.h
- Revision:
- 19:5083339b55e8
- Parent:
- 16:cf2bfada3adf
- Child:
- 21:e3866e4fe5fb
--- a/shot/shot.h Thu May 21 15:20:33 2020 +0000 +++ b/shot/shot.h Thu May 21 17:07:46 2020 +0000 @@ -9,10 +9,10 @@ #include <stdlib.h> /** shot class -@brief set several kinds of shot and come from all around -@author Zeyu Feng -@13 April 2020 -*/ + *@brief set several kinds of shot and come from all around + *@author Zeyu Feng + *@13 April 2020 + */ /**struct of shot position type and direction*/ struct shot_posandtype { int x; @@ -30,37 +30,40 @@ shot(); /**destructor*/ ~shot(); - /**generate first 10 shots*/ + /**generate first 7 shots vector include position type direction by iterating through the vector*/ void init(); - /**produce a random_pos(21,0)(42,0)(63,0)(21,45)(42,45)(63,45) - *@param vector_i(shot_posandtype*) - */ + /**produce a init position of shots((21,0);(42,0);(63,0);(21,45);(42,45);(63,45)) + *@param vector_i(shot_posandtype*) + */ void init_pos(shot_posandtype *i); - /**move shots in their own directions*/ + /**update shots in their directions*/ void update(); - /**generate shots as time goes on*/ + /**resize shots as time goes on + generate shots in empty vector */ void update_shot(); - /**draw updated shots*/ + /**draw updated shots iterating through the vector*/ void draw(N5110 &lcd); /**if beyoud border, delete it and generate new one, keep total number constant*/ void delete_shot(); + /**control difficulty of game(size) *@param timerflag(int) - *@param increment(float) + *@param increment(float) per 1/6 s *@param max(int) */ void gen_shot(int timer_flag, float increment, int max); - /**accessors resize shots + /**accessors set the size of shots *@param size(int) */ void set_size(int size); + /**accessors create a shot vector for testing*/ void set_shot(int x, int y, int type, int Direction); /**mutators get size @@ -68,12 +71,21 @@ */ int get_size(); + /** mutators get position of the shot for testing*/ Vector2D get_shot(); private: + /** creat vectors for my struct 'shot_posandtype' + vector is useful as it is possible to remove or add elements*/ std::vector<shot_posandtype> _p; + + /**vector size must an integer*/ int _size; + + /**it's too fast to generate 1 shot per 1/6 second, + generate a float number (0-1),use f_to_i convert to _size*/ float _size_f; + Vector2D _shot_pos; }; #endif