ELEC2645 (2018/19) / Mbed 2 deprecated el17cr

Dependencies:   mbed

Ball/Ball.h

Committer:
el17cr
Date:
2019-05-09
Revision:
8:8d9c5a7e57d3
Parent:
7:cf469c3505a2

File content as of revision 8:8d9c5a7e57d3:

#ifndef BALL_H
#define BALL_H

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

/** Ball class

@brief Class for creating the ball object and determining how it will move and be controlled

@version 1.0

@author Connor Rainey

@date May 2019

*/


class Ball
{

public:
    // constructor
    /**
     * @brief Constructs the ball object
     * @details simple construtor that creates a trivial calibration
     */
    Ball();
    // destructor
    /**
     * @brief Destructs the ball object
     * @details deallocates memory location for the ball object
     */
     ~Ball();
    /**
     * @brief initialises ball object
     * @param y @details the initial y coordinate of the ball
     * @param size @details the size of the ball
     */
    void init(int y,int size);
    /**
     * @brief draws the ball object
     * @param N5110 &lcd @details The screen in which the ball is drawn on
     */
    void draw(N5110 &lcd);
    /**
     * @brief updates the ball object
     * @details updates the balls position to enable it to move on the screen
     */
    void update();
    //acessor and mutator methods
    /**
     * @brief sets the velocity
     * @param v @details the velocity vector of the ball moving on the screen
     */
    void set_velocity(Vector2D v);
    /**
     * @brief gets the velocity
     * @returns the velocity vector of the ball moving on the screen
     */
    Vector2D get_velocity();
    /**
     * @brief gets the postion vector of the ball on the screen
     * @returns the position vector of the ball on the screen
     */
    Vector2D get_pos();
    /**
     * @brief sets the postion vector of the ball on the screen
     * @param p @details the position vector of the ball on the screen
     */
    void set_pos(Vector2D p);
    /**
     * @brief updates the x postion of the ball on the screen in accordance with the joystick
     * @param d @details direction in which ball is moving along x axis
     * @param mag @details magnitude at which the ball moves
     */
    void updateX(Direction d,float mag);



private:

    Vector2D _velocity;
    int _size;
    double _x;
    double _y;
    double _speed;

};
#endif