Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Ball/Ball.h
- Revision:
- 37:de1f584bce71
- Parent:
- 29:42651f87522b
- Child:
- 38:a85bc227b907
--- a/Ball/Ball.h Mon May 06 00:05:52 2019 +0000
+++ b/Ball/Ball.h Mon May 06 21:44:49 2019 +0000
@@ -10,24 +10,78 @@
class Ball {
public:
-//constructor method
+ /**
+ * @brief Create a Ball object
+ */
Ball();
-//destructor method
+ /**
+ * @brief Delete a ball member to free up memory
+ */
~Ball();
-//methods for engine
+
+ /** Initialise ball object
+ *
+ * Sets the initial position of the ball to the centre of the LCD display.
+ * Sets the initial velocity of the ball to 0 and the sensitivity of the
+ * ball to 5/10.
+ * @param radius - integer for radius of the ball
+ */
void init(int radius);
+ /**
+ * @brief read the input from the accelerometer and convert it to an instantaneous velocity
+ * for the ball.
+ * @param accelerometer - FXOS8700CQ object to retrieve acceleromter readings
+ */
void read_input(FXOS8700CQ &accelerometer);
+ /**
+ * @brief update the coordinates of the ball within the range of the screen
+ */
void update();
+ /**
+ * @brief render the ball onto the LCD screen
+ * @param lcd - N5110 object to interface with the LCD
+ */
void draw(N5110 &lcd);
-//accessor methods
+ /**
+ * @brief get the instantaneous velocity of the ball
+ * @returns x and y velocities of the ball in a 2D vector
+ */
Vector2D get_velocity();
+ /**
+ * @brief get the instantaneous position of the ball
+ * @returns x and y positions in a 2D vector. 0 < x < 83 and 0 < y < 47.
+ */
Vector2D get_position();
+ /**
+ * @brief get the radius of the ball
+ * @returns radius of the ball as an integer
+ */
int get_radius();
+ /**
+ * @brief get the speed multiplying factor of the ball. Essentially the sensitivity
+ * to the accelerometer input
+ * @returns ball speed multiplier as an integer in the range 1-10
+ */
int get_ball_speed();
-//mutator methods
- void set_ball_speed(int ball_speed); //this is a constant multiplier for the ball velocity in both axes
- void set_velocity(Vector2D vel); //this is used to set the velocity at one specific instant in the code
+ /**
+ * @brief Set the sensitivity of the ball's motion to the accelerometer input
+ * @param ball_speed - integer in the range 1-10
+ */
+ void set_ball_speed(int ball_speed);
+ /**
+ * @brief set the instantaneous velocities in the x and y directions
+ * @param vel - a 2D vector (using the gamepad class) of the desired x and y velocities
+ */
+ void set_velocity(Vector2D vel);
+ /**
+ * @brief set the instantaneous x and y positions of the ball
+ * @param pos - a 2D vector (using the gamepad class) of the desired x and y coordinates
+ */
void set_position(Vector2D pos);
+ /**
+ * @brief set the radius of the ball
+ * @param radius - integer value
+ */
void set_radius(int radius);
private: