ELEC2645 (2018/19) / Mbed 2 deprecated el17cr

Dependencies:   mbed

Committer:
el17cr
Date:
Thu May 09 06:22:13 2019 +0000
Revision:
7:cf469c3505a2
Parent:
6:85314a3d69cd
Game finished, documentation added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17cr 2:7f91a86b4dc0 1 #ifndef BALL_H
el17cr 2:7f91a86b4dc0 2 #define BALL_H
el17cr 2:7f91a86b4dc0 3
el17cr 2:7f91a86b4dc0 4 #include "mbed.h"
el17cr 2:7f91a86b4dc0 5 #include "N5110.h"
el17cr 2:7f91a86b4dc0 6 #include "Gamepad.h"
el17cr 2:7f91a86b4dc0 7
el17cr 7:cf469c3505a2 8 /** Ball class
el17cr 7:cf469c3505a2 9
el17cr 7:cf469c3505a2 10 @brief Class for creating the ball object and determining how it will move and be controlled
el17cr 7:cf469c3505a2 11
el17cr 7:cf469c3505a2 12 @version 1.0
el17cr 7:cf469c3505a2 13
el17cr 7:cf469c3505a2 14 @author Connor Rainey
el17cr 7:cf469c3505a2 15
el17cr 7:cf469c3505a2 16 @date May 2019
el17cr 7:cf469c3505a2 17
el17cr 7:cf469c3505a2 18 */
el17cr 7:cf469c3505a2 19
el17cr 2:7f91a86b4dc0 20
el17cr 2:7f91a86b4dc0 21 class Ball
el17cr 2:7f91a86b4dc0 22 {
el17cr 7:cf469c3505a2 23
el17cr 2:7f91a86b4dc0 24 public:
el17cr 7:cf469c3505a2 25 // constructor
el17cr 7:cf469c3505a2 26 /**
el17cr 7:cf469c3505a2 27 * @brief Constructs the ball object
el17cr 7:cf469c3505a2 28 * @details simple construtor that creates a trivial calibration
el17cr 7:cf469c3505a2 29 */
el17cr 7:cf469c3505a2 30 Ball();
el17cr 7:cf469c3505a2 31 // destructor
el17cr 7:cf469c3505a2 32 /**
el17cr 7:cf469c3505a2 33 * @brief Destructs the ball object
el17cr 7:cf469c3505a2 34 * @details deallocates memory location for the ball object
el17cr 7:cf469c3505a2 35 */
el17cr 7:cf469c3505a2 36 ~Ball();
el17cr 7:cf469c3505a2 37 /**
el17cr 7:cf469c3505a2 38 * @brief initialises ball object
el17cr 7:cf469c3505a2 39 * @param y @details the initial y coordinate of the ball
el17cr 7:cf469c3505a2 40 * @param size @details the size of the ball
el17cr 7:cf469c3505a2 41 */
el17cr 3:5edefa83f8f0 42 void init(int y,int size);
el17cr 7:cf469c3505a2 43 /**
el17cr 7:cf469c3505a2 44 * @brief draws the ball object
el17cr 7:cf469c3505a2 45 * @param N5110 &lcd @details The screen in which the ball is drawn on
el17cr 7:cf469c3505a2 46 */
el17cr 2:7f91a86b4dc0 47 void draw(N5110 &lcd);
el17cr 7:cf469c3505a2 48 /**
el17cr 7:cf469c3505a2 49 * @brief updates the ball object
el17cr 7:cf469c3505a2 50 * @details updates the balls position to enable it to move on the screen
el17cr 7:cf469c3505a2 51 */
el17cr 3:5edefa83f8f0 52 void update();
el17cr 3:5edefa83f8f0 53 //acessor and mutator methods
el17cr 7:cf469c3505a2 54 /**
el17cr 7:cf469c3505a2 55 * @brief sets the velocity
el17cr 7:cf469c3505a2 56 * @param v @details the velocity vector of the ball moving on the screen
el17cr 7:cf469c3505a2 57 */
el17cr 3:5edefa83f8f0 58 void set_velocity(Vector2D v);
el17cr 7:cf469c3505a2 59 /**
el17cr 7:cf469c3505a2 60 * @brief gets the velocity
el17cr 7:cf469c3505a2 61 * @returns the velocity vector of the ball moving on the screen
el17cr 7:cf469c3505a2 62 */
el17cr 3:5edefa83f8f0 63 Vector2D get_velocity();
el17cr 7:cf469c3505a2 64 /**
el17cr 7:cf469c3505a2 65 * @brief gets the postion vector of the ball on the screen
el17cr 7:cf469c3505a2 66 * @returns the position vector of the ball on the screen
el17cr 7:cf469c3505a2 67 */
el17cr 2:7f91a86b4dc0 68 Vector2D get_pos();
el17cr 7:cf469c3505a2 69 /**
el17cr 7:cf469c3505a2 70 * @brief sets the postion vector of the ball on the screen
el17cr 7:cf469c3505a2 71 * @param p @details the position vector of the ball on the screen
el17cr 7:cf469c3505a2 72 */
el17cr 3:5edefa83f8f0 73 void set_pos(Vector2D p);
el17cr 7:cf469c3505a2 74 /**
el17cr 7:cf469c3505a2 75 * @brief updates the x postion of the ball on the screen in accordance with the joystick
el17cr 7:cf469c3505a2 76 * @param d @details direction in which ball is moving along x axis
el17cr 7:cf469c3505a2 77 * @param mag @details magnitude at which the ball moves
el17cr 7:cf469c3505a2 78 */
el17cr 3:5edefa83f8f0 79 void updateX(Direction d,float mag);
el17cr 7:cf469c3505a2 80
el17cr 7:cf469c3505a2 81
el17cr 7:cf469c3505a2 82
el17cr 2:7f91a86b4dc0 83 private:
el17cr 2:7f91a86b4dc0 84
el17cr 3:5edefa83f8f0 85 Vector2D _velocity;
el17cr 3:5edefa83f8f0 86 int _size;
el17cr 6:85314a3d69cd 87 double _x;
el17cr 6:85314a3d69cd 88 double _y;
el17cr 6:85314a3d69cd 89 double _speed;
el17cr 7:cf469c3505a2 90
el17cr 2:7f91a86b4dc0 91 };
el17cr 2:7f91a86b4dc0 92 #endif
el17cr 7:cf469c3505a2 93
el17cr 7:cf469c3505a2 94