ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Committer:
shahidsajid
Date:
Sat Apr 27 14:09:21 2019 +0000
Revision:
17:b2b651acffae
Parent:
15:81a3aaf52647
created a Batting target method and ball_count method

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 10:6c6e09023942 9
shahidsajid 10:6c6e09023942 10 /** Ball Class
shahidsajid 10:6c6e09023942 11 @author Dr Craig A. Evans, University of Leeds
shahidsajid 10:6c6e09023942 12 @brief Controls the ball in the Pong game
shahidsajid 10:6c6e09023942 13 @date Febraury 2017
shahidsajid 10:6c6e09023942 14 */
shahidsajid 10:6c6e09023942 15 class Cricket
shahidsajid 10:6c6e09023942 16 {
shahidsajid 10:6c6e09023942 17
shahidsajid 10:6c6e09023942 18 public:
shahidsajid 10:6c6e09023942 19 Cricket();
shahidsajid 10:6c6e09023942 20 ~Cricket();
shahidsajid 10:6c6e09023942 21 void init();
shahidsajid 10:6c6e09023942 22 void draw(N5110 &lcd);
shahidsajid 10:6c6e09023942 23 void set_field(N5110 &lcd);
shahidsajid 13:924891519a95 24 void set_init_positions(int x,int y, Direction direction,int no);
shahidsajid 13:924891519a95 25 void set_ball_direction(Direction dir);
shahidsajid 10:6c6e09023942 26 void draw_field(N5110 &lcd);
shahidsajid 17:b2b651acffae 27 void check_victory(N5110 &lcd);
shahidsajid 15:81a3aaf52647 28 void update_game(int checkHit,int loft_check, Direction dir,Gamepad &pad);
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 15:81a3aaf52647 31 void batsman_out(string messsage,Gamepad &pad);
shahidsajid 12:954da4f4e565 32 void game(N5110 &lcd,Gamepad &pad);
shahidsajid 12:954da4f4e565 33 void init_positions();
shahidsajid 13:924891519a95 34 void reset();
shahidsajid 17:b2b651acffae 35 void welcome(N5110 &lcd, Gamepad &pad);
shahidsajid 13:924891519a95 36 int check_fielder(Direction dir);
shahidsajid 17:b2b651acffae 37 void check_ball_count(N5110 &lcd);
shahidsajid 10:6c6e09023942 38 private:
shahidsajid 10:6c6e09023942 39 Ball ball;
shahidsajid 10:6c6e09023942 40 Bat bat;
shahidsajid 14:122eaa3b7a50 41 Scoreboard scoreboard;
shahidsajid 12:954da4f4e565 42
shahidsajid 12:954da4f4e565 43 struct fielder_positions{
shahidsajid 12:954da4f4e565 44 Direction dir;
shahidsajid 12:954da4f4e565 45 int x;
shahidsajid 12:954da4f4e565 46 int y;
shahidsajid 12:954da4f4e565 47 int no;
shahidsajid 12:954da4f4e565 48 };
shahidsajid 12:954da4f4e565 49 fielder_positions positions[7];
shahidsajid 10:6c6e09023942 50 struct Fielder{
shahidsajid 10:6c6e09023942 51 Direction dir;
shahidsajid 10:6c6e09023942 52 int x;
shahidsajid 10:6c6e09023942 53 int y;
shahidsajid 10:6c6e09023942 54 int position;
shahidsajid 10:6c6e09023942 55 };
shahidsajid 17:b2b651acffae 56 int new_game;
shahidsajid 10:6c6e09023942 57 Fielder field[5];
shahidsajid 10:6c6e09023942 58 int direction_set;
shahidsajid 10:6c6e09023942 59 Vector2D ball_position;
shahidsajid 12:954da4f4e565 60 Direction ball_direction;
shahidsajid 12:954da4f4e565 61 int check_bowled;
shahidsajid 17:b2b651acffae 62 int _ball_limit;
shahidsajid 12:954da4f4e565 63 int init_field_counter;
shahidsajid 13:924891519a95 64 int outfield_fielder;
shahidsajid 12:954da4f4e565 65 int fieldersCount;
shahidsajid 10:6c6e09023942 66 int new_round;
shahidsajid 10:6c6e09023942 67 int fieldNumbers[10];
shahidsajid 12:954da4f4e565 68 int fielder_no;
shahidsajid 10:6c6e09023942 69 int ballHit;
shahidsajid 15:81a3aaf52647 70 int check_hit;
shahidsajid 15:81a3aaf52647 71 int check_update;
shahidsajid 15:81a3aaf52647 72 int loft_check;
shahidsajid 10:6c6e09023942 73 int d;
shahidsajid 10:6c6e09023942 74 int _size;
shahidsajid 10:6c6e09023942 75 int _x;
shahidsajid 10:6c6e09023942 76 int _y;
shahidsajid 10:6c6e09023942 77 };
shahidsajid 10:6c6e09023942 78 #endif