ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Committer:
shahidsajid
Date:
Tue Apr 23 20:57:15 2019 +0000
Revision:
14:122eaa3b7a50
Parent:
13:924891519a95
Child:
15:81a3aaf52647
Completed update_game(); Game now runs multiple times with field changed each time;

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