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
Bat/Bat.h@29:f7a2d2a755ec, 2019-05-07 (annotated)
- Committer:
- shahidsajid
- Date:
- Tue May 07 18:38:54 2019 +0000
- Revision:
- 29:f7a2d2a755ec
- Parent:
- 28:d0b0a64a832d
- Child:
- 30:43aace0fdbdf
Completed documenting the Cricket class;
Who changed what in which revision?
| User | Revision | Line number | New 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 | 29:f7a2d2a755ec | 18 | /** |
| shahidsajid | 29:f7a2d2a755ec | 19 | * @brief Constructor for the Bat Class |
| shahidsajid | 29:f7a2d2a755ec | 20 | */ |
| shahidsajid | 4:55a0509c4874 | 21 | Bat(); |
| shahidsajid | 29:f7a2d2a755ec | 22 | /** |
| shahidsajid | 29:f7a2d2a755ec | 23 | * @brief Deconstructor for the Bat Class |
| shahidsajid | 29:f7a2d2a755ec | 24 | */ |
| shahidsajid | 4:55a0509c4874 | 25 | ~Bat(); |
| shahidsajid | 28:d0b0a64a832d | 26 | /** |
| shahidsajid | 28:d0b0a64a832d | 27 | * @brief Initlialises the Bat class |
| shahidsajid | 28:d0b0a64a832d | 28 | * @details Sets the Bat's position and sets the batting variables to 0 |
| shahidsajid | 28:d0b0a64a832d | 29 | */ |
| shahidsajid | 4:55a0509c4874 | 30 | void init(int x,int y); |
| shahidsajid | 28:d0b0a64a832d | 31 | /** |
| shahidsajid | 28:d0b0a64a832d | 32 | * @brief Prints the bat to the LCD at the inititialised co-ordinates |
| shahidsajid | 28:d0b0a64a832d | 33 | * @param &lcd @details reference object for a N5110 class object |
| shahidsajid | 28:d0b0a64a832d | 34 | */ |
| shahidsajid | 4:55a0509c4874 | 35 | void draw(N5110 &lcd); |
| shahidsajid | 28:d0b0a64a832d | 36 | /** |
| shahidsajid | 28:d0b0a64a832d | 37 | * @brief Resets the batting variables to 0 |
| shahidsajid | 28:d0b0a64a832d | 38 | * param &lcd @details reference pointer for the LCD |
| shahidsajid | 28:d0b0a64a832d | 39 | */ |
| shahidsajid | 26:6427f09cf8d3 | 40 | void reset(); |
| shahidsajid | 26:6427f09cf8d3 | 41 | |
| shahidsajid | 28:d0b0a64a832d | 42 | //accessors and mutators |
| shahidsajid | 28:d0b0a64a832d | 43 | /** |
| shahidsajid | 28:d0b0a64a832d | 44 | * @brief Checks if the ball has been hit with the bat during each round |
| shahidsajid | 28:d0b0a64a832d | 45 | * @param @ux @details takes a UserExperience object to check if Button A has been pressed |
| shahidsajid | 28:d0b0a64a832d | 46 | * @returns a boolean value true if ball has been hit during the round and false if ball was missed |
| shahidsajid | 28:d0b0a64a832d | 47 | */ |
| shahidsajid | 21:a0904159e183 | 48 | int get_hitBall(UX &ux); |
| shahidsajid | 28:d0b0a64a832d | 49 | /** |
| shahidsajid | 28:d0b0a64a832d | 50 | * @brief Checks if the hit was a lofted hit |
| shahidsajid | 28:d0b0a64a832d | 51 | * @param @ux @details takes a UserExperience object to check if Button L has been pressed |
| shahidsajid | 28:d0b0a64a832d | 52 | * @returns a boolean value true if button L is pressed during the round and false if button L is not pressed |
| shahidsajid | 28:d0b0a64a832d | 53 | */ |
| shahidsajid | 21:a0904159e183 | 54 | int get_loft_ball(UX &ux); |
| shahidsajid | 14:122eaa3b7a50 | 55 | |
| shahidsajid | 4:55a0509c4874 | 56 | |
| shahidsajid | 4:55a0509c4874 | 57 | private: |
| shahidsajid | 29:f7a2d2a755ec | 58 | |
| shahidsajid | 29:f7a2d2a755ec | 59 | /*integer variable used to check if ball is Hit, the variable is essentially used as a flag |
| shahidsajid | 29:f7a2d2a755ec | 60 | in the cricket method*/ |
| shahidsajid | 6:3e50f2cf4366 | 61 | int _hitBall; |
| shahidsajid | 28:d0b0a64a832d | 62 | |
| shahidsajid | 29:f7a2d2a755ec | 63 | /*integer variable used to check if the hit is lofted, the variable is essentially used as a flag |
| shahidsajid | 29:f7a2d2a755ec | 64 | in the cricket class */ |
| shahidsajid | 13:924891519a95 | 65 | int _loft_ball; |
| shahidsajid | 28:d0b0a64a832d | 66 | |
| shahidsajid | 28:d0b0a64a832d | 67 | //Direction of the ball |
| shahidsajid | 4:55a0509c4874 | 68 | int d; |
| shahidsajid | 28:d0b0a64a832d | 69 | |
| shahidsajid | 28:d0b0a64a832d | 70 | //x co-ordinate for the bat to be printed on the LCD |
| shahidsajid | 26:6427f09cf8d3 | 71 | int _bat_x; |
| shahidsajid | 28:d0b0a64a832d | 72 | //y co-ordinate for the bat to be printed on the LCD |
| shahidsajid | 26:6427f09cf8d3 | 73 | int _bat_y; |
| shahidsajid | 4:55a0509c4874 | 74 | }; |
| shahidsajid | 4:55a0509c4874 | 75 | #endif |