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 BALL_H
jamesheavey 0:92b180c8d407 2 #define BALL_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 #define BALL_SIZE 2
jamesheavey 0:92b180c8d407 10 #define BALL_SPEED 2
jamesheavey 0:92b180c8d407 11
jamesheavey 0:92b180c8d407 12 /** Ball Class
jamesheavey 0:92b180c8d407 13 @author James Heavey, University of Leeds
jamesheavey 0:92b180c8d407 14 @brief Controls the ball in the Breakout game
jamesheavey 0:92b180c8d407 15 @date May 2019
jamesheavey 0:92b180c8d407 16 */
jamesheavey 0:92b180c8d407 17
jamesheavey 0:92b180c8d407 18 class Ball
jamesheavey 0:92b180c8d407 19 {
jamesheavey 0:92b180c8d407 20
jamesheavey 0:92b180c8d407 21 public:
jamesheavey 0:92b180c8d407 22
jamesheavey 0:92b180c8d407 23 /** Constructor declaration */
jamesheavey 0:92b180c8d407 24 Ball();
jamesheavey 0:92b180c8d407 25
jamesheavey 0:92b180c8d407 26 /** Destructor declaration */
jamesheavey 0:92b180c8d407 27 ~Ball();
jamesheavey 0:92b180c8d407 28
jamesheavey 0:92b180c8d407 29 /** Initialise Ball attributes
jamesheavey 0:92b180c8d407 30 * @param size @details initialises _size
jamesheavey 0:92b180c8d407 31 * @param speed @details initialises _speed
jamesheavey 0:92b180c8d407 32 * @param x @details initialises the _x coordinate over the centre of the paddle
jamesheavey 0:92b180c8d407 33 */
jamesheavey 0:92b180c8d407 34 void init(int size,int speed,int x);
jamesheavey 0:92b180c8d407 35
jamesheavey 0:92b180c8d407 36 /** Draws the Ball at at its current coordinates on the LCD
jamesheavey 0:92b180c8d407 37 * @param lcd @details a N5110 pointer
jamesheavey 0:92b180c8d407 38 */
jamesheavey 0:92b180c8d407 39 void draw(N5110 &lcd);
jamesheavey 0:92b180c8d407 40
jamesheavey 0:92b180c8d407 41 /** Update the Laser's x and y coordinates based on its velocity */
jamesheavey 0:92b180c8d407 42 void update();
jamesheavey 0:92b180c8d407 43
jamesheavey 0:92b180c8d407 44 /** Set the Ball's x and y velocities
jamesheavey 0:92b180c8d407 45 * @param v @details a vector of the x and y velocities
jamesheavey 0:92b180c8d407 46 */
jamesheavey 0:92b180c8d407 47 void set_velocity(Vector2D v);
jamesheavey 0:92b180c8d407 48
jamesheavey 0:92b180c8d407 49 /** Set the Ball's x and y coordinates
jamesheavey 0:92b180c8d407 50 * @param p @details a vector of the x and y velocities
jamesheavey 0:92b180c8d407 51 */
jamesheavey 0:92b180c8d407 52 void set_pos(Vector2D p);
jamesheavey 0:92b180c8d407 53
jamesheavey 0:92b180c8d407 54 /** Retrieves the Ball's x and y velocities
jamesheavey 0:92b180c8d407 55 * @returns a vector of the x and y velocities
jamesheavey 0:92b180c8d407 56 */
jamesheavey 0:92b180c8d407 57 Vector2D get_velocity();
jamesheavey 0:92b180c8d407 58
jamesheavey 0:92b180c8d407 59 /** Retrieves the Ball's x and y velocities
jamesheavey 0:92b180c8d407 60 * @returns a vector of the x and y velocities
jamesheavey 0:92b180c8d407 61 */
jamesheavey 0:92b180c8d407 62 Vector2D get_pos();
jamesheavey 0:92b180c8d407 63
jamesheavey 0:92b180c8d407 64
jamesheavey 0:92b180c8d407 65
jamesheavey 0:92b180c8d407 66 private:
jamesheavey 0:92b180c8d407 67
jamesheavey 0:92b180c8d407 68 Vector2D _velocity;
jamesheavey 0:92b180c8d407 69 int _size;
jamesheavey 0:92b180c8d407 70 int _x;
jamesheavey 0:92b180c8d407 71 int _y;
jamesheavey 0:92b180c8d407 72 };
jamesheavey 0:92b180c8d407 73 #endif