Class containing methods to draw a ball within the maze game with the specified position, size and fill style parameters.
Diff: Ball.h
- Revision:
- 3:569a3f2786ec
- Parent:
- 2:bcb96ab2848b
diff -r bcb96ab2848b -r 569a3f2786ec Ball.h --- a/Ball.h Wed May 03 21:13:45 2017 +0000 +++ b/Ball.h Thu May 04 14:01:56 2017 +0000 @@ -1,20 +1,9 @@ -/* - - @file Ball.h - - (c) Max Houghton 02.14.17 - Roller Maze Project, ELEC2645, Univeristy of Leeds - +/** Ball Class + @brief Class contains necessary parameters to draw the ball of the correct position, size and fill style. + @author Max Houghton + @date March 19 2017 */ -// -// ball.h -// -// -// Created by Max Houghton on 19/03/2017. -// -// - #ifndef BALL_H #define BALL_H @@ -27,29 +16,104 @@ public: + /** + * @details - constructor + */ Ball(); + + /** + * @details - destructor + */ ~Ball(); + /** Initialise Ball + * + * @details - Initiases the ball with the appropriate different parameters chosen by user. + * @param - x - specifies the x coordinate for the starting position of the ball. + * @param - y - specifies the y coordinate for the starting position of the ball. + * @param - radius - specifies size of the ball to be drawn. + * @param - colour - specifies if the ball is either transparent or filled. + */ void init(float x, float y, int radius, bool colour); + + /** Update + * + * @details - Function takes the 2D Vector 'position' and updates the current position of the ball by adding on the values of 'position'. + * @param - position - 2D Vector struct passed down by engine containing values for the centre of the ball for the next iteration. + * + */ void update(Vector2D position); + + /** Draw + * + * @details - Function draws the ball using the current set values for the centre of the ball and its radius. + * @param - lcd - N5110 Library used to draw the circle representing the ball. + * + */ void draw(N5110 &lcd); + /** Get Position + * + * @details - Function returns a 2D Vector struct containing information about the ball's current position. This is used when checking for wall collisions in the Maze Engine class. + * + */ Vector2D getPosition(); + + /** Get Velocity + * + * @details - Function returns a 2D Vector struct containing information about the ball's next position. + * + */ Vector2D getVelocity(); + /** Set Position + * + * @details - This function dictates the position of the ball for the next update of the game. It is used in the wall collision check and goal check functions. + * @param - p - 2D Vector struct containing the location of the ball to be set to. + * + */ void setPosition(Vector2D p); + + /** Set Velocity + * + * @details - This decides where the ball is to travel next. + * @param - v - 2D Vector struct which has the location of the ball for the next iteration. + * + */ void setVelocity(Vector2D v); private: + /** + * @details - Struct containing x and y values for the following position of the ball + */ Vector2D velocity; + /** Check For Interference + * + * @details - When using the accelerometer data for position values, small but non-zero values can cause the ball undesirably. This function removes all small values of the data ensuring the ball only moves according to deliberate movements of the accelerometer. + * + */ Vector2D checkForInterference(Vector2D velocity); + /** + * @param - _radius - Integer to decide size of the ball to be drawn. + */ int _radius; + /** + * @param - _x - Float value specifying x coordinate of centre of ball. + */ float _x; + + /** + * @param - _y - Float value specifying y coordinate of centre of ball. + */ float _y; + + /** + * @param - _colour - Boolean value specifying fill style of the ball; true corresponds to transparent fill and false to solid fill. + */ bool _colour; };