ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Committer:
shahidsajid
Date:
Tue May 07 17:50:58 2019 +0000
Revision:
28:d0b0a64a832d
Parent:
26:6427f09cf8d3
Child:
29:f7a2d2a755ec
Documented the bat and ball class;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shahidsajid 4:55a0509c4874 1 #ifndef BAT_H
shahidsajid 4:55a0509c4874 2 #define BAT_H
shahidsajid 4:55a0509c4874 3
shahidsajid 4:55a0509c4874 4 #include "mbed.h"
shahidsajid 4:55a0509c4874 5 #include "N5110.h"
shahidsajid 4:55a0509c4874 6 #include "Gamepad.h"
shahidsajid 21:a0904159e183 7 #include "UX.h"
shahidsajid 4:55a0509c4874 8
shahidsajid 26:6427f09cf8d3 9 /** Bat Class
shahidsajid 26:6427f09cf8d3 10 @author Shahid Zubin Sajid,
shahidsajid 26:6427f09cf8d3 11 @brief Bat charactersitics and checks for collisions
shahidsajid 4:55a0509c4874 12 @date Febraury 2017
shahidsajid 4:55a0509c4874 13 */
shahidsajid 4:55a0509c4874 14 class Bat
shahidsajid 4:55a0509c4874 15 {
shahidsajid 4:55a0509c4874 16
shahidsajid 4:55a0509c4874 17 public:
shahidsajid 4:55a0509c4874 18 Bat();
shahidsajid 4:55a0509c4874 19 ~Bat();
shahidsajid 28:d0b0a64a832d 20 /**
shahidsajid 28:d0b0a64a832d 21 * @brief Initlialises the Bat class
shahidsajid 28:d0b0a64a832d 22 * @details Sets the Bat's position and sets the batting variables to 0
shahidsajid 28:d0b0a64a832d 23 */
shahidsajid 4:55a0509c4874 24 void init(int x,int y);
shahidsajid 28:d0b0a64a832d 25 /**
shahidsajid 28:d0b0a64a832d 26 * @brief Prints the bat to the LCD at the inititialised co-ordinates
shahidsajid 28:d0b0a64a832d 27 * @param &lcd @details reference object for a N5110 class object
shahidsajid 28:d0b0a64a832d 28 */
shahidsajid 4:55a0509c4874 29 void draw(N5110 &lcd);
shahidsajid 28:d0b0a64a832d 30 /**
shahidsajid 28:d0b0a64a832d 31 * @brief Resets the batting variables to 0
shahidsajid 28:d0b0a64a832d 32 * param &lcd @details reference pointer for the LCD
shahidsajid 28:d0b0a64a832d 33 */
shahidsajid 26:6427f09cf8d3 34 void reset();
shahidsajid 26:6427f09cf8d3 35
shahidsajid 28:d0b0a64a832d 36 //accessors and mutators
shahidsajid 28:d0b0a64a832d 37 /**
shahidsajid 28:d0b0a64a832d 38 * @brief Checks if the ball has been hit with the bat during each round
shahidsajid 28:d0b0a64a832d 39 * @param @ux @details takes a UserExperience object to check if Button A has been pressed
shahidsajid 28:d0b0a64a832d 40 * @returns a boolean value true if ball has been hit during the round and false if ball was missed
shahidsajid 28:d0b0a64a832d 41 */
shahidsajid 21:a0904159e183 42 int get_hitBall(UX &ux);
shahidsajid 28:d0b0a64a832d 43 /**
shahidsajid 28:d0b0a64a832d 44 * @brief Checks if the hit was a lofted hit
shahidsajid 28:d0b0a64a832d 45 * @param @ux @details takes a UserExperience object to check if Button L has been pressed
shahidsajid 28:d0b0a64a832d 46 * @returns a boolean value true if button L is pressed during the round and false if button L is not pressed
shahidsajid 28:d0b0a64a832d 47 */
shahidsajid 21:a0904159e183 48 int get_loft_ball(UX &ux);
shahidsajid 14:122eaa3b7a50 49
shahidsajid 4:55a0509c4874 50
shahidsajid 4:55a0509c4874 51 private:
shahidsajid 14:122eaa3b7a50 52
shahidsajid 28:d0b0a64a832d 53 // Seperate Gamepad has been used in this class because Gamepad obect
shahidsajid 28:d0b0a64a832d 54 //from the main class had issues with the CHECK_EVENT Function. The function was not responsive
shahidsajid 28:d0b0a64a832d 55 // and could not be resolved and as a result the only suitable solution was to create another object
shahidsajid 14:122eaa3b7a50 56
shahidsajid 28:d0b0a64a832d 57 //integer variable used to check if ball is Hit, the variable is essentially used as a flag
shahidsajid 28:d0b0a64a832d 58 // in the cricket method
shahidsajid 6:3e50f2cf4366 59 int _hitBall;
shahidsajid 28:d0b0a64a832d 60
shahidsajid 28:d0b0a64a832d 61 //integer variable used to check if the hit is lofted, the variable is essentially used as a flag
shahidsajid 28:d0b0a64a832d 62 // in the cricket class
shahidsajid 13:924891519a95 63 int _loft_ball;
shahidsajid 28:d0b0a64a832d 64
shahidsajid 28:d0b0a64a832d 65 //Direction of the ball
shahidsajid 4:55a0509c4874 66 int d;
shahidsajid 28:d0b0a64a832d 67
shahidsajid 28:d0b0a64a832d 68 //x co-ordinate for the bat to be printed on the LCD
shahidsajid 26:6427f09cf8d3 69 int _bat_x;
shahidsajid 28:d0b0a64a832d 70 //y co-ordinate for the bat to be printed on the LCD
shahidsajid 26:6427f09cf8d3 71 int _bat_y;
shahidsajid 4:55a0509c4874 72 };
shahidsajid 4:55a0509c4874 73 #endif