ELEC2645 (2018/19) / Mbed 2 deprecated el17ebs

Dependencies:   mbed FATFileSystem

Committer:
ellisbhastroud
Date:
Fri Mar 29 18:45:40 2019 +0000
Revision:
3:a8960004d261
Child:
4:035448357749
Menu Working, Game Mechanisms Developed. Can now use joystick and button to shoot golf ball with power dependant on joystick magnitude.

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 3:a8960004d261 8
ellisbhastroud 3:a8960004d261 9 /** Ball Class
ellisbhastroud 3:a8960004d261 10 * @brief Class for controlling the golf ball
ellisbhastroud 3:a8960004d261 11 * @author Ellis Blackford Stroud
ellisbhastroud 3:a8960004d261 12 * @date May, 2018
ellisbhastroud 3:a8960004d261 13 */
ellisbhastroud 3:a8960004d261 14
ellisbhastroud 3:a8960004d261 15 /** Joystick struct */
ellisbhastroud 3:a8960004d261 16 struct Joystick {
ellisbhastroud 3:a8960004d261 17 float x; /**< float for x value */
ellisbhastroud 3:a8960004d261 18 float y; /**< float for y value */
ellisbhastroud 3:a8960004d261 19 float mag; /**< float for magnitude */
ellisbhastroud 3:a8960004d261 20 };
ellisbhastroud 3:a8960004d261 21
ellisbhastroud 3:a8960004d261 22
ellisbhastroud 3:a8960004d261 23 class Ball {
ellisbhastroud 3:a8960004d261 24
ellisbhastroud 3:a8960004d261 25 public:
ellisbhastroud 3:a8960004d261 26
ellisbhastroud 3:a8960004d261 27 /** Constructor */
ellisbhastroud 3:a8960004d261 28 Ball();
ellisbhastroud 3:a8960004d261 29
ellisbhastroud 3:a8960004d261 30 /** Destructor */
ellisbhastroud 3:a8960004d261 31 ~Ball();
ellisbhastroud 3:a8960004d261 32
ellisbhastroud 3:a8960004d261 33 void init(float x_pos, float y_pos);
ellisbhastroud 3:a8960004d261 34
ellisbhastroud 3:a8960004d261 35 void draw_ball(N5110 &lcd);
ellisbhastroud 3:a8960004d261 36
ellisbhastroud 3:a8960004d261 37 void draw_aim(N5110 &lcd);
ellisbhastroud 3:a8960004d261 38
ellisbhastroud 3:a8960004d261 39 void draw_screen(N5110 &lcd);
ellisbhastroud 3:a8960004d261 40
ellisbhastroud 3:a8960004d261 41 void move_ball();
ellisbhastroud 3:a8960004d261 42
ellisbhastroud 3:a8960004d261 43 void shoot_ball(Gamepad &pad);
ellisbhastroud 3:a8960004d261 44
ellisbhastroud 3:a8960004d261 45 void set_vel(float x_vel, float y_vel);
ellisbhastroud 3:a8960004d261 46
ellisbhastroud 3:a8960004d261 47 void check_hit_wall();
ellisbhastroud 3:a8960004d261 48
ellisbhastroud 3:a8960004d261 49 void read_joy(Gamepad &pad);
ellisbhastroud 3:a8960004d261 50
ellisbhastroud 3:a8960004d261 51 private:
ellisbhastroud 3:a8960004d261 52
ellisbhastroud 3:a8960004d261 53
ellisbhastroud 3:a8960004d261 54 Vector2D _coords;
ellisbhastroud 3:a8960004d261 55 Joystick _joy;
ellisbhastroud 3:a8960004d261 56 float _x_pos;
ellisbhastroud 3:a8960004d261 57 float _y_pos;
ellisbhastroud 3:a8960004d261 58 float _x_vel;
ellisbhastroud 3:a8960004d261 59 float _y_vel;
ellisbhastroud 3:a8960004d261 60 };
ellisbhastroud 3:a8960004d261 61
ellisbhastroud 3:a8960004d261 62 #endif