ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Committer:
shahidsajid
Date:
Sat Apr 27 15:42:36 2019 +0000
Revision:
18:a260ce8db9e7
Parent:
15:81a3aaf52647
Child:
19:e1ded5acb64a
Created no. of balls completed; created a target; printed the target and no. of balls onto the screen; Created displays for when game is won and game is lost

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 15:81a3aaf52647 27 void update_game(int checkHit,int loft_check, Direction dir,Gamepad &pad);
shahidsajid 11:f481ec642cc5 28 void play_game(N5110 &lcd,Gamepad &pad);
shahidsajid 15:81a3aaf52647 29 void update_scoreboard(int checkUpdate, int runs,Gamepad &pad);
shahidsajid 15:81a3aaf52647 30 void batsman_out(string messsage,Gamepad &pad);
shahidsajid 18:a260ce8db9e7 31 void check_victory(N5110 &lcd);
shahidsajid 12:954da4f4e565 32 void game(N5110 &lcd,Gamepad &pad);
shahidsajid 12:954da4f4e565 33 void init_positions();
shahidsajid 13:924891519a95 34 void reset();
shahidsajid 13:924891519a95 35 int check_fielder(Direction dir);
shahidsajid 18:a260ce8db9e7 36 void check_ball_count(N5110 &lcd);
shahidsajid 10:6c6e09023942 37 private:
shahidsajid 10:6c6e09023942 38 Ball ball;
shahidsajid 10:6c6e09023942 39 Bat bat;
shahidsajid 14:122eaa3b7a50 40 Scoreboard scoreboard;
shahidsajid 12:954da4f4e565 41
shahidsajid 12:954da4f4e565 42 struct fielder_positions{
shahidsajid 12:954da4f4e565 43 Direction dir;
shahidsajid 12:954da4f4e565 44 int x;
shahidsajid 12:954da4f4e565 45 int y;
shahidsajid 12:954da4f4e565 46 int no;
shahidsajid 12:954da4f4e565 47 };
shahidsajid 12:954da4f4e565 48 fielder_positions positions[7];
shahidsajid 10:6c6e09023942 49 struct Fielder{
shahidsajid 10:6c6e09023942 50 Direction dir;
shahidsajid 10:6c6e09023942 51 int x;
shahidsajid 10:6c6e09023942 52 int y;
shahidsajid 10:6c6e09023942 53 int position;
shahidsajid 10:6c6e09023942 54 };
shahidsajid 10:6c6e09023942 55 Fielder field[5];
shahidsajid 10:6c6e09023942 56 int direction_set;
shahidsajid 10:6c6e09023942 57 Vector2D ball_position;
shahidsajid 12:954da4f4e565 58 Direction ball_direction;
shahidsajid 12:954da4f4e565 59 int check_bowled;
shahidsajid 12:954da4f4e565 60 int init_field_counter;
shahidsajid 13:924891519a95 61 int outfield_fielder;
shahidsajid 12:954da4f4e565 62 int fieldersCount;
shahidsajid 10:6c6e09023942 63 int new_round;
shahidsajid 10:6c6e09023942 64 int fieldNumbers[10];
shahidsajid 12:954da4f4e565 65 int fielder_no;
shahidsajid 10:6c6e09023942 66 int ballHit;
shahidsajid 15:81a3aaf52647 67 int check_hit;
shahidsajid 18:a260ce8db9e7 68 int _ball_limit;
shahidsajid 18:a260ce8db9e7 69 int new_game;
shahidsajid 15:81a3aaf52647 70 int check_update;
shahidsajid 15:81a3aaf52647 71 int loft_check;
shahidsajid 10:6c6e09023942 72 int d;
shahidsajid 10:6c6e09023942 73 int _size;
shahidsajid 10:6c6e09023942 74 int _x;
shahidsajid 10:6c6e09023942 75 int _y;
shahidsajid 10:6c6e09023942 76 };
shahidsajid 10:6c6e09023942 77 #endif