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.
Paddle/Paddle.h@130:46f3fac2bdf9, 2019-05-08 (annotated)
- Committer:
- jamesheavey
- Date:
- Wed May 08 23:35:45 2019 +0000
- Revision:
- 130:46f3fac2bdf9
- Parent:
- 129:b47c28c7eaaf
- Child:
- 131:c227bbfb38b0
doxy update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jamesheavey | 0:7d4d2023ed9c | 1 | #ifndef PADDLE_H |
jamesheavey | 0:7d4d2023ed9c | 2 | #define PADDLE_H |
jamesheavey | 0:7d4d2023ed9c | 3 | |
jamesheavey | 0:7d4d2023ed9c | 4 | #include "mbed.h" |
jamesheavey | 0:7d4d2023ed9c | 5 | #include "N5110.h" |
jamesheavey | 0:7d4d2023ed9c | 6 | #include "Gamepad.h" |
jamesheavey | 0:7d4d2023ed9c | 7 | |
jamesheavey | 86:01f33d94e496 | 8 | #define PADDLE_WIDTH 15 |
jamesheavey | 86:01f33d94e496 | 9 | #define PADDLE_HEIGHT 2 |
jamesheavey | 86:01f33d94e496 | 10 | |
jamesheavey | 129:b47c28c7eaaf | 11 | /** Paddle Class |
jamesheavey | 86:01f33d94e496 | 12 | @author James Heavey, University of Leeds |
jamesheavey | 91:c01a736fb0d9 | 13 | @brief Controls the paddle in the Breakout game |
jamesheavey | 86:01f33d94e496 | 14 | @date May 2019 |
jamesheavey | 91:c01a736fb0d9 | 15 | */ |
jamesheavey | 86:01f33d94e496 | 16 | |
jamesheavey | 0:7d4d2023ed9c | 17 | class Paddle |
jamesheavey | 0:7d4d2023ed9c | 18 | { |
jamesheavey | 0:7d4d2023ed9c | 19 | public: |
jamesheavey | 129:b47c28c7eaaf | 20 | |
jamesheavey | 129:b47c28c7eaaf | 21 | /** Constructor declaration */ |
jamesheavey | 0:7d4d2023ed9c | 22 | Paddle(); |
jamesheavey | 129:b47c28c7eaaf | 23 | |
jamesheavey | 129:b47c28c7eaaf | 24 | /** Destructor declaration */ |
jamesheavey | 0:7d4d2023ed9c | 25 | ~Paddle(); |
jamesheavey | 129:b47c28c7eaaf | 26 | |
jamesheavey | 129:b47c28c7eaaf | 27 | /** Initialise Paddle attributes |
jamesheavey | 129:b47c28c7eaaf | 28 | * @param y @details initialises the _y value at the correct value on screen |
jamesheavey | 129:b47c28c7eaaf | 29 | * @param height @details sets the height of the paddle |
jamesheavey | 129:b47c28c7eaaf | 30 | * @param width @details sets the width of the paddle |
jamesheavey | 129:b47c28c7eaaf | 31 | */ |
jamesheavey | 129:b47c28c7eaaf | 32 | void init(int y,int height,int width); |
jamesheavey | 129:b47c28c7eaaf | 33 | |
jamesheavey | 129:b47c28c7eaaf | 34 | /** Draws the Paddle at at its current coordinates on the LCD |
jamesheavey | 130:46f3fac2bdf9 | 35 | * @param lcd @details a N5110 pointer |
jamesheavey | 129:b47c28c7eaaf | 36 | */ |
jamesheavey | 0:7d4d2023ed9c | 37 | void draw(N5110 &lcd); |
jamesheavey | 129:b47c28c7eaaf | 38 | |
jamesheavey | 129:b47c28c7eaaf | 39 | /** Update the Paddle's velocity according to the Gamepad input, then update coordinates accordingly |
jamesheavey | 130:46f3fac2bdf9 | 40 | * @param pad @details a Gamepad pointer |
jamesheavey | 129:b47c28c7eaaf | 41 | */ |
jamesheavey | 0:7d4d2023ed9c | 42 | void update(Direction d,float mag); |
jamesheavey | 129:b47c28c7eaaf | 43 | |
jamesheavey | 129:b47c28c7eaaf | 44 | /** Decrement the member variable _lives */ |
jamesheavey | 9:f6f0f39538c7 | 45 | void lose_life(); |
jamesheavey | 129:b47c28c7eaaf | 46 | |
jamesheavey | 129:b47c28c7eaaf | 47 | /** Increment the member variable _lives */ |
jamesheavey | 114:280903dd7e06 | 48 | void inc_life(); |
jamesheavey | 129:b47c28c7eaaf | 49 | |
jamesheavey | 129:b47c28c7eaaf | 50 | /** Set the member variable _lives to 6 */ |
jamesheavey | 129:b47c28c7eaaf | 51 | void reset_lives(); |
jamesheavey | 129:b47c28c7eaaf | 52 | |
jamesheavey | 129:b47c28c7eaaf | 53 | /** Retrieves the Paddle's lives remaining |
jamesheavey | 129:b47c28c7eaaf | 54 | * @returns the member variable _lives |
jamesheavey | 129:b47c28c7eaaf | 55 | */ |
jamesheavey | 9:f6f0f39538c7 | 56 | int get_lives(); |
jamesheavey | 129:b47c28c7eaaf | 57 | |
jamesheavey | 129:b47c28c7eaaf | 58 | /** Sets the member varible _tilt to true */ |
jamesheavey | 16:1761dfe801af | 59 | void set_tilt(); |
jamesheavey | 129:b47c28c7eaaf | 60 | |
jamesheavey | 129:b47c28c7eaaf | 61 | /** Set the member variable _tilt to false */ |
jamesheavey | 16:1761dfe801af | 62 | void set_joy(); |
jamesheavey | 129:b47c28c7eaaf | 63 | |
jamesheavey | 129:b47c28c7eaaf | 64 | /** Set the member variable _sens |
jamesheavey | 129:b47c28c7eaaf | 65 | * @param sens @details sets _sens to local variable sens |
jamesheavey | 129:b47c28c7eaaf | 66 | */ |
jamesheavey | 129:b47c28c7eaaf | 67 | void set_sens(float sens); |
jamesheavey | 129:b47c28c7eaaf | 68 | |
jamesheavey | 129:b47c28c7eaaf | 69 | /** Set the _x coordinate to the middle of the screen */ |
jamesheavey | 69:db1354676fde | 70 | void recentre(); |
jamesheavey | 129:b47c28c7eaaf | 71 | |
jamesheavey | 129:b47c28c7eaaf | 72 | /** Retrieves the Paddle's x and y velocities |
jamesheavey | 129:b47c28c7eaaf | 73 | * @returns a vector of the x and y velocities |
jamesheavey | 129:b47c28c7eaaf | 74 | */ |
jamesheavey | 129:b47c28c7eaaf | 75 | Vector2D get_pos(); |
jamesheavey | 0:7d4d2023ed9c | 76 | |
jamesheavey | 0:7d4d2023ed9c | 77 | private: |
jamesheavey | 0:7d4d2023ed9c | 78 | |
jamesheavey | 0:7d4d2023ed9c | 79 | int _height; |
jamesheavey | 0:7d4d2023ed9c | 80 | int _width; |
jamesheavey | 0:7d4d2023ed9c | 81 | int _x; |
jamesheavey | 0:7d4d2023ed9c | 82 | int _y; |
jamesheavey | 0:7d4d2023ed9c | 83 | int _speed; |
jamesheavey | 0:7d4d2023ed9c | 84 | int _score; |
jamesheavey | 9:f6f0f39538c7 | 85 | int _lives; |
jamesheavey | 72:7254d2a8a1cd | 86 | float _sens; |
jamesheavey | 16:1761dfe801af | 87 | bool _tilt; |
jamesheavey | 0:7d4d2023ed9c | 88 | |
jamesheavey | 91:c01a736fb0d9 | 89 | |
jamesheavey | 0:7d4d2023ed9c | 90 | }; |
jamesheavey | 0:7d4d2023ed9c | 91 | #endif |