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.
Brick/Brick.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 | 1:e18615d46071 | 1 | #ifndef BRICK_H |
| jamesheavey | 1:e18615d46071 | 2 | #define BRICK_H |
| jamesheavey | 1:e18615d46071 | 3 | |
| jamesheavey | 1:e18615d46071 | 4 | #include "mbed.h" |
| jamesheavey | 1:e18615d46071 | 5 | #include "N5110.h" |
| jamesheavey | 1:e18615d46071 | 6 | #include "Gamepad.h" |
| jamesheavey | 1:e18615d46071 | 7 | |
| jamesheavey | 86:01f33d94e496 | 8 | #define BRICK_WIDTH 12 |
| jamesheavey | 86:01f33d94e496 | 9 | #define BRICK_HEIGHT 4 |
| jamesheavey | 86:01f33d94e496 | 10 | |
| jamesheavey | 129:b47c28c7eaaf | 11 | /** Brick Class |
| jamesheavey | 86:01f33d94e496 | 12 | @author James Heavey, University of Leeds |
| jamesheavey | 91:c01a736fb0d9 | 13 | @brief Controls the bricks in the Breakout game |
| jamesheavey | 86:01f33d94e496 | 14 | @date May 2019 |
| jamesheavey | 91:c01a736fb0d9 | 15 | */ |
| jamesheavey | 86:01f33d94e496 | 16 | |
| jamesheavey | 1:e18615d46071 | 17 | class Brick |
| jamesheavey | 1:e18615d46071 | 18 | { |
| jamesheavey | 1:e18615d46071 | 19 | public: |
| jamesheavey | 1:e18615d46071 | 20 | |
| jamesheavey | 129:b47c28c7eaaf | 21 | /** Constructor declaration */ |
| jamesheavey | 1:e18615d46071 | 22 | Brick(); |
| jamesheavey | 129:b47c28c7eaaf | 23 | |
| jamesheavey | 129:b47c28c7eaaf | 24 | /** Destructor declaration */ |
| jamesheavey | 1:e18615d46071 | 25 | ~Brick(); |
| jamesheavey | 129:b47c28c7eaaf | 26 | |
| jamesheavey | 129:b47c28c7eaaf | 27 | /** Initialise Brick attributes |
| jamesheavey | 129:b47c28c7eaaf | 28 | * @param x @details initialises x coordinate |
| jamesheavey | 129:b47c28c7eaaf | 29 | * @param y @details initialises y coordinate |
| jamesheavey | 129:b47c28c7eaaf | 30 | * @param lives @details initialises the number of lives |
| jamesheavey | 129:b47c28c7eaaf | 31 | */ |
| jamesheavey | 86:01f33d94e496 | 32 | void init(int x,int y, int lives); |
| jamesheavey | 129:b47c28c7eaaf | 33 | |
| jamesheavey | 129:b47c28c7eaaf | 34 | /** Draws the Brick on the LCD, at current coordinates with a fill that is dependant on _lives |
| jamesheavey | 130:46f3fac2bdf9 | 35 | * @param lcd @details a N5110 pointer |
| jamesheavey | 129:b47c28c7eaaf | 36 | */ |
| jamesheavey | 1:e18615d46071 | 37 | void draw(N5110 &lcd); |
| jamesheavey | 129:b47c28c7eaaf | 38 | |
| jamesheavey | 129:b47c28c7eaaf | 39 | /** Sets the Brick's x coordinate |
| jamesheavey | 129:b47c28c7eaaf | 40 | * @param x @details set the member variable _x to the new local x |
| jamesheavey | 129:b47c28c7eaaf | 41 | */ |
| jamesheavey | 129:b47c28c7eaaf | 42 | void set_posx(int x); |
| jamesheavey | 129:b47c28c7eaaf | 43 | |
| jamesheavey | 129:b47c28c7eaaf | 44 | /** Resets the lives after victory |
| jamesheavey | 129:b47c28c7eaaf | 45 | * @param inc @details additional lives added on t o the _base_lives (additional lives come from _multiplier) |
| jamesheavey | 129:b47c28c7eaaf | 46 | */ |
| jamesheavey | 129:b47c28c7eaaf | 47 | void reset_lives(int inc); |
| jamesheavey | 129:b47c28c7eaaf | 48 | |
| jamesheavey | 129:b47c28c7eaaf | 49 | /** Decrements the member variable _lives |
| jamesheavey | 129:b47c28c7eaaf | 50 | * @return returns a bool; true if brick is destroyed, false if not |
| jamesheavey | 129:b47c28c7eaaf | 51 | */ |
| jamesheavey | 32:4dba7a85dbb2 | 52 | bool hit(); |
| jamesheavey | 129:b47c28c7eaaf | 53 | |
| jamesheavey | 129:b47c28c7eaaf | 54 | /** Retrieves the Brick's x coordinate |
| jamesheavey | 129:b47c28c7eaaf | 55 | * @returns integer _x coordinate |
| jamesheavey | 129:b47c28c7eaaf | 56 | */ |
| jamesheavey | 34:07ded1f83c59 | 57 | int get_x(); |
| jamesheavey | 129:b47c28c7eaaf | 58 | |
| jamesheavey | 129:b47c28c7eaaf | 59 | /** Retrieves the Brick's y coordinate |
| jamesheavey | 129:b47c28c7eaaf | 60 | * @returns integer _y coordinate |
| jamesheavey | 129:b47c28c7eaaf | 61 | */ |
| jamesheavey | 34:07ded1f83c59 | 62 | int get_y(); |
| jamesheavey | 1:e18615d46071 | 63 | |
| jamesheavey | 1:e18615d46071 | 64 | private: |
| jamesheavey | 1:e18615d46071 | 65 | |
| jamesheavey | 1:e18615d46071 | 66 | int _height; |
| jamesheavey | 1:e18615d46071 | 67 | int _width; |
| jamesheavey | 1:e18615d46071 | 68 | int _x; |
| jamesheavey | 1:e18615d46071 | 69 | int _y; |
| jamesheavey | 1:e18615d46071 | 70 | int _lives; |
| jamesheavey | 65:ec89c0b74a71 | 71 | int _base_lives; |
| jamesheavey | 1:e18615d46071 | 72 | |
| jamesheavey | 1:e18615d46071 | 73 | }; |
| jamesheavey | 1:e18615d46071 | 74 | #endif |