![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Li Ruofan 201199450
Dependencies: mbed Gamepad Joystick
myShip/spaceship.h@7:e3844250b77d, 2020-05-15 (annotated)
- Committer:
- DannyLee
- Date:
- Fri May 15 22:23:22 2020 +0000
- Revision:
- 7:e3844250b77d
- Parent:
- 6:cbd9e1f26a10
Still has problems, actually I can't compile it
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DannyLee | 3:cf9fead9c3f4 | 1 | #ifndef spaceship_H |
DannyLee | 3:cf9fead9c3f4 | 2 | #define spaceship_H |
DannyLee | 3:cf9fead9c3f4 | 3 | |
DannyLee | 3:cf9fead9c3f4 | 4 | #include "mbed.h" |
DannyLee | 3:cf9fead9c3f4 | 5 | #include "N5110.h" |
DannyLee | 3:cf9fead9c3f4 | 6 | #include "Joystick.h" |
DannyLee | 3:cf9fead9c3f4 | 7 | #include "Bitmap.h" |
DannyLee | 3:cf9fead9c3f4 | 8 | /* spaceship Class |
DannyLee | 3:cf9fead9c3f4 | 9 | @Library for Spaceship object in the spaceship project |
DannyLee | 3:cf9fead9c3f4 | 10 | @coded by Li Ruofan |
DannyLee | 3:cf9fead9c3f4 | 11 | @May 2020 |
DannyLee | 3:cf9fead9c3f4 | 12 | */ |
DannyLee | 3:cf9fead9c3f4 | 13 | class spaceship{ |
DannyLee | 3:cf9fead9c3f4 | 14 | |
DannyLee | 3:cf9fead9c3f4 | 15 | public: |
DannyLee | 3:cf9fead9c3f4 | 16 | /* Construct function of our ship*/ |
DannyLee | 3:cf9fead9c3f4 | 17 | Spaceship(); |
DannyLee | 3:cf9fead9c3f4 | 18 | |
DannyLee | 3:cf9fead9c3f4 | 19 | /* Destruct function of our ship*/ |
DannyLee | 3:cf9fead9c3f4 | 20 | ~Spaceship(); |
DannyLee | 3:cf9fead9c3f4 | 21 | |
DannyLee | 3:cf9fead9c3f4 | 22 | |
DannyLee | 3:cf9fead9c3f4 | 23 | /* Initiate the position and the size of the ship |
DannyLee | 3:cf9fead9c3f4 | 24 | @param the value of horizontal position x (int) |
DannyLee | 3:cf9fead9c3f4 | 25 | @param the value of vertical position y (int) |
DannyLee | 3:cf9fead9c3f4 | 26 | @param the columns of spaceship image (int) |
DannyLee | 3:cf9fead9c3f4 | 27 | @param the rows of spaceship image (int) |
DannyLee | 3:cf9fead9c3f4 | 28 | */ |
DannyLee | 3:cf9fead9c3f4 | 29 | void init(int x,int y,int width,int height); |
DannyLee | 6:cbd9e1f26a10 | 30 | |
DannyLee | 6:cbd9e1f26a10 | 31 | /* draw the image of the ship |
DannyLee | 6:cbd9e1f26a10 | 32 | @param lcd (N5110) |
DannyLee | 6:cbd9e1f26a10 | 33 | */ |
DannyLee | 6:cbd9e1f26a10 | 34 | void draw(N5110 &lcd); |
DannyLee | 6:cbd9e1f26a10 | 35 | |
DannyLee | 3:cf9fead9c3f4 | 36 | void update(); |
DannyLee | 3:cf9fead9c3f4 | 37 | /// access and mutate |
DannyLee | 3:cf9fead9c3f4 | 38 | |
DannyLee | 3:cf9fead9c3f4 | 39 | /* get position and speed of spaceship in the lcd |
DannyLee | 3:cf9fead9c3f4 | 40 | @return the current postion of spaceship |
DannyLee | 3:cf9fead9c3f4 | 41 | */ |
DannyLee | 3:cf9fead9c3f4 | 42 | void set_speed(Vector2D v); |
DannyLee | 3:cf9fead9c3f4 | 43 | Vector2D get_speed(); |
DannyLee | 6:cbd9e1f26a10 | 44 | Vector2D get_Pos(); |
DannyLee | 3:cf9fead9c3f4 | 45 | |
DannyLee | 3:cf9fead9c3f4 | 46 | private: |
DannyLee | 3:cf9fead9c3f4 | 47 | Vector2D _velocity; |
DannyLee | 3:cf9fead9c3f4 | 48 | int _x; |
DannyLee | 3:cf9fead9c3f4 | 49 | int _y; |
DannyLee | 3:cf9fead9c3f4 | 50 | int _width; |
DannyLee | 3:cf9fead9c3f4 | 51 | int _height; |
DannyLee | 3:cf9fead9c3f4 | 52 | int _speed; |
DannyLee | 6:cbd9e1f26a10 | 53 | |
DannyLee | 3:cf9fead9c3f4 | 54 | }; |
DannyLee | 3:cf9fead9c3f4 | 55 | #endif |