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@10:02ab3324be6c, 2020-05-10 (annotated)
- Committer:
- el19zf
- Date:
- Sun May 10 05:16:51 2020 +0000
- Revision:
- 10:02ab3324be6c
- Parent:
- 9:62d6559f0d50
- Child:
- 11:494cc44777fe
add welcome interface and 'gameover'
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 | 4:b12a49f0b730 | 12 | @set several kinds of shot and come from all around |
el19zf | 4:b12a49f0b730 | 13 | @author Zeyu Feng |
el19zf | 4:b12a49f0b730 | 14 | @13 April 2020 |
el19zf | 4:b12a49f0b730 | 15 | */ |
el19zf | 7:c49f3d3b672f | 16 | |
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 | 4:b12a49f0b730 | 28 | //constructor |
el19zf | 4:b12a49f0b730 | 29 | shot(); |
el19zf | 4:b12a49f0b730 | 30 | //destructor |
el19zf | 4:b12a49f0b730 | 31 | ~shot(); |
el19zf | 8:8287d2ef965d | 32 | //generate first 10 shots |
el19zf | 6:dce38fe4e092 | 33 | void init(); |
el19zf | 8:8287d2ef965d | 34 | //random pos |
el19zf | 6:dce38fe4e092 | 35 | void init_pos(shot_posandtype* i); |
el19zf | 8:8287d2ef965d | 36 | //increase number of shots along with time |
el19zf | 10:02ab3324be6c | 37 | void init_shot(); |
el19zf | 8:8287d2ef965d | 38 | //moving function |
el19zf | 6:dce38fe4e092 | 39 | void update(); |
el19zf | 7:c49f3d3b672f | 40 | |
el19zf | 4:b12a49f0b730 | 41 | void draw(N5110 &lcd); |
el19zf | 8:8287d2ef965d | 42 | //if beyoud border, delete it and generate new one, keep total number constant |
el19zf | 6:dce38fe4e092 | 43 | void delete_shot(); |
el19zf | 8:8287d2ef965d | 44 | //accessors |
el19zf | 8:8287d2ef965d | 45 | void set_size(int size); |
el19zf | 8:8287d2ef965d | 46 | ////mutators |
el19zf | 8:8287d2ef965d | 47 | int get_size(); |
el19zf | 10:02ab3324be6c | 48 | |
el19zf | 10:02ab3324be6c | 49 | void gen_shot(int flag); |
el19zf | 7:c49f3d3b672f | 50 | |
el19zf | 4:b12a49f0b730 | 51 | private: |
el19zf | 5:6774b7272e85 | 52 | std::vector<shot_posandtype> _p; |
el19zf | 4:b12a49f0b730 | 53 | |
el19zf | 8:8287d2ef965d | 54 | int _size; |
el19zf | 4:b12a49f0b730 | 55 | }; |
el19zf | 4:b12a49f0b730 | 56 | #endif |
el19zf | 7:c49f3d3b672f | 57 | |
el19zf | 4:b12a49f0b730 | 58 | |
el19zf | 7:c49f3d3b672f | 59 | |
el19zf | 7:c49f3d3b672f | 60 |