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@31:eefa1d23a843, 2019-05-08 (annotated)
- Committer:
- shahidsajid
- Date:
- Wed May 08 12:13:28 2019 +0000
- Revision:
- 31:eefa1d23a843
- Parent:
- 30:43aace0fdbdf
- Child:
- 32:1bc731f03a30
Documented and updated in-line comments for all the classes;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| shahidsajid | 30:43aace0fdbdf | 1 | |
| shahidsajid | 4:55a0509c4874 | 2 | #ifndef BAT_H |
| shahidsajid | 4:55a0509c4874 | 3 | #define BAT_H |
| shahidsajid | 4:55a0509c4874 | 4 | |
| shahidsajid | 4:55a0509c4874 | 5 | #include "mbed.h" |
| shahidsajid | 4:55a0509c4874 | 6 | #include "N5110.h" |
| shahidsajid | 4:55a0509c4874 | 7 | #include "Gamepad.h" |
| shahidsajid | 21:a0904159e183 | 8 | #include "UX.h" |
| shahidsajid | 4:55a0509c4874 | 9 | |
| shahidsajid | 26:6427f09cf8d3 | 10 | /** Bat Class |
| shahidsajid | 26:6427f09cf8d3 | 11 | @author Shahid Zubin Sajid, |
| shahidsajid | 30:43aace0fdbdf | 12 | @brief Bat charactersitics and checks for collisions |
| shahidsajid | 31:eefa1d23a843 | 13 | @date May 2019 |
| shahidsajid | 30:43aace0fdbdf | 14 | */ |
| shahidsajid | 4:55a0509c4874 | 15 | class Bat |
| shahidsajid | 4:55a0509c4874 | 16 | { |
| shahidsajid | 4:55a0509c4874 | 17 | |
| shahidsajid | 4:55a0509c4874 | 18 | public: |
| shahidsajid | 30:43aace0fdbdf | 19 | /** |
| shahidsajid | 29:f7a2d2a755ec | 20 | * @brief Constructor for the Bat Class |
| shahidsajid | 29:f7a2d2a755ec | 21 | */ |
| shahidsajid | 4:55a0509c4874 | 22 | Bat(); |
| shahidsajid | 30:43aace0fdbdf | 23 | /** |
| shahidsajid | 29:f7a2d2a755ec | 24 | * @brief Deconstructor for the Bat Class |
| shahidsajid | 29:f7a2d2a755ec | 25 | */ |
| shahidsajid | 4:55a0509c4874 | 26 | ~Bat(); |
| shahidsajid | 30:43aace0fdbdf | 27 | /** |
| shahidsajid | 28:d0b0a64a832d | 28 | * @brief Initlialises the Bat class |
| shahidsajid | 28:d0b0a64a832d | 29 | * @details Sets the Bat's position and sets the batting variables to 0 |
| shahidsajid | 28:d0b0a64a832d | 30 | */ |
| shahidsajid | 31:eefa1d23a843 | 31 | void init(int width,int height); |
| shahidsajid | 30:43aace0fdbdf | 32 | /** |
| shahidsajid | 28:d0b0a64a832d | 33 | * @brief Prints the bat to the LCD at the inititialised co-ordinates |
| shahidsajid | 28:d0b0a64a832d | 34 | * @param &lcd @details reference object for a N5110 class object |
| shahidsajid | 28:d0b0a64a832d | 35 | */ |
| shahidsajid | 4:55a0509c4874 | 36 | void draw(N5110 &lcd); |
| shahidsajid | 30:43aace0fdbdf | 37 | /** |
| shahidsajid | 28:d0b0a64a832d | 38 | * @brief Resets the batting variables to 0 |
| shahidsajid | 28:d0b0a64a832d | 39 | * param &lcd @details reference pointer for the LCD |
| shahidsajid | 28:d0b0a64a832d | 40 | */ |
| shahidsajid | 26:6427f09cf8d3 | 41 | void reset(); |
| shahidsajid | 30:43aace0fdbdf | 42 | |
| shahidsajid | 28:d0b0a64a832d | 43 | //accessors and mutators |
| shahidsajid | 30:43aace0fdbdf | 44 | /** |
| shahidsajid | 28:d0b0a64a832d | 45 | * @brief Checks if the ball has been hit with the bat during each round |
| shahidsajid | 28:d0b0a64a832d | 46 | * @param @ux @details takes a UserExperience object to check if Button A has been pressed |
| shahidsajid | 28:d0b0a64a832d | 47 | * @returns a boolean value true if ball has been hit during the round and false if ball was missed |
| shahidsajid | 28:d0b0a64a832d | 48 | */ |
| shahidsajid | 31:eefa1d23a843 | 49 | int get_hit_ball(UX &ux); |
| shahidsajid | 30:43aace0fdbdf | 50 | /** |
| shahidsajid | 28:d0b0a64a832d | 51 | * @brief Checks if the hit was a lofted hit |
| shahidsajid | 28:d0b0a64a832d | 52 | * @param @ux @details takes a UserExperience object to check if Button L has been pressed |
| shahidsajid | 28:d0b0a64a832d | 53 | * @returns a boolean value true if button L is pressed during the round and false if button L is not pressed |
| shahidsajid | 28:d0b0a64a832d | 54 | */ |
| shahidsajid | 21:a0904159e183 | 55 | int get_loft_ball(UX &ux); |
| shahidsajid | 30:43aace0fdbdf | 56 | |
| shahidsajid | 30:43aace0fdbdf | 57 | |
| shahidsajid | 4:55a0509c4874 | 58 | private: |
| shahidsajid | 29:f7a2d2a755ec | 59 | |
| shahidsajid | 29:f7a2d2a755ec | 60 | /*integer variable used to check if ball is Hit, the variable is essentially used as a flag |
| shahidsajid | 29:f7a2d2a755ec | 61 | in the cricket method*/ |
| shahidsajid | 31:eefa1d23a843 | 62 | int _hit_ball; |
| shahidsajid | 30:43aace0fdbdf | 63 | |
| shahidsajid | 29:f7a2d2a755ec | 64 | /*integer variable used to check if the hit is lofted, the variable is essentially used as a flag |
| shahidsajid | 29:f7a2d2a755ec | 65 | in the cricket class */ |
| shahidsajid | 13:924891519a95 | 66 | int _loft_ball; |
| shahidsajid | 30:43aace0fdbdf | 67 | |
| shahidsajid | 28:d0b0a64a832d | 68 | //Direction of the ball |
| shahidsajid | 4:55a0509c4874 | 69 | int d; |
| shahidsajid | 30:43aace0fdbdf | 70 | |
| shahidsajid | 28:d0b0a64a832d | 71 | //x co-ordinate for the bat to be printed on the LCD |
| shahidsajid | 31:eefa1d23a843 | 72 | int _bat_width; |
| shahidsajid | 28:d0b0a64a832d | 73 | //y co-ordinate for the bat to be printed on the LCD |
| shahidsajid | 31:eefa1d23a843 | 74 | int _bat_height; |
| shahidsajid | 4:55a0509c4874 | 75 | }; |
| shahidsajid | 30:43aace0fdbdf | 76 | #endif |