ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Committer:
shahidsajid
Date:
Tue Apr 30 10:27:23 2019 +0000
Revision:
20:9d21599fe350
Parent:
19:e1ded5acb64a
Child:
21:a0904159e183
Created starting menus with correct button functionality;

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 19:e1ded5acb64a 27 void update_game(int checkHit,int loft_check, Direction dir,Gamepad &pad,N5110 &lcd);
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 19:e1ded5acb64a 30 void batsman_out(int option,Gamepad &pad, N5110 &lcd);
shahidsajid 18:a260ce8db9e7 31 void check_victory(N5110 &lcd);
shahidsajid 19:e1ded5acb64a 32 void game(N5110 &lcd,Gamepad &pad);
shahidsajid 19:e1ded5acb64a 33
shahidsajid 12:954da4f4e565 34 void init_positions();
shahidsajid 19:e1ded5acb64a 35 void round_reset();
shahidsajid 19:e1ded5acb64a 36 void game_reset();
shahidsajid 13:924891519a95 37 int check_fielder(Direction dir);
shahidsajid 19:e1ded5acb64a 38 bool check_ball_count(N5110 &lcd);
shahidsajid 10:6c6e09023942 39 private:
shahidsajid 10:6c6e09023942 40 Ball ball;
shahidsajid 10:6c6e09023942 41 Bat bat;
shahidsajid 14:122eaa3b7a50 42 Scoreboard scoreboard;
shahidsajid 12:954da4f4e565 43
shahidsajid 12:954da4f4e565 44 struct fielder_positions{
shahidsajid 12:954da4f4e565 45 Direction dir;
shahidsajid 12:954da4f4e565 46 int x;
shahidsajid 12:954da4f4e565 47 int y;
shahidsajid 12:954da4f4e565 48 int no;
shahidsajid 12:954da4f4e565 49 };
shahidsajid 12:954da4f4e565 50 fielder_positions positions[7];
shahidsajid 10:6c6e09023942 51 struct Fielder{
shahidsajid 10:6c6e09023942 52 Direction dir;
shahidsajid 10:6c6e09023942 53 int x;
shahidsajid 10:6c6e09023942 54 int y;
shahidsajid 10:6c6e09023942 55 int position;
shahidsajid 10:6c6e09023942 56 };
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 12:954da4f4e565 62 int init_field_counter;
shahidsajid 13:924891519a95 63 int outfield_fielder;
shahidsajid 12:954da4f4e565 64 int fieldersCount;
shahidsajid 10:6c6e09023942 65 int new_round;
shahidsajid 10:6c6e09023942 66 int fieldNumbers[10];
shahidsajid 20:9d21599fe350 67 int _position_no;
shahidsajid 10:6c6e09023942 68 int ballHit;
shahidsajid 15:81a3aaf52647 69 int check_hit;
shahidsajid 18:a260ce8db9e7 70 int _ball_limit;
shahidsajid 18:a260ce8db9e7 71 int new_game;
shahidsajid 15:81a3aaf52647 72 int check_update;
shahidsajid 15:81a3aaf52647 73 int loft_check;
shahidsajid 10:6c6e09023942 74 int d;
shahidsajid 10:6c6e09023942 75 int _size;
shahidsajid 10:6c6e09023942 76 int _x;
shahidsajid 10:6c6e09023942 77 int _y;
shahidsajid 10:6c6e09023942 78 };
shahidsajid 10:6c6e09023942 79 #endif