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/shot.h@13:eb60628db8bf, 2020-05-14 (annotated)
- Committer:
- el19zf
- Date:
- Thu May 14 16:45:20 2020 +0000
- Revision:
- 13:eb60628db8bf
- Parent:
- 11:494cc44777fe
- Child:
- 15:3571beaaeed8
using Doxygen style to comment the code and debug some function;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el19zf | 4:b12a49f0b730 | 1 | #ifndef SHOT_H |
el19zf | 4:b12a49f0b730 | 2 | #define SHOT_H |
el19zf | 4:b12a49f0b730 | 3 | |
el19zf | 4:b12a49f0b730 | 4 | #include "mbed.h" |
el19zf | 4:b12a49f0b730 | 5 | #include "Gamepad.h" |
el19zf | 4:b12a49f0b730 | 6 | #include "N5110.h" |
el19zf | 4:b12a49f0b730 | 7 | #include <vector> |
el19zf | 6:dce38fe4e092 | 8 | #include <time.h> |
el19zf | 6:dce38fe4e092 | 9 | #include <stdlib.h> |
el19zf | 4:b12a49f0b730 | 10 | |
el19zf | 4:b12a49f0b730 | 11 | /** shot class |
el19zf | 13:eb60628db8bf | 12 | @set several kinds of shot and come from all around |
el19zf | 13:eb60628db8bf | 13 | @author Zeyu Feng |
el19zf | 13:eb60628db8bf | 14 | @13 April 2020 |
el19zf | 13:eb60628db8bf | 15 | */ |
el19zf | 13:eb60628db8bf | 16 | /**struct of shot position type and direction*/ |
el19zf | 7:c49f3d3b672f | 17 | struct shot_posandtype { |
el19zf | 5:6774b7272e85 | 18 | int x; |
el19zf | 5:6774b7272e85 | 19 | int y; |
el19zf | 5:6774b7272e85 | 20 | int type; |
el19zf | 5:6774b7272e85 | 21 | int dir; |
el19zf | 5:6774b7272e85 | 22 | }; |
el19zf | 4:b12a49f0b730 | 23 | |
el19zf | 7:c49f3d3b672f | 24 | class shot |
el19zf | 7:c49f3d3b672f | 25 | { |
el19zf | 7:c49f3d3b672f | 26 | |
el19zf | 7:c49f3d3b672f | 27 | public: |
el19zf | 13:eb60628db8bf | 28 | |
el19zf | 13:eb60628db8bf | 29 | /**constructor*/ |
el19zf | 4:b12a49f0b730 | 30 | shot(); |
el19zf | 13:eb60628db8bf | 31 | /**destructor*/ |
el19zf | 4:b12a49f0b730 | 32 | ~shot(); |
el19zf | 13:eb60628db8bf | 33 | /**generate first 10 shots*/ |
el19zf | 6:dce38fe4e092 | 34 | void init(); |
el19zf | 13:eb60628db8bf | 35 | |
el19zf | 13:eb60628db8bf | 36 | /**produce a random_pos(21,0)(42,0)(63,0)(21,45)(42,45)(63,45) |
el19zf | 13:eb60628db8bf | 37 | *@param vector_i(shot_posandtype*) |
el19zf | 13:eb60628db8bf | 38 | */ |
el19zf | 6:dce38fe4e092 | 39 | void init_pos(shot_posandtype* i); |
el19zf | 13:eb60628db8bf | 40 | |
el19zf | 13:eb60628db8bf | 41 | /**move shots in their own directions*/ |
el19zf | 13:eb60628db8bf | 42 | void update(N5110 &lcd); |
el19zf | 13:eb60628db8bf | 43 | |
el19zf | 13:eb60628db8bf | 44 | /**generate shots as time goes on*/ |
el19zf | 13:eb60628db8bf | 45 | void update_shot(); |
el19zf | 13:eb60628db8bf | 46 | |
el19zf | 13:eb60628db8bf | 47 | /**draw updated shots*/ |
el19zf | 4:b12a49f0b730 | 48 | void draw(N5110 &lcd); |
el19zf | 13:eb60628db8bf | 49 | |
el19zf | 13:eb60628db8bf | 50 | /**if beyoud border, delete it and generate new one, keep total number constant*/ |
el19zf | 6:dce38fe4e092 | 51 | void delete_shot(); |
el19zf | 13:eb60628db8bf | 52 | /**control difficulty of game(size) |
el19zf | 13:eb60628db8bf | 53 | *@param timerflag(int) |
el19zf | 13:eb60628db8bf | 54 | *@param increment(float) |
el19zf | 13:eb60628db8bf | 55 | *@param max(int) |
el19zf | 13:eb60628db8bf | 56 | */ |
el19zf | 13:eb60628db8bf | 57 | void gen_shot(int timer_flag, float increment, int max); |
el19zf | 13:eb60628db8bf | 58 | |
el19zf | 13:eb60628db8bf | 59 | /**accessors resize shots |
el19zf | 13:eb60628db8bf | 60 | *@param size(int) |
el19zf | 13:eb60628db8bf | 61 | */ |
el19zf | 8:8287d2ef965d | 62 | void set_size(int size); |
el19zf | 13:eb60628db8bf | 63 | |
el19zf | 13:eb60628db8bf | 64 | /**mutators get size |
el19zf | 13:eb60628db8bf | 65 | *@return current size |
el19zf | 13:eb60628db8bf | 66 | */ |
el19zf | 8:8287d2ef965d | 67 | int get_size(); |
el19zf | 7:c49f3d3b672f | 68 | |
el19zf | 4:b12a49f0b730 | 69 | private: |
el19zf | 5:6774b7272e85 | 70 | std::vector<shot_posandtype> _p; |
el19zf | 8:8287d2ef965d | 71 | int _size; |
el19zf | 13:eb60628db8bf | 72 | float _size_f; |
el19zf | 4:b12a49f0b730 | 73 | }; |
el19zf | 4:b12a49f0b730 | 74 | #endif |
el19zf | 7:c49f3d3b672f | 75 | |
el19zf | 4:b12a49f0b730 | 76 | |
el19zf | 7:c49f3d3b672f | 77 | |
el19zf | 7:c49f3d3b672f | 78 |