ELEC2645 (2018/19) / Mbed 2 deprecated el17ebs

Dependencies:   mbed FATFileSystem

Committer:
ellisbhastroud
Date:
Sat Apr 20 10:42:17 2019 +0000
Revision:
9:bc34f2243e43
Parent:
8:d410856c6d04
Child:
10:9f54a6366e94
Levels addition fully functioning

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ellisbhastroud 3:a8960004d261 1 #ifndef BALL_H
ellisbhastroud 3:a8960004d261 2 #define BALL_H
ellisbhastroud 3:a8960004d261 3
ellisbhastroud 3:a8960004d261 4 #include "mbed.h"
ellisbhastroud 3:a8960004d261 5 #include "N5110.h"
ellisbhastroud 3:a8960004d261 6 #include "Gamepad.h"
ellisbhastroud 3:a8960004d261 7
ellisbhastroud 8:d410856c6d04 8 /** Enum for wall types */
ellisbhastroud 9:bc34f2243e43 9 enum WallType {
ellisbhastroud 8:d410856c6d04 10
ellisbhastroud 8:d410856c6d04 11 LEFT, /**< left wall */
ellisbhastroud 8:d410856c6d04 12 RIGHT, /**< right wall */
ellisbhastroud 8:d410856c6d04 13 TOP, /**< top wall */
ellisbhastroud 8:d410856c6d04 14 BOTTOM, /**< bottom wall */
ellisbhastroud 8:d410856c6d04 15 };
ellisbhastroud 8:d410856c6d04 16
ellisbhastroud 8:d410856c6d04 17 /** Pixel Coordinate Struct*/
ellisbhastroud 8:d410856c6d04 18 struct Coord {
ellisbhastroud 8:d410856c6d04 19 int x; /**< coordinate of x pixel */
ellisbhastroud 8:d410856c6d04 20 int y; /**< coordinate of y pixel */
ellisbhastroud 8:d410856c6d04 21 };
ellisbhastroud 8:d410856c6d04 22
ellisbhastroud 9:bc34f2243e43 23 /** Map Layout struct */
ellisbhastroud 9:bc34f2243e43 24 struct WallMap {
ellisbhastroud 9:bc34f2243e43 25 WallType wall; /**< wall type */
ellisbhastroud 8:d410856c6d04 26 Coord start; /**< coordinate of line start */
ellisbhastroud 8:d410856c6d04 27 Coord end; /**< coordinate of line end */
ellisbhastroud 8:d410856c6d04 28 };
ellisbhastroud 8:d410856c6d04 29
ellisbhastroud 9:bc34f2243e43 30 /** Levels Information struct */
ellisbhastroud 9:bc34f2243e43 31 struct Levels {
ellisbhastroud 9:bc34f2243e43 32 Coord ball; /**< start position of ball */
ellisbhastroud 9:bc34f2243e43 33 Coord hole; /**< position of hole */
ellisbhastroud 9:bc34f2243e43 34 WallMap walls[10]; /**< array of wall plots */
ellisbhastroud 9:bc34f2243e43 35 int wall_count;
ellisbhastroud 9:bc34f2243e43 36
ellisbhastroud 9:bc34f2243e43 37 };
ellisbhastroud 9:bc34f2243e43 38
ellisbhastroud 3:a8960004d261 39 /** Ball Class
ellisbhastroud 3:a8960004d261 40 * @brief Class for controlling the golf ball
ellisbhastroud 3:a8960004d261 41 * @author Ellis Blackford Stroud
ellisbhastroud 3:a8960004d261 42 * @date May, 2018
ellisbhastroud 3:a8960004d261 43 */
ellisbhastroud 3:a8960004d261 44
ellisbhastroud 5:0b31909caf7f 45 class Ball
ellisbhastroud 5:0b31909caf7f 46 {
ellisbhastroud 3:a8960004d261 47
ellisbhastroud 3:a8960004d261 48 public:
ellisbhastroud 3:a8960004d261 49
ellisbhastroud 3:a8960004d261 50 /** Constructor */
ellisbhastroud 3:a8960004d261 51 Ball();
ellisbhastroud 3:a8960004d261 52
ellisbhastroud 3:a8960004d261 53 /** Destructor */
ellisbhastroud 3:a8960004d261 54 ~Ball();
ellisbhastroud 3:a8960004d261 55
ellisbhastroud 9:bc34f2243e43 56 void init(Coord start_pos);
ellisbhastroud 3:a8960004d261 57
ellisbhastroud 5:0b31909caf7f 58 void drawBall(N5110 &lcd);
ellisbhastroud 3:a8960004d261 59
ellisbhastroud 5:0b31909caf7f 60 void printShotCount(N5110 &lcd);
ellisbhastroud 4:035448357749 61
ellisbhastroud 8:d410856c6d04 62 void drawPower(N5110 &lcd, float mag);
ellisbhastroud 8:d410856c6d04 63
ellisbhastroud 8:d410856c6d04 64 void drawAim(N5110 &lcd, Vector2D joy_coord ,float angle);
ellisbhastroud 8:d410856c6d04 65
ellisbhastroud 5:0b31909caf7f 66 void move_ball(int frame_rate);
ellisbhastroud 4:035448357749 67
ellisbhastroud 4:035448357749 68 Vector2D get_ball_pos();
ellisbhastroud 3:a8960004d261 69
ellisbhastroud 8:d410856c6d04 70 void shoot_ball(Gamepad &pad, Vector2D joy_coord);
ellisbhastroud 3:a8960004d261 71
ellisbhastroud 4:035448357749 72 int get_shot_count();
ellisbhastroud 9:bc34f2243e43 73
ellisbhastroud 9:bc34f2243e43 74 int get_total_shot_count();
ellisbhastroud 5:0b31909caf7f 75
ellisbhastroud 9:bc34f2243e43 76 void set_total_shot_count(int total_shot_count);
ellisbhastroud 9:bc34f2243e43 77
ellisbhastroud 9:bc34f2243e43 78 bool check_hole(Coord hole);
ellisbhastroud 8:d410856c6d04 79
ellisbhastroud 9:bc34f2243e43 80 void check_wall_bounce(WallMap map[], int size);
ellisbhastroud 8:d410856c6d04 81
ellisbhastroud 8:d410856c6d04 82 void left_bounce(Coord start, Coord end);
ellisbhastroud 3:a8960004d261 83
ellisbhastroud 8:d410856c6d04 84 void right_bounce(Coord start, Coord end);
ellisbhastroud 8:d410856c6d04 85
ellisbhastroud 8:d410856c6d04 86 void top_bounce(Coord start, Coord end);
ellisbhastroud 5:0b31909caf7f 87
ellisbhastroud 8:d410856c6d04 88 void bottom_bounce(Coord start, Coord end);
ellisbhastroud 8:d410856c6d04 89
ellisbhastroud 3:a8960004d261 90 private:
ellisbhastroud 4:035448357749 91
ellisbhastroud 3:a8960004d261 92 float _x_pos;
ellisbhastroud 3:a8960004d261 93 float _y_pos;
ellisbhastroud 3:a8960004d261 94 float _x_vel;
ellisbhastroud 3:a8960004d261 95 float _y_vel;
ellisbhastroud 4:035448357749 96 int _shot_count;
ellisbhastroud 9:bc34f2243e43 97 int _total_shot_count;
ellisbhastroud 5:0b31909caf7f 98 Direction _direction;
ellisbhastroud 3:a8960004d261 99 };
ellisbhastroud 3:a8960004d261 100
ellisbhastroud 3:a8960004d261 101 #endif