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@12:954da4f4e565, 2019-04-23 (annotated)
- Committer:
- shahidsajid
- Date:
- Tue Apr 23 12:46:34 2019 +0000
- Revision:
- 12:954da4f4e565
- Parent:
- 11:f481ec642cc5
- Child:
- 13:924891519a95
Player able to hit the ball to 8 different parts of the field; Created update_ball(); Created init_positions() methods
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 | 10:6c6e09023942 | 8 | |
shahidsajid | 10:6c6e09023942 | 9 | /** Ball Class |
shahidsajid | 10:6c6e09023942 | 10 | @author Dr Craig A. Evans, University of Leeds |
shahidsajid | 10:6c6e09023942 | 11 | @brief Controls the ball in the Pong game |
shahidsajid | 10:6c6e09023942 | 12 | @date Febraury 2017 |
shahidsajid | 10:6c6e09023942 | 13 | */ |
shahidsajid | 10:6c6e09023942 | 14 | class Cricket |
shahidsajid | 10:6c6e09023942 | 15 | { |
shahidsajid | 10:6c6e09023942 | 16 | |
shahidsajid | 10:6c6e09023942 | 17 | public: |
shahidsajid | 10:6c6e09023942 | 18 | Cricket(); |
shahidsajid | 10:6c6e09023942 | 19 | ~Cricket(); |
shahidsajid | 10:6c6e09023942 | 20 | void init(); |
shahidsajid | 10:6c6e09023942 | 21 | void draw(N5110 &lcd); |
shahidsajid | 10:6c6e09023942 | 22 | void set_field(N5110 &lcd); |
shahidsajid | 10:6c6e09023942 | 23 | void draw_field(N5110 &lcd); |
shahidsajid | 10:6c6e09023942 | 24 | void update_game(int checkHit, Direction dir); |
shahidsajid | 11:f481ec642cc5 | 25 | void play_game(N5110 &lcd,Gamepad &pad); |
shahidsajid | 12:954da4f4e565 | 26 | void game(N5110 &lcd,Gamepad &pad); |
shahidsajid | 12:954da4f4e565 | 27 | void set_init_positions(int x,int y, Direction direction,int no); |
shahidsajid | 12:954da4f4e565 | 28 | void init_positions(); |
shahidsajid | 10:6c6e09023942 | 29 | private: |
shahidsajid | 10:6c6e09023942 | 30 | Ball ball; |
shahidsajid | 10:6c6e09023942 | 31 | Bat bat; |
shahidsajid | 12:954da4f4e565 | 32 | |
shahidsajid | 12:954da4f4e565 | 33 | struct fielder_positions{ |
shahidsajid | 12:954da4f4e565 | 34 | Direction dir; |
shahidsajid | 12:954da4f4e565 | 35 | int x; |
shahidsajid | 12:954da4f4e565 | 36 | int y; |
shahidsajid | 12:954da4f4e565 | 37 | int no; |
shahidsajid | 12:954da4f4e565 | 38 | }; |
shahidsajid | 12:954da4f4e565 | 39 | fielder_positions positions[7]; |
shahidsajid | 10:6c6e09023942 | 40 | struct Fielder{ |
shahidsajid | 10:6c6e09023942 | 41 | Direction dir; |
shahidsajid | 10:6c6e09023942 | 42 | int x; |
shahidsajid | 10:6c6e09023942 | 43 | int y; |
shahidsajid | 10:6c6e09023942 | 44 | int position; |
shahidsajid | 10:6c6e09023942 | 45 | }; |
shahidsajid | 10:6c6e09023942 | 46 | Fielder field[5]; |
shahidsajid | 10:6c6e09023942 | 47 | int direction_set; |
shahidsajid | 10:6c6e09023942 | 48 | Vector2D ball_position; |
shahidsajid | 12:954da4f4e565 | 49 | Direction ball_direction; |
shahidsajid | 12:954da4f4e565 | 50 | int check_bowled; |
shahidsajid | 12:954da4f4e565 | 51 | int init_field_counter; |
shahidsajid | 12:954da4f4e565 | 52 | int fieldersCount; |
shahidsajid | 10:6c6e09023942 | 53 | int new_round; |
shahidsajid | 10:6c6e09023942 | 54 | int fieldNumbers[10]; |
shahidsajid | 12:954da4f4e565 | 55 | int fielder_no; |
shahidsajid | 10:6c6e09023942 | 56 | int ballHit; |
shahidsajid | 10:6c6e09023942 | 57 | int d; |
shahidsajid | 10:6c6e09023942 | 58 | int _size; |
shahidsajid | 10:6c6e09023942 | 59 | int _x; |
shahidsajid | 10:6c6e09023942 | 60 | int _y; |
shahidsajid | 10:6c6e09023942 | 61 | }; |
shahidsajid | 10:6c6e09023942 | 62 | #endif |