ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Committer:
shahidsajid
Date:
Tue Apr 30 20:36:42 2019 +0000
Revision:
22:69d7fe739872
Parent:
21:a0904159e183
Completed version of the game;

Who changed what in which revision?

UserRevisionLine numberNew 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 10:6c6e09023942 12 @author Dr Craig A. Evans, University of Leeds
shahidsajid 10:6c6e09023942 13 @brief Controls the ball in the Pong game
shahidsajid 10:6c6e09023942 14 @date Febraury 2017
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 10:6c6e09023942 24 void set_field(N5110 &lcd);
shahidsajid 13:924891519a95 25 void set_init_positions(int x,int y, Direction direction,int no);
shahidsajid 13:924891519a95 26 void set_ball_direction(Direction dir);
shahidsajid 10:6c6e09023942 27 void draw_field(N5110 &lcd);
shahidsajid 19:e1ded5acb64a 28 void update_game(int checkHit,int loft_check, Direction dir,Gamepad &pad,N5110 &lcd);
shahidsajid 11:f481ec642cc5 29 void play_game(N5110 &lcd,Gamepad &pad);
shahidsajid 15:81a3aaf52647 30 void update_scoreboard(int checkUpdate, int runs,Gamepad &pad);
shahidsajid 19:e1ded5acb64a 31 void batsman_out(int option,Gamepad &pad, N5110 &lcd);
shahidsajid 18:a260ce8db9e7 32 void check_victory(N5110 &lcd);
shahidsajid 19:e1ded5acb64a 33 void game(N5110 &lcd,Gamepad &pad);
shahidsajid 22:69d7fe739872 34 void new_round(N5110 &lcd, Gamepad &pad);
shahidsajid 22:69d7fe739872 35 void new_game(N5110 &lcd, Gamepad &pad);
shahidsajid 22:69d7fe739872 36 void intro(N5110 &lcd);
shahidsajid 12:954da4f4e565 37 void init_positions();
shahidsajid 19:e1ded5acb64a 38 void round_reset();
shahidsajid 19:e1ded5acb64a 39 void game_reset();
shahidsajid 13:924891519a95 40 int check_fielder(Direction dir);
shahidsajid 19:e1ded5acb64a 41 bool check_ball_count(N5110 &lcd);
shahidsajid 10:6c6e09023942 42 private:
shahidsajid 10:6c6e09023942 43 Ball ball;
shahidsajid 10:6c6e09023942 44 Bat bat;
shahidsajid 14:122eaa3b7a50 45 Scoreboard scoreboard;
shahidsajid 21:a0904159e183 46 UX ux;
shahidsajid 12:954da4f4e565 47
shahidsajid 12:954da4f4e565 48 struct fielder_positions{
shahidsajid 12:954da4f4e565 49 Direction dir;
shahidsajid 12:954da4f4e565 50 int x;
shahidsajid 12:954da4f4e565 51 int y;
shahidsajid 12:954da4f4e565 52 int no;
shahidsajid 12:954da4f4e565 53 };
shahidsajid 12:954da4f4e565 54 fielder_positions positions[7];
shahidsajid 10:6c6e09023942 55 struct Fielder{
shahidsajid 10:6c6e09023942 56 Direction dir;
shahidsajid 10:6c6e09023942 57 int x;
shahidsajid 10:6c6e09023942 58 int y;
shahidsajid 10:6c6e09023942 59 int position;
shahidsajid 10:6c6e09023942 60 };
shahidsajid 10:6c6e09023942 61 Fielder field[5];
shahidsajid 10:6c6e09023942 62 int direction_set;
shahidsajid 10:6c6e09023942 63 Vector2D ball_position;
shahidsajid 12:954da4f4e565 64 Direction ball_direction;
shahidsajid 12:954da4f4e565 65 int check_bowled;
shahidsajid 12:954da4f4e565 66 int init_field_counter;
shahidsajid 13:924891519a95 67 int outfield_fielder;
shahidsajid 12:954da4f4e565 68 int fieldersCount;
shahidsajid 22:69d7fe739872 69 int _new_round;
shahidsajid 10:6c6e09023942 70 int fieldNumbers[10];
shahidsajid 20:9d21599fe350 71 int _position_no;
shahidsajid 10:6c6e09023942 72 int ballHit;
shahidsajid 15:81a3aaf52647 73 int check_hit;
shahidsajid 18:a260ce8db9e7 74 int _ball_limit;
shahidsajid 22:69d7fe739872 75 int _new_game;
shahidsajid 15:81a3aaf52647 76 int check_update;
shahidsajid 21:a0904159e183 77 int set_hit;
shahidsajid 22:69d7fe739872 78 int set_loft;
shahidsajid 15:81a3aaf52647 79 int loft_check;
shahidsajid 10:6c6e09023942 80 int d;
shahidsajid 10:6c6e09023942 81 int _size;
shahidsajid 10:6c6e09023942 82 int _x;
shahidsajid 10:6c6e09023942 83 int _y;
shahidsajid 10:6c6e09023942 84 };
shahidsajid 10:6c6e09023942 85 #endif