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.
Dependencies: mbed
Ball/Ball.h
- Committer:
- shahidsajid
- Date:
- 2019-05-08
- Revision:
- 33:9d34ef219fff
- Parent:
- 32:1bc731f03a30
- Parent:
- 8:7b7e1a5b8200
File content as of revision 33:9d34ef219fff:
#ifndef BALL_H #define BALL_H #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Bat.h" /** Ball Class * @author Shahid Zubin Sajid * @brief Controls the ball in the Hero Cricket Game * @date May 2019 */ class Ball { public: /** Constructor */ Ball(); /** Deconstructor */ ~Ball(); /** * @brief Initlialises the Bat class * @details Sets the Ball's starting co-ordinates and sets the class variables to 0 */ void init(int size); /** * @brief Draws the ball onto the screen * @details The ball is drawn based on the current co-ordinates of the ball */ void draw(N5110 &lcd); /** * @brief Resets all the variable counters for the ball */ void reset(); /** * @brief Resets the ball count for starting each game */ void reset_ball_count(); /** * @brief Starts the ball from a set position * @details The ball's y co-ordinate is incremented during each untill the target co-odinates are reached * @param &pad @details Takes a reference pointer to a Gamepad object * @returns returns an int with 1 signifiying that the ball has reached the target co-ordinates and 0 if false */ int ball_start(Gamepad &pad); void get_direction(Gamepad &pad); /** * @brief Returns the no. of balls played at the point in the game * @returns an integer value representing the no. of balls played at that point */ int get_ball_count(); //void update_ball(int checkHit, Direction dir); /** * @brief Starts the ball from a set position * @details The ball's cordinates are adjusted according to the expected x and y cordinates * @param expected_x @details The expected x cordinate according to the direction of the ball * @param expected_y @details The expected y cordinate according to the direction of the ball * @returns returns an int with 1 if the expected co-ordinates have been reached */ int update_ball(int expected_x,int expected_y); /** * @brief The bowler starts running in for each round * @details The bowler starts from y co-ordinate 0 and stops at y-ordinate 16 * @details The y-ordinate of the bowler is incremented with each call till target co-ordinate is reached * @returns an integer value that returns 1 if target co-ordinate is reached and 0 if it hasn't */ int bowler_start(Gamepad &pad); /** * @brief Increments the _ball_count variable during each call */ void increment_ball_count(); private: /*Integer variable that stores the no. of balls played during the game*/ int _ball_count; /**Integer value that dictates if the bowler has bowled the ball the value is set to 1 if the bowler_start returns 1 */ int _bowled; /**flag used to check if tone has to be played during each round*/ int _set_tone; int d; /** Integer variable to store the size of the ball*/ int _size; /**Integer variable to store the x co-rdinate of the ball*/ int _ball_x; /**Integer variable to store the y co-ordinate of the ball*/ int _ball_y; /**Integer variable to store t the x cordinate of the bowler*/ int _bowler_x; /**Integer variable to store t the y cordinate of the bowler*/ int _bowler_y; }; #endif