James Cummins / Mbed 2 deprecated el17jnc

Dependencies:   mbed

Ball/Ball.h

Committer:
JamesCummins
Date:
2019-05-06
Revision:
37:de1f584bce71
Parent:
29:42651f87522b
Child:
38:a85bc227b907

File content as of revision 37:de1f584bce71:

#ifndef BALL_H
#define BALL_H

#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "FXOS8700CQ.h"


class Ball {

public:
    /** 
    * @brief Create a Ball object
    */
    Ball();
    /** 
    * @brief Delete a ball member to free up memory
    */
    ~Ball();
    
    /** 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);
    /** 
    * @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();
    /** 
    * @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:
    int _radius;
    int _x;
    int _y;
    Vector2D _velocity;
    int _ball_speed;
};
#endif