ELEC2645 (2018/19) / Mbed 2 deprecated el17ebs

Dependencies:   mbed FATFileSystem

Committer:
ellisbhastroud
Date:
Thu Apr 18 10:42:42 2019 +0000
Revision:
8:d410856c6d04
Parent:
5:0b31909caf7f
Child:
9:bc34f2243e43
Course map draw and bounce algorithms complete

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 8:d410856c6d04 9 enum Wall {
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 8:d410856c6d04 23 /** Course Information struct */
ellisbhastroud 8:d410856c6d04 24 struct Course {
ellisbhastroud 8:d410856c6d04 25 Wall 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 3:a8960004d261 30 /** Ball Class
ellisbhastroud 3:a8960004d261 31 * @brief Class for controlling the golf ball
ellisbhastroud 3:a8960004d261 32 * @author Ellis Blackford Stroud
ellisbhastroud 3:a8960004d261 33 * @date May, 2018
ellisbhastroud 3:a8960004d261 34 */
ellisbhastroud 3:a8960004d261 35
ellisbhastroud 5:0b31909caf7f 36 class Ball
ellisbhastroud 5:0b31909caf7f 37 {
ellisbhastroud 3:a8960004d261 38
ellisbhastroud 3:a8960004d261 39 public:
ellisbhastroud 3:a8960004d261 40
ellisbhastroud 3:a8960004d261 41 /** Constructor */
ellisbhastroud 3:a8960004d261 42 Ball();
ellisbhastroud 3:a8960004d261 43
ellisbhastroud 3:a8960004d261 44 /** Destructor */
ellisbhastroud 3:a8960004d261 45 ~Ball();
ellisbhastroud 3:a8960004d261 46
ellisbhastroud 3:a8960004d261 47 void init(float x_pos, float y_pos);
ellisbhastroud 3:a8960004d261 48
ellisbhastroud 5:0b31909caf7f 49 void drawBall(N5110 &lcd);
ellisbhastroud 3:a8960004d261 50
ellisbhastroud 5:0b31909caf7f 51 void printShotCount(N5110 &lcd);
ellisbhastroud 4:035448357749 52
ellisbhastroud 8:d410856c6d04 53 void drawPower(N5110 &lcd, float mag);
ellisbhastroud 8:d410856c6d04 54
ellisbhastroud 8:d410856c6d04 55 void drawAim(N5110 &lcd, Vector2D joy_coord ,float angle);
ellisbhastroud 8:d410856c6d04 56
ellisbhastroud 5:0b31909caf7f 57 void move_ball(int frame_rate);
ellisbhastroud 4:035448357749 58
ellisbhastroud 4:035448357749 59 Vector2D get_ball_pos();
ellisbhastroud 3:a8960004d261 60
ellisbhastroud 8:d410856c6d04 61 void shoot_ball(Gamepad &pad, Vector2D joy_coord);
ellisbhastroud 3:a8960004d261 62
ellisbhastroud 4:035448357749 63 int get_shot_count();
ellisbhastroud 5:0b31909caf7f 64
ellisbhastroud 3:a8960004d261 65 void set_vel(float x_vel, float y_vel);
ellisbhastroud 8:d410856c6d04 66
ellisbhastroud 8:d410856c6d04 67 void check_wall_bounce(Course map[], int size);
ellisbhastroud 8:d410856c6d04 68
ellisbhastroud 8:d410856c6d04 69 void left_bounce(Coord start, Coord end);
ellisbhastroud 3:a8960004d261 70
ellisbhastroud 8:d410856c6d04 71 void right_bounce(Coord start, Coord end);
ellisbhastroud 8:d410856c6d04 72
ellisbhastroud 8:d410856c6d04 73 void top_bounce(Coord start, Coord end);
ellisbhastroud 5:0b31909caf7f 74
ellisbhastroud 8:d410856c6d04 75 void bottom_bounce(Coord start, Coord end);
ellisbhastroud 8:d410856c6d04 76
ellisbhastroud 8:d410856c6d04 77
ellisbhastroud 5:0b31909caf7f 78
ellisbhastroud 3:a8960004d261 79 private:
ellisbhastroud 3:a8960004d261 80
ellisbhastroud 4:035448357749 81
ellisbhastroud 3:a8960004d261 82 float _x_pos;
ellisbhastroud 3:a8960004d261 83 float _y_pos;
ellisbhastroud 3:a8960004d261 84 float _x_vel;
ellisbhastroud 3:a8960004d261 85 float _y_vel;
ellisbhastroud 4:035448357749 86 int _shot_count;
ellisbhastroud 5:0b31909caf7f 87 Direction _direction;
ellisbhastroud 3:a8960004d261 88 };
ellisbhastroud 3:a8960004d261 89
ellisbhastroud 3:a8960004d261 90 #endif