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
Cricket/Cricket.h
- Committer:
- shahidsajid
- Date:
- 2019-05-07
- Revision:
- 28:d0b0a64a832d
- Parent:
- 26:6427f09cf8d3
- Child:
- 29:f7a2d2a755ec
File content as of revision 28:d0b0a64a832d:
#ifndef CRICKET_H #define CRICKET_H #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Ball.h" #include "Scoreboard.h" #include "UX.h" /** Ball Class @author Shahid Zubin Sajid @brief GAME ENGINE FOR HERO CRICKET @date May 2019 */ class Cricket { public: Cricket(); ~Cricket(); /** * @brief Initlialises the Cricket class Object * @details Intialises the bat variables to the starting values * @details Initialises the other class objects used in the game */ void init(); /** * @brief Draws the fielders, the outfield circle and the pitch onto the LCD */ void draw(N5110 &lcd); //Setters void set_field(N5110 &lcd); /** * @brief Method to set the cor-dinates,direction and position for batsman to hit the ball * @param x @details Integer value for the x-cordinate * @param y @details Integer value for the y-cordinate * @param direction @details Direction variable to set the position direction * @param no @details integer to store the position number */ void set_init_positions(int x,int y, Direction direction,int no); /** * @brief Sets the ball direction and sets _direction_set to 1 * @details loops through the positions available and sets the direction to the arguement if found * @param dir @details Direction variable recieved as recived from the joystick during gameplay */ void set_ball_direction(Direction dir); /** * @brief Draws the 5 outfield filders to the LCD * @details Loops through the fielders array and prints the fielders acc. to their cordinates * param &lcd @details reference pointer for the LCD */ void draw_field(N5110 &lcd); /** * @brief Method to set the cor-dinates,direction and position for batsman to hit the ball * @param x @details Integer value for the x-cordinate * @param y @details Integer value for the y-cordinate * @param direction @details Direction variable to set the position direction * @param no @details integer to store the position number */ void update_game(int checkHit,int loft_check, Direction dir,Gamepad &pad,N5110 &lcd); void play_game(N5110 &lcd,Gamepad &pad); /** * @brief Updates the score by adding runs scored during the round to score * @param checkUpdate @details integer value which validates that the game has been updated * @param runs @details Integer value which stores the runs scored during the round * @param &pad @details Takes a reference pointer to a Gamepad object */ void update_scoreboard(int checkUpdate,int runs, Gamepad &pad); /** * @brief method when a batsman is out, screen updates and game resets. * @param option @details integer value which identifies the way batsman is out * @param &pad @details Takes a reference pointer to a Gamepad object * @param &lcd @details reference pointer for the LCD */ void batsman_out(int option,Gamepad &pad, N5110 &lcd); /** * @brief method which compares score and target, if true game is won and game resets * @param &lcd @details reference pointer for the LCD */ void check_victory(N5110 &lcd); void game(N5110 &lcd,Gamepad &pad); void intro(N5110 &lcd); bool game_status(N5110 &lcd); void info_screen(N5110 &lcd, int target); void init_positions(); void round_reset(); void game_reset(); int check_fielder(Direction dir); bool check_ball_count(N5110 &lcd); private: Ball ball; Bat bat; Scoreboard scoreboard; UX ux; struct fielder_positions{ Direction dir; int x; int y; int no; }; fielder_positions positions[7]; struct Fielder{ Direction dir; int x; int y; int position; }; Fielder field[5]; Direction _ball_direction; int _check_bowled; int _init_field_counter; int _fielders_count; int _new_round; int field_numbers[10]; int _position_no; int ballHit; int _ball_limit; int _new_game; int _check_update; int _check_hit; int _set_hit; int _set_loft; int _direction_set; int _loft_check; //int d; }; #endif