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