Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed FATFileSystem
Diff: Ball/Ball.h
- Revision:
- 8:d410856c6d04
- Parent:
- 5:0b31909caf7f
- Child:
- 9:bc34f2243e43
--- a/Ball/Ball.h Wed Apr 17 11:13:54 2019 +0000
+++ b/Ball/Ball.h Thu Apr 18 10:42:42 2019 +0000
@@ -5,6 +5,28 @@
#include "N5110.h"
#include "Gamepad.h"
+/** Enum for wall types */
+enum Wall {
+
+ LEFT, /**< left wall */
+ RIGHT, /**< right wall */
+ TOP, /**< top wall */
+ BOTTOM, /**< bottom wall */
+};
+
+/** Pixel Coordinate Struct*/
+struct Coord {
+ int x; /**< coordinate of x pixel */
+ int y; /**< coordinate of y pixel */
+};
+
+/** Course Information struct */
+struct Course {
+ Wall wall; /**< wall type */
+ Coord start; /**< coordinate of line start */
+ Coord end; /**< coordinate of line end */
+};
+
/** Ball Class
* @brief Class for controlling the golf ball
* @author Ellis Blackford Stroud
@@ -28,28 +50,35 @@
void printShotCount(N5110 &lcd);
- void drawPower(N5110 &lcd, Gamepad &pad);
-
+ void drawPower(N5110 &lcd, float mag);
+
+ void drawAim(N5110 &lcd, Vector2D joy_coord ,float angle);
+
void move_ball(int frame_rate);
Vector2D get_ball_pos();
- void shoot_ball(Gamepad &pad);
+ void shoot_ball(Gamepad &pad, Vector2D joy_coord);
int get_shot_count();
void set_vel(float x_vel, float y_vel);
-
- void read_joy(Gamepad &pad);
+
+ void check_wall_bounce(Course map[], int size);
+
+ void left_bounce(Coord start, Coord end);
- void check_wall_bounce();
+ void right_bounce(Coord start, Coord end);
+
+ void top_bounce(Coord start, Coord end);
+ void bottom_bounce(Coord start, Coord end);
+
+
private:
- Vector2D _joystick;
- float _mag;
float _x_pos;
float _y_pos;
float _x_vel;