ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Committer:
shahidsajid
Date:
Wed May 08 13:30:12 2019 +0000
Revision:
33:9d34ef219fff
Parent:
32:1bc731f03a30
Parent:
8:7b7e1a5b8200
Fixed Documentation Errors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shahidsajid 3:bd3465a70a5a 1 #ifndef BALL_H
shahidsajid 3:bd3465a70a5a 2 #define BALL_H
shahidsajid 3:bd3465a70a5a 3
shahidsajid 3:bd3465a70a5a 4 #include "mbed.h"
shahidsajid 3:bd3465a70a5a 5 #include "N5110.h"
shahidsajid 3:bd3465a70a5a 6 #include "Gamepad.h"
shahidsajid 6:3e50f2cf4366 7 #include "Bat.h"
shahidsajid 3:bd3465a70a5a 8 /** Ball Class
shahidsajid 32:1bc731f03a30 9 * @author Shahid Zubin Sajid
shahidsajid 32:1bc731f03a30 10 * @brief Controls the ball in the Hero Cricket Game
shahidsajid 32:1bc731f03a30 11 * @date May 2019
shahidsajid 30:43aace0fdbdf 12 */
shahidsajid 3:bd3465a70a5a 13 class Ball
shahidsajid 3:bd3465a70a5a 14 {
shahidsajid 3:bd3465a70a5a 15
shahidsajid 3:bd3465a70a5a 16 public:
shahidsajid 32:1bc731f03a30 17 /** Constructor */
shahidsajid 3:bd3465a70a5a 18 Ball();
shahidsajid 32:1bc731f03a30 19 /** Deconstructor */
shahidsajid 3:bd3465a70a5a 20 ~Ball();
shahidsajid 30:43aace0fdbdf 21 /**
shahidsajid 28:d0b0a64a832d 22 * @brief Initlialises the Bat class
shahidsajid 28:d0b0a64a832d 23 * @details Sets the Ball's starting co-ordinates and sets the class variables to 0
shahidsajid 28:d0b0a64a832d 24 */
shahidsajid 31:eefa1d23a843 25 void init(int size);
shahidsajid 30:43aace0fdbdf 26 /**
shahidsajid 28:d0b0a64a832d 27 * @brief Draws the ball onto the screen
shahidsajid 28:d0b0a64a832d 28 * @details The ball is drawn based on the current co-ordinates of the ball
shahidsajid 28:d0b0a64a832d 29 */
shahidsajid 3:bd3465a70a5a 30 void draw(N5110 &lcd);
shahidsajid 30:43aace0fdbdf 31 /**
shahidsajid 28:d0b0a64a832d 32 * @brief Resets all the variable counters for the ball
shahidsajid 30:43aace0fdbdf 33 */
shahidsajid 13:924891519a95 34 void reset();
shahidsajid 32:1bc731f03a30 35 /**
shahidsajid 28:d0b0a64a832d 36 * @brief Resets the ball count for starting each game
shahidsajid 30:43aace0fdbdf 37 */
shahidsajid 26:6427f09cf8d3 38 void reset_ball_count();
shahidsajid 30:43aace0fdbdf 39 /**
shahidsajid 28:d0b0a64a832d 40 * @brief Starts the ball from a set position
shahidsajid 28:d0b0a64a832d 41 * @details The ball's y co-ordinate is incremented during each untill the target co-odinates are reached
shahidsajid 28:d0b0a64a832d 42 * @param &pad @details Takes a reference pointer to a Gamepad object
shahidsajid 28:d0b0a64a832d 43 * @returns returns an int with 1 signifiying that the ball has reached the target co-ordinates and 0 if false
shahidsajid 28:d0b0a64a832d 44 */
shahidsajid 15:81a3aaf52647 45 int ball_start(Gamepad &pad);
shahidsajid 30:43aace0fdbdf 46
shahidsajid 3:bd3465a70a5a 47 void get_direction(Gamepad &pad);
shahidsajid 30:43aace0fdbdf 48 /**
shahidsajid 28:d0b0a64a832d 49 * @brief Returns the no. of balls played at the point in the game
shahidsajid 28:d0b0a64a832d 50 * @returns an integer value representing the no. of balls played at that point
shahidsajid 30:43aace0fdbdf 51 */
shahidsajid 18:a260ce8db9e7 52 int get_ball_count();
shahidsajid 30:43aace0fdbdf 53
shahidsajid 12:954da4f4e565 54 //void update_ball(int checkHit, Direction dir);
shahidsajid 30:43aace0fdbdf 55 /**
shahidsajid 28:d0b0a64a832d 56 * @brief Starts the ball from a set position
shahidsajid 28:d0b0a64a832d 57 * @details The ball's cordinates are adjusted according to the expected x and y cordinates
shahidsajid 28:d0b0a64a832d 58 * @param expected_x @details The expected x cordinate according to the direction of the ball
shahidsajid 28:d0b0a64a832d 59 * @param expected_y @details The expected y cordinate according to the direction of the ball
shahidsajid 28:d0b0a64a832d 60 * @returns returns an int with 1 if the expected co-ordinates have been reached
shahidsajid 28:d0b0a64a832d 61 */
shahidsajid 14:122eaa3b7a50 62 int update_ball(int expected_x,int expected_y);
shahidsajid 30:43aace0fdbdf 63 /**
shahidsajid 28:d0b0a64a832d 64 * @brief The bowler starts running in for each round
shahidsajid 28:d0b0a64a832d 65 * @details The bowler starts from y co-ordinate 0 and stops at y-ordinate 16
shahidsajid 28:d0b0a64a832d 66 * @details The y-ordinate of the bowler is incremented with each call till target co-ordinate is reached
shahidsajid 28:d0b0a64a832d 67 * @returns an integer value that returns 1 if target co-ordinate is reached and 0 if it hasn't
shahidsajid 30:43aace0fdbdf 68 */
shahidsajid 15:81a3aaf52647 69 int bowler_start(Gamepad &pad);
shahidsajid 32:1bc731f03a30 70 /**
shahidsajid 28:d0b0a64a832d 71 * @brief Increments the _ball_count variable during each call
shahidsajid 28:d0b0a64a832d 72 */
shahidsajid 18:a260ce8db9e7 73 void increment_ball_count();
shahidsajid 30:43aace0fdbdf 74
shahidsajid 3:bd3465a70a5a 75 private:
shahidsajid 32:1bc731f03a30 76 /*Integer variable that stores the no. of balls played during the game*/
shahidsajid 18:a260ce8db9e7 77 int _ball_count;
shahidsajid 32:1bc731f03a30 78 /**Integer value that dictates if the bowler has bowled the ball
shahidsajid 28:d0b0a64a832d 79 the value is set to 1 if the bowler_start returns 1
shahidsajid 28:d0b0a64a832d 80 */
shahidsajid 26:6427f09cf8d3 81 int _bowled;
shahidsajid 32:1bc731f03a30 82 /**flag used to check if tone has to be played during each round*/
shahidsajid 26:6427f09cf8d3 83 int _set_tone;
shahidsajid 4:55a0509c4874 84 int d;
shahidsajid 32:1bc731f03a30 85 /** Integer variable to store the size of the ball*/
shahidsajid 3:bd3465a70a5a 86 int _size;
shahidsajid 32:1bc731f03a30 87 /**Integer variable to store the x co-rdinate of the ball*/
shahidsajid 31:eefa1d23a843 88 int _ball_x;
shahidsajid 32:1bc731f03a30 89 /**Integer variable to store the y co-ordinate of the ball*/
shahidsajid 31:eefa1d23a843 90 int _ball_y;
shahidsajid 32:1bc731f03a30 91 /**Integer variable to store t the x cordinate of the bowler*/
shahidsajid 31:eefa1d23a843 92 int _bowler_x;
shahidsajid 32:1bc731f03a30 93 /**Integer variable to store t the y cordinate of the bowler*/
shahidsajid 31:eefa1d23a843 94 int _bowler_y;
shahidsajid 3:bd3465a70a5a 95 };
shahidsajid 3:bd3465a70a5a 96 #endif