FINAL VERSION

Dependencies:   mbed

Committer:
jamesheavey
Date:
Thu May 09 14:36:51 2019 +0000
Revision:
140:d8634e76ecce
Parent:
138:55c5e7149117
Final Submission. I have read and agreed with Statement of Academic Integrity.

Who changed what in which revision?

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