James Heavey / Mbed 2 deprecated 2665-Breakout-Game

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Brick.h Source File

Brick.h

00001 #ifndef BRICK_H
00002 #define BRICK_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 
00008 #define BRICK_WIDTH 12
00009 #define BRICK_HEIGHT 4
00010 
00011 /** Brick Class
00012 @author James Heavey, University of Leeds
00013 @brief Controls the bricks in the Breakout game
00014 @date May 2019
00015 */
00016 
00017 class Brick
00018 {
00019 public:
00020 
00021     /** Constructor declaration */
00022     Brick();
00023     
00024     /** Destructor declaration */
00025     ~Brick();
00026     
00027     /** Initialise Brick attributes
00028     * @param x @details initialises x coordinate
00029     * @param y @details initialises y coordinate
00030     * @param lives @details initialises the number of lives
00031     */
00032     void init(int x,int y, int lives);
00033     
00034     /** Draws the Brick on the LCD, at current coordinates with a fill that is dependant on _lives
00035     * @param lcd @details a N5110 pointer
00036     */
00037     void draw(N5110 &lcd);
00038     
00039     /** Sets the Brick's x coordinate
00040     * @param x @details set the  variable _x to the new local x
00041     */
00042     void set_posx(int x);
00043     
00044     /** Resets the lives after victory
00045     * @param inc @details additional lives added on t o the _base_lives (additional lives come from _multiplier)
00046     */
00047     void reset_lives(int inc);
00048     
00049     /** Decrements the  variable _lives
00050     * @returns a bool; true if brick is destroyed, false if not
00051     */
00052     bool hit();
00053     
00054     /** Retrieves the Brick's x coordinate
00055     * @returns integer _x coordinate
00056     */
00057     int get_x();
00058     
00059     /** Retrieves the Brick's y coordinate
00060     * @returns integer _y coordinate
00061     */
00062     int get_y();
00063 
00064 private:
00065 
00066     int _height;
00067     int _width;
00068     int _x;
00069     int _y;
00070     int _lives;
00071     int _base_lives;
00072 
00073 };
00074 #endif