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@26:6427f09cf8d3, 2019-05-01 (annotated)
- Committer:
- shahidsajid
- Date:
- Wed May 01 11:56:36 2019 +0000
- Revision:
- 26:6427f09cf8d3
- Parent:
- 24:23fd6b451db7
- Child:
- 28:d0b0a64a832d
Documented the UX class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shahidsajid | 10:6c6e09023942 | 1 | #ifndef CRICKET_H |
shahidsajid | 10:6c6e09023942 | 2 | #define CRICKET_H |
shahidsajid | 10:6c6e09023942 | 3 | |
shahidsajid | 10:6c6e09023942 | 4 | #include "mbed.h" |
shahidsajid | 10:6c6e09023942 | 5 | #include "N5110.h" |
shahidsajid | 10:6c6e09023942 | 6 | #include "Gamepad.h" |
shahidsajid | 10:6c6e09023942 | 7 | #include "Ball.h" |
shahidsajid | 14:122eaa3b7a50 | 8 | #include "Scoreboard.h" |
shahidsajid | 21:a0904159e183 | 9 | #include "UX.h" |
shahidsajid | 10:6c6e09023942 | 10 | |
shahidsajid | 10:6c6e09023942 | 11 | /** Ball Class |
shahidsajid | 26:6427f09cf8d3 | 12 | @author Shahid Zubin Sajid |
shahidsajid | 26:6427f09cf8d3 | 13 | @brief Controls the ball in the Cricket team |
shahidsajid | 26:6427f09cf8d3 | 14 | @date May 2019 |
shahidsajid | 10:6c6e09023942 | 15 | */ |
shahidsajid | 10:6c6e09023942 | 16 | class Cricket |
shahidsajid | 10:6c6e09023942 | 17 | { |
shahidsajid | 10:6c6e09023942 | 18 | |
shahidsajid | 10:6c6e09023942 | 19 | public: |
shahidsajid | 10:6c6e09023942 | 20 | Cricket(); |
shahidsajid | 10:6c6e09023942 | 21 | ~Cricket(); |
shahidsajid | 10:6c6e09023942 | 22 | void init(); |
shahidsajid | 10:6c6e09023942 | 23 | void draw(N5110 &lcd); |
shahidsajid | 26:6427f09cf8d3 | 24 | |
shahidsajid | 26:6427f09cf8d3 | 25 | //Setters |
shahidsajid | 10:6c6e09023942 | 26 | void set_field(N5110 &lcd); |
shahidsajid | 13:924891519a95 | 27 | void set_init_positions(int x,int y, Direction direction,int no); |
shahidsajid | 13:924891519a95 | 28 | void set_ball_direction(Direction dir); |
shahidsajid | 26:6427f09cf8d3 | 29 | |
shahidsajid | 26:6427f09cf8d3 | 30 | // |
shahidsajid | 10:6c6e09023942 | 31 | void draw_field(N5110 &lcd); |
shahidsajid | 19:e1ded5acb64a | 32 | void update_game(int checkHit,int loft_check, Direction dir,Gamepad &pad,N5110 &lcd); |
shahidsajid | 11:f481ec642cc5 | 33 | void play_game(N5110 &lcd,Gamepad &pad); |
shahidsajid | 15:81a3aaf52647 | 34 | void update_scoreboard(int checkUpdate, int runs,Gamepad &pad); |
shahidsajid | 19:e1ded5acb64a | 35 | void batsman_out(int option,Gamepad &pad, N5110 &lcd); |
shahidsajid | 18:a260ce8db9e7 | 36 | void check_victory(N5110 &lcd); |
shahidsajid | 19:e1ded5acb64a | 37 | void game(N5110 &lcd,Gamepad &pad); |
shahidsajid | 24:23fd6b451db7 | 38 | void intro(N5110 &lcd); |
shahidsajid | 24:23fd6b451db7 | 39 | bool game_status(N5110 &lcd); |
shahidsajid | 24:23fd6b451db7 | 40 | void info_screen(N5110 &lcd, int target); |
shahidsajid | 19:e1ded5acb64a | 41 | |
shahidsajid | 12:954da4f4e565 | 42 | void init_positions(); |
shahidsajid | 19:e1ded5acb64a | 43 | void round_reset(); |
shahidsajid | 19:e1ded5acb64a | 44 | void game_reset(); |
shahidsajid | 13:924891519a95 | 45 | int check_fielder(Direction dir); |
shahidsajid | 19:e1ded5acb64a | 46 | bool check_ball_count(N5110 &lcd); |
shahidsajid | 10:6c6e09023942 | 47 | private: |
shahidsajid | 10:6c6e09023942 | 48 | Ball ball; |
shahidsajid | 10:6c6e09023942 | 49 | Bat bat; |
shahidsajid | 14:122eaa3b7a50 | 50 | Scoreboard scoreboard; |
shahidsajid | 21:a0904159e183 | 51 | UX ux; |
shahidsajid | 12:954da4f4e565 | 52 | |
shahidsajid | 12:954da4f4e565 | 53 | struct fielder_positions{ |
shahidsajid | 12:954da4f4e565 | 54 | Direction dir; |
shahidsajid | 12:954da4f4e565 | 55 | int x; |
shahidsajid | 12:954da4f4e565 | 56 | int y; |
shahidsajid | 12:954da4f4e565 | 57 | int no; |
shahidsajid | 12:954da4f4e565 | 58 | }; |
shahidsajid | 12:954da4f4e565 | 59 | fielder_positions positions[7]; |
shahidsajid | 10:6c6e09023942 | 60 | struct Fielder{ |
shahidsajid | 10:6c6e09023942 | 61 | Direction dir; |
shahidsajid | 10:6c6e09023942 | 62 | int x; |
shahidsajid | 10:6c6e09023942 | 63 | int y; |
shahidsajid | 10:6c6e09023942 | 64 | int position; |
shahidsajid | 10:6c6e09023942 | 65 | }; |
shahidsajid | 10:6c6e09023942 | 66 | Fielder field[5]; |
shahidsajid | 26:6427f09cf8d3 | 67 | |
shahidsajid | 26:6427f09cf8d3 | 68 | Direction _ball_direction; |
shahidsajid | 26:6427f09cf8d3 | 69 | int _check_bowled; |
shahidsajid | 26:6427f09cf8d3 | 70 | int _init_field_counter; |
shahidsajid | 26:6427f09cf8d3 | 71 | int _fielders_count; |
shahidsajid | 26:6427f09cf8d3 | 72 | int _new_round; |
shahidsajid | 26:6427f09cf8d3 | 73 | int field_numbers[10]; |
shahidsajid | 20:9d21599fe350 | 74 | int _position_no; |
shahidsajid | 10:6c6e09023942 | 75 | int ballHit; |
shahidsajid | 26:6427f09cf8d3 | 76 | int _ball_limit; |
shahidsajid | 26:6427f09cf8d3 | 77 | int _new_game; |
shahidsajid | 26:6427f09cf8d3 | 78 | int _check_update; |
shahidsajid | 26:6427f09cf8d3 | 79 | int _check_hit; |
shahidsajid | 26:6427f09cf8d3 | 80 | int _set_hit; |
shahidsajid | 26:6427f09cf8d3 | 81 | int _set_loft; |
shahidsajid | 26:6427f09cf8d3 | 82 | int _direction_set; |
shahidsajid | 26:6427f09cf8d3 | 83 | int _loft_check; |
shahidsajid | 26:6427f09cf8d3 | 84 | //int d; |
shahidsajid | 10:6c6e09023942 | 85 | }; |
shahidsajid | 10:6c6e09023942 | 86 | #endif |