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.
Spaceship/Spaceship.h@27:8bb2bd97c319, 2020-05-13 (annotated)
- Committer:
- evanso
- Date:
- Wed May 13 14:30:12 2020 +0000
- Revision:
- 27:8bb2bd97c319
- Parent:
- 21:f7d7834e3af1
- Child:
- 29:e96d91f1d39c
Added position parent class for other classes to inherit XY positions and direction bool. Added more Doxygen comments. Made code and comments multi-line to increase readability.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| evanso | 3:dee187b8b30c | 1 | #ifndef SPACESHIP_H |
| evanso | 3:dee187b8b30c | 2 | #define SPACESHIP_H |
| evanso | 3:dee187b8b30c | 3 | |
| evanso | 27:8bb2bd97c319 | 4 | // Included libraries ---------------------------------------------------------- |
| evanso | 3:dee187b8b30c | 5 | #include "mbed.h" |
| evanso | 3:dee187b8b30c | 6 | #include "N5110.h" |
| evanso | 3:dee187b8b30c | 7 | #include "Gamepad.h" |
| evanso | 27:8bb2bd97c319 | 8 | #include "Position.h" |
| evanso | 7:0af4ced868f5 | 9 | |
| evanso | 3:dee187b8b30c | 10 | /** Spaceship class |
| evanso | 27:8bb2bd97c319 | 11 | * @brief Draws and moves spaceship |
| evanso | 27:8bb2bd97c319 | 12 | * @author Benjamin Evans, University of Leeds |
| evanso | 27:8bb2bd97c319 | 13 | * @date April 2020 |
| evanso | 27:8bb2bd97c319 | 14 | */ |
| evanso | 27:8bb2bd97c319 | 15 | class Spaceship: private Position{ |
| evanso | 3:dee187b8b30c | 16 | public: |
| evanso | 3:dee187b8b30c | 17 | /** Constructor */ |
| evanso | 3:dee187b8b30c | 18 | Spaceship(); |
| evanso | 3:dee187b8b30c | 19 | |
| evanso | 3:dee187b8b30c | 20 | /** Destructor */ |
| evanso | 3:dee187b8b30c | 21 | ~Spaceship(); |
| evanso | 3:dee187b8b30c | 22 | |
| evanso | 3:dee187b8b30c | 23 | /** Initalises Spaceship */ |
| evanso | 3:dee187b8b30c | 24 | void init(); |
| evanso | 3:dee187b8b30c | 25 | |
| evanso | 3:dee187b8b30c | 26 | /** Draws Spaceship |
| evanso | 27:8bb2bd97c319 | 27 | * @param lcd @details N5110 object |
| evanso | 3:dee187b8b30c | 28 | */ |
| evanso | 3:dee187b8b30c | 29 | void draw(N5110 &lcd); |
| evanso | 3:dee187b8b30c | 30 | |
| evanso | 11:ab578a151f67 | 31 | /** Move Spaceship around the screen depedning on joystick input |
| evanso | 27:8bb2bd97c319 | 32 | * @param d_ @details Direction object of joystick |
| evanso | 4:0df2b85e47f1 | 33 | */ |
| evanso | 13:12276eed13ac | 34 | void movement(Direction d_); |
| evanso | 11:ab578a151f67 | 35 | |
| evanso | 27:8bb2bd97c319 | 36 | // Accessors and mutators -------------------------------------------------- |
| evanso | 11:ab578a151f67 | 37 | |
| evanso | 16:1ee3d3804557 | 38 | /** Gets sprtie directon if spaceship |
| evanso | 27:8bb2bd97c319 | 39 | * @return spaceship_sprite_direction_ @details true = east, |
| evanso | 27:8bb2bd97c319 | 40 | * false = west |
| evanso | 16:1ee3d3804557 | 41 | */ |
| evanso | 16:1ee3d3804557 | 42 | bool get_spaceship_sprite_direction(); |
| evanso | 16:1ee3d3804557 | 43 | |
| evanso | 17:25d79cca203a | 44 | /** Gets the xy position of the spaceship |
| evanso | 27:8bb2bd97c319 | 45 | * @return position_x_spaceship_ |
| evanso | 27:8bb2bd97c319 | 46 | * @return position_y_spaceship_ |
| evanso | 17:25d79cca203a | 47 | */ |
| evanso | 17:25d79cca203a | 48 | Vector2D get_pos(); |
| evanso | 17:25d79cca203a | 49 | |
| evanso | 11:ab578a151f67 | 50 | private: |
| evanso | 13:12276eed13ac | 51 | // Function prototypes ----------------------------------------------------- |
| evanso | 11:ab578a151f67 | 52 | |
| evanso | 27:8bb2bd97c319 | 53 | /** Sets the x, y position and sprite direction of the spaceship for |
| evanso | 27:8bb2bd97c319 | 54 | * movement function |
| evanso | 27:8bb2bd97c319 | 55 | * @peram x_change |
| evanso | 27:8bb2bd97c319 | 56 | * @peram y_change |
| evanso | 27:8bb2bd97c319 | 57 | * @peram sprite_change |
| evanso | 27:8bb2bd97c319 | 58 | * @peram prite_param |
| evanso | 16:1ee3d3804557 | 59 | */ |
| evanso | 27:8bb2bd97c319 | 60 | void set_spaceship_peram(int x_change,int y_change, bool sprite_change, |
| evanso | 27:8bb2bd97c319 | 61 | bool sprite_param); |
| evanso | 11:ab578a151f67 | 62 | |
| evanso | 27:8bb2bd97c319 | 63 | /** Checks sapceship x and y position and stops spacship comming of the |
| evanso | 27:8bb2bd97c319 | 64 | * screen in y direction. Keeps spaceship in middle 3rd of screen in |
| evanso | 27:8bb2bd97c319 | 65 | * x direction |
| evanso | 16:1ee3d3804557 | 66 | */ |
| evanso | 6:12e8433382b3 | 67 | void off_screen_x_y_checker(); |
| evanso | 3:dee187b8b30c | 68 | }; |
| evanso | 3:dee187b8b30c | 69 | |
| evanso | 3:dee187b8b30c | 70 | #endif |