James Heavey / Mbed 2 deprecated 2665-Breakout-Game

Dependencies:   mbed

Committer:
jamesheavey
Date:
Tue Jan 05 01:14:11 2021 +0000
Revision:
0:92b180c8d407
test

Who changed what in which revision?

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