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.
Laser/Laser.h@0:92b180c8d407, 2021-01-05 (annotated)
- Committer:
- jamesheavey
- Date:
- Tue Jan 05 01:14:11 2021 +0000
- Revision:
- 0:92b180c8d407
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jamesheavey | 0:92b180c8d407 | 1 | #ifndef LASER_H |
jamesheavey | 0:92b180c8d407 | 2 | #define LASER_H |
jamesheavey | 0:92b180c8d407 | 3 | |
jamesheavey | 0:92b180c8d407 | 4 | #include "mbed.h" |
jamesheavey | 0:92b180c8d407 | 5 | #include "N5110.h" |
jamesheavey | 0:92b180c8d407 | 6 | #include "Gamepad.h" |
jamesheavey | 0:92b180c8d407 | 7 | #include "Paddle.h" |
jamesheavey | 0:92b180c8d407 | 8 | |
jamesheavey | 0:92b180c8d407 | 9 | /** Laser Class |
jamesheavey | 0:92b180c8d407 | 10 | @author James Heavey, University of Leeds |
jamesheavey | 0:92b180c8d407 | 11 | @brief Controls the Laser in the Breakout game |
jamesheavey | 0:92b180c8d407 | 12 | @date May 2019 |
jamesheavey | 0:92b180c8d407 | 13 | */ |
jamesheavey | 0:92b180c8d407 | 14 | class Laser |
jamesheavey | 0:92b180c8d407 | 15 | { |
jamesheavey | 0:92b180c8d407 | 16 | |
jamesheavey | 0:92b180c8d407 | 17 | public: |
jamesheavey | 0:92b180c8d407 | 18 | |
jamesheavey | 0:92b180c8d407 | 19 | /** Constructor declaration */ |
jamesheavey | 0:92b180c8d407 | 20 | Laser(); |
jamesheavey | 0:92b180c8d407 | 21 | |
jamesheavey | 0:92b180c8d407 | 22 | /** Deconstructor declaration */ |
jamesheavey | 0:92b180c8d407 | 23 | ~Laser(); |
jamesheavey | 0:92b180c8d407 | 24 | |
jamesheavey | 0:92b180c8d407 | 25 | /** Initialises the laser off screen with a set velocity */ |
jamesheavey | 0:92b180c8d407 | 26 | void init(); |
jamesheavey | 0:92b180c8d407 | 27 | |
jamesheavey | 0:92b180c8d407 | 28 | /** Draws the Laser at at its current coordinates on the LCD |
jamesheavey | 0:92b180c8d407 | 29 | * @param lcd @details a N5110 pointer |
jamesheavey | 0:92b180c8d407 | 30 | */ |
jamesheavey | 0:92b180c8d407 | 31 | void draw(N5110 &lcd); |
jamesheavey | 0:92b180c8d407 | 32 | |
jamesheavey | 0:92b180c8d407 | 33 | /** Update the Laser's y coordinate based on its velocity */ |
jamesheavey | 0:92b180c8d407 | 34 | void update(); |
jamesheavey | 0:92b180c8d407 | 35 | |
jamesheavey | 0:92b180c8d407 | 36 | /** Sets the Laser's x coordinate |
jamesheavey | 0:92b180c8d407 | 37 | * @param x @details set the variable _x to the new local x |
jamesheavey | 0:92b180c8d407 | 38 | */ |
jamesheavey | 0:92b180c8d407 | 39 | void set_posx(int x); |
jamesheavey | 0:92b180c8d407 | 40 | |
jamesheavey | 0:92b180c8d407 | 41 | /** Sets the Laser's x coordinate |
jamesheavey | 0:92b180c8d407 | 42 | * @param y @details set the variable _y to the new local y |
jamesheavey | 0:92b180c8d407 | 43 | */ |
jamesheavey | 0:92b180c8d407 | 44 | void set_posy(int y); |
jamesheavey | 0:92b180c8d407 | 45 | |
jamesheavey | 0:92b180c8d407 | 46 | /** Retrieve the Laser's current x coordinate |
jamesheavey | 0:92b180c8d407 | 47 | * @returns variable _x as an integer |
jamesheavey | 0:92b180c8d407 | 48 | */ |
jamesheavey | 0:92b180c8d407 | 49 | int get_x(); |
jamesheavey | 0:92b180c8d407 | 50 | |
jamesheavey | 0:92b180c8d407 | 51 | /** Retrieve the Laser's current y coordinate |
jamesheavey | 0:92b180c8d407 | 52 | * @returns variable _y as an integer |
jamesheavey | 0:92b180c8d407 | 53 | */ |
jamesheavey | 0:92b180c8d407 | 54 | int get_y(); |
jamesheavey | 0:92b180c8d407 | 55 | |
jamesheavey | 0:92b180c8d407 | 56 | private: |
jamesheavey | 0:92b180c8d407 | 57 | |
jamesheavey | 0:92b180c8d407 | 58 | int _speed_y; |
jamesheavey | 0:92b180c8d407 | 59 | int _x; |
jamesheavey | 0:92b180c8d407 | 60 | int _y; |
jamesheavey | 0:92b180c8d407 | 61 | |
jamesheavey | 0:92b180c8d407 | 62 | }; |
jamesheavey | 0:92b180c8d407 | 63 | #endif |