Harry Rance 200925395 Embedded Systems Project

Dependencies:   mbed

Committer:
harryrance
Date:
Wed May 03 16:24:01 2017 +0000
Revision:
6:dca8b5e2ebe5
Parent:
3:43970d8d642e
Full project complete with Doxygen commenting throughout; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
harryrance 0:c9bf674fe0c7 1 #ifndef USERSHIP_H
harryrance 0:c9bf674fe0c7 2 #define USERSHIP_H
harryrance 0:c9bf674fe0c7 3
harryrance 0:c9bf674fe0c7 4 #include "mbed.h"
harryrance 0:c9bf674fe0c7 5 #include "N5110.h"
harryrance 0:c9bf674fe0c7 6 #include "Gamepad.h"
harryrance 0:c9bf674fe0c7 7
harryrance 6:dca8b5e2ebe5 8 /** UserShip Class
harryrance 6:dca8b5e2ebe5 9 @brief Library for generating the user ship and it's movement mechanics.
harryrance 6:dca8b5e2ebe5 10 @brief Can be used to update the shpi's position on the screen depending on the user input.
harryrance 6:dca8b5e2ebe5 11 @brief Can also be used to determine which ship should be drawn if one has been purchase in-game.
harryrance 6:dca8b5e2ebe5 12
harryrance 6:dca8b5e2ebe5 13 @author Harry Rance
harryrance 6:dca8b5e2ebe5 14 @date 2nd May 2017
harryrance 6:dca8b5e2ebe5 15
harryrance 6:dca8b5e2ebe5 16 */
harryrance 0:c9bf674fe0c7 17 class UserShip
harryrance 0:c9bf674fe0c7 18 {
harryrance 0:c9bf674fe0c7 19 public:
harryrance 6:dca8b5e2ebe5 20
harryrance 6:dca8b5e2ebe5 21 //Constructor
harryrance 0:c9bf674fe0c7 22 UserShip();
harryrance 6:dca8b5e2ebe5 23
harryrance 6:dca8b5e2ebe5 24 //Destructor
harryrance 0:c9bf674fe0c7 25 ~UserShip();
harryrance 6:dca8b5e2ebe5 26
harryrance 6:dca8b5e2ebe5 27 /** Initialise
harryrance 6:dca8b5e2ebe5 28 * Initialises the x and y origin of the user ship, along with the y vector component.
harryrance 6:dca8b5e2ebe5 29 * @param y - integer value used to control the velocity and position of the ship in the y direction (should be kept constant at 0).
harryrance 6:dca8b5e2ebe5 30 * @param x_origin - integer value to determine x origin poisiton (0-83).
harryrance 6:dca8b5e2ebe5 31 * @param y_origin - integer value to determine y origin position (0-47).
harryrance 6:dca8b5e2ebe5 32 */
harryrance 0:c9bf674fe0c7 33 void initialise(int y, int x_origin, int y_origin);
harryrance 6:dca8b5e2ebe5 34
harryrance 6:dca8b5e2ebe5 35 /** Draw
harryrance 6:dca8b5e2ebe5 36 * Calls all of the draw functions in order to draw each ship when required.
harryrance 6:dca8b5e2ebe5 37 */
harryrance 0:c9bf674fe0c7 38 void draw(N5110 &lcd);
harryrance 6:dca8b5e2ebe5 39
harryrance 6:dca8b5e2ebe5 40 /* Draw Default/1/2/3/4 Ship
harryrance 6:dca8b5e2ebe5 41 * The following 5 functions set the pixels for the 5 different types of ships that can be used.
harryrance 6:dca8b5e2ebe5 42 * Default ship is the first ship that can be used. 1, 2, 3 and 4 can be purchased in game using coins.
harryrance 6:dca8b5e2ebe5 43 */
harryrance 3:43970d8d642e 44 void draw_default_ship(N5110 &lcd);
harryrance 3:43970d8d642e 45 void draw_ship_1(N5110 &lcd);
harryrance 3:43970d8d642e 46 void draw_ship_2(N5110 &lcd);
harryrance 3:43970d8d642e 47 void draw_ship_3(N5110 &lcd);
harryrance 3:43970d8d642e 48 void draw_ship_4(N5110 &lcd);
harryrance 6:dca8b5e2ebe5 49
harryrance 6:dca8b5e2ebe5 50 /** Update
harryrance 6:dca8b5e2ebe5 51 * Updates the ship's x and y position and velocity with regards to the user input on the joystick.
harryrance 6:dca8b5e2ebe5 52 * @param d - enum value to denote in which direction the joystick has been moved.
harryrance 6:dca8b5e2ebe5 53 * @param mag - float value to determine the magnitude at which the joystick has been moved.
harryrance 6:dca8b5e2ebe5 54 * Magnitude determines the speed at which the ship moves.
harryrance 6:dca8b5e2ebe5 55 */
harryrance 0:c9bf674fe0c7 56 void update(Direction d, float mag);
harryrance 6:dca8b5e2ebe5 57
harryrance 6:dca8b5e2ebe5 58 /** Get Position
harryrance 6:dca8b5e2ebe5 59 * Gets the position of the ship and returns a 2D Vector with x and y members.
harryrance 6:dca8b5e2ebe5 60 */
harryrance 0:c9bf674fe0c7 61 Vector2D get_pos();
harryrance 6:dca8b5e2ebe5 62
harryrance 6:dca8b5e2ebe5 63 /** Set Position
harryrance 6:dca8b5e2ebe5 64 * Sets the position for the ship in a 2D Vector with x and y members.
harryrance 6:dca8b5e2ebe5 65 * @param p - 2D vector with x and y members of boss position.
harryrance 6:dca8b5e2ebe5 66 */
harryrance 1:95d7dd44bb0d 67 void set_pos(Vector2D p);
harryrance 0:c9bf674fe0c7 68
harryrance 0:c9bf674fe0c7 69 private:
harryrance 0:c9bf674fe0c7 70 int _x_origin;
harryrance 0:c9bf674fe0c7 71 int _y_origin;
harryrance 0:c9bf674fe0c7 72 int _x;
harryrance 0:c9bf674fe0c7 73 int _y;
harryrance 0:c9bf674fe0c7 74 int _speed;
harryrance 0:c9bf674fe0c7 75
harryrance 0:c9bf674fe0c7 76 };
harryrance 0:c9bf674fe0c7 77 #endif
harryrance 0:c9bf674fe0c7 78