Harry Rance 200925395 Embedded Systems Project

Dependencies:   mbed

Committer:
harryrance
Date:
Wed May 03 16:33:20 2017 +0000
Revision:
7:569f3fc70ac5
Parent:
6:dca8b5e2ebe5
Committed with full documentation generated.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
harryrance 1:95d7dd44bb0d 1 #ifndef BULLET_H
harryrance 1:95d7dd44bb0d 2 #define BULLET_H
harryrance 1:95d7dd44bb0d 3
harryrance 1:95d7dd44bb0d 4 #include "mbed.h"
harryrance 1:95d7dd44bb0d 5 #include "N5110.h"
harryrance 1:95d7dd44bb0d 6 #include "Gamepad.h"
harryrance 1:95d7dd44bb0d 7 #include "UserShip.h"
harryrance 1:95d7dd44bb0d 8
harryrance 6:dca8b5e2ebe5 9 /** Bullet Class
harryrance 6:dca8b5e2ebe5 10 @brief Library for generating the bullet and bullet movement.
harryrance 6:dca8b5e2ebe5 11 @brief Can draw the bullet and generate movement using 2D Vectors.
harryrance 6:dca8b5e2ebe5 12 @brief Can also detect user input to identify when the bullet is fired or inactive.
harryrance 6:dca8b5e2ebe5 13
harryrance 6:dca8b5e2ebe5 14 @author Harry Rance
harryrance 6:dca8b5e2ebe5 15 @date 2nd May 2017
harryrance 6:dca8b5e2ebe5 16
harryrance 6:dca8b5e2ebe5 17 */
harryrance 6:dca8b5e2ebe5 18
harryrance 1:95d7dd44bb0d 19 class Bullet
harryrance 1:95d7dd44bb0d 20 {
harryrance 1:95d7dd44bb0d 21
harryrance 1:95d7dd44bb0d 22 public:
harryrance 6:dca8b5e2ebe5 23
harryrance 6:dca8b5e2ebe5 24 //Constructor
harryrance 1:95d7dd44bb0d 25 Bullet();
harryrance 6:dca8b5e2ebe5 26
harryrance 6:dca8b5e2ebe5 27 //Destructor
harryrance 1:95d7dd44bb0d 28 ~Bullet();
harryrance 6:dca8b5e2ebe5 29
harryrance 6:dca8b5e2ebe5 30 /** Initialise
harryrance 6:dca8b5e2ebe5 31 * Initialises the bullet with its x and y origin, speed and also the current user score and coins amount.
harryrance 6:dca8b5e2ebe5 32 * @param x_origin - sets the x origin (0-83) for the bullet.
harryrance 6:dca8b5e2ebe5 33 * @param y_origin - sets the y origin (0-47) for the bullet.
harryrance 6:dca8b5e2ebe5 34 * @param speed - sets the original speed for the bullet to move at
harryrance 6:dca8b5e2ebe5 35 * @param button_check - initialises the _button_check varaible to 0 to say that the button has not initially been pressed.
harryrance 6:dca8b5e2ebe5 36 * @param coins - sets the amount of original coins to start with to the set value.
harryrance 6:dca8b5e2ebe5 37 * @param score - sets the starting score to the defined value.
harryrance 6:dca8b5e2ebe5 38 */
harryrance 3:43970d8d642e 39 void initialise(int x_origin, int y_origin, int speed, int button_check, int coins, int score);
harryrance 6:dca8b5e2ebe5 40
harryrance 6:dca8b5e2ebe5 41 /** Draw
harryrance 6:dca8b5e2ebe5 42 * Draws the bullet on the LCD screen with regards to it's movement parameters.
harryrance 6:dca8b5e2ebe5 43 */
harryrance 1:95d7dd44bb0d 44 void draw(N5110 &lcd);
harryrance 6:dca8b5e2ebe5 45
harryrance 6:dca8b5e2ebe5 46 /** Update
harryrance 6:dca8b5e2ebe5 47 * Updates the movement and game mechanics parameters for the bullet.
harryrance 6:dca8b5e2ebe5 48 */
harryrance 1:95d7dd44bb0d 49 void update();
harryrance 6:dca8b5e2ebe5 50
harryrance 6:dca8b5e2ebe5 51 /** Check Button Press
harryrance 6:dca8b5e2ebe5 52 * Used to check if the button has been pressed, and change variables if this is true.
harryrance 6:dca8b5e2ebe5 53 */
harryrance 1:95d7dd44bb0d 54 void check_button_press(Gamepad &pad);
harryrance 1:95d7dd44bb0d 55
harryrance 6:dca8b5e2ebe5 56 /** Set Velocity
harryrance 6:dca8b5e2ebe5 57 * Sets the velocity of the bullet with x and y members.
harryrance 6:dca8b5e2ebe5 58 * @param v - contains the x and y values in a 2D vector of the velocity.
harryrance 6:dca8b5e2ebe5 59 */
harryrance 1:95d7dd44bb0d 60 void set_velocity(Vector2D v);
harryrance 6:dca8b5e2ebe5 61
harryrance 6:dca8b5e2ebe5 62 /** Set Position
harryrance 6:dca8b5e2ebe5 63 * Sets the position of the bullet with x and y members.
harryrance 6:dca8b5e2ebe5 64 * @param p - contains the x and y values in a 2D vector of the velocity.
harryrance 6:dca8b5e2ebe5 65 */
harryrance 1:95d7dd44bb0d 66 void set_position(Vector2D p);
harryrance 6:dca8b5e2ebe5 67
harryrance 6:dca8b5e2ebe5 68 /** Add Score
harryrance 6:dca8b5e2ebe5 69 * Function to add an integer value onto the score variable each time the boss/alien is hit.
harryrance 6:dca8b5e2ebe5 70 */
harryrance 2:50feb42b982c 71 void add_score();
harryrance 6:dca8b5e2ebe5 72
harryrance 6:dca8b5e2ebe5 73 /** Add Coins
harryrance 6:dca8b5e2ebe5 74 * Function to add an integer value onto the coins variable each time the boss/alien is hit.
harryrance 6:dca8b5e2ebe5 75 */
harryrance 2:50feb42b982c 76 void add_coins();
harryrance 6:dca8b5e2ebe5 77
harryrance 6:dca8b5e2ebe5 78 /** Gets velocity of the bullet.
harryrance 6:dca8b5e2ebe5 79 * returns a struct with x and y members, in the range of 0.0-1.0.
harryrance 6:dca8b5e2ebe5 80 */
harryrance 1:95d7dd44bb0d 81 Vector2D get_velocity();
harryrance 6:dca8b5e2ebe5 82
harryrance 6:dca8b5e2ebe5 83 /** Gets position of the bullet.
harryrance 6:dca8b5e2ebe5 84 * returns a struct with x and y members, with x in the range of 0-83 and y in the range of 0-47.
harryrance 6:dca8b5e2ebe5 85 */
harryrance 1:95d7dd44bb0d 86 Vector2D get_position();
harryrance 6:dca8b5e2ebe5 87
harryrance 6:dca8b5e2ebe5 88 /** Get Score
harryrance 6:dca8b5e2ebe5 89 * Returns an integer value for the current score.
harryrance 6:dca8b5e2ebe5 90 */
harryrance 2:50feb42b982c 91 int get_score();
harryrance 6:dca8b5e2ebe5 92
harryrance 6:dca8b5e2ebe5 93 /** Get Coins
harryrance 6:dca8b5e2ebe5 94 * Returns an integer value for the current coins.
harryrance 6:dca8b5e2ebe5 95 */
harryrance 2:50feb42b982c 96 int get_coins();
harryrance 6:dca8b5e2ebe5 97
harryrance 6:dca8b5e2ebe5 98 //Public integer variable for the y position of the bullet. Used in GameEngine.
harryrance 2:50feb42b982c 99 int _y;
harryrance 6:dca8b5e2ebe5 100
harryrance 6:dca8b5e2ebe5 101 //Public variable for the speed of the bullet. Used in GameEngine.
harryrance 2:50feb42b982c 102 int _speed;
harryrance 6:dca8b5e2ebe5 103
harryrance 6:dca8b5e2ebe5 104 //Public variable to check if the button is pressed or not. Used in GameEngine.
harryrance 2:50feb42b982c 105 int _button_check;
harryrance 6:dca8b5e2ebe5 106
harryrance 6:dca8b5e2ebe5 107 //Decrements the amount of user coins displayed when a life is purchased.
harryrance 3:43970d8d642e 108 void dec_coins_for_life();
harryrance 6:dca8b5e2ebe5 109
harryrance 6:dca8b5e2ebe5 110 /** The following 4 functions are for purchasing one of the four available ships in game.
harryrance 6:dca8b5e2ebe5 111 * They decrement the amount of displayed coins by a different amount depending on which button, X, Y, B or R has been pressed.
harryrance 6:dca8b5e2ebe5 112 * Each button corresponds to a different ship, all of different costs ranging from 50 coins to 200 coins.
harryrance 6:dca8b5e2ebe5 113 */
harryrance 3:43970d8d642e 114 void dec_coins_for_x();
harryrance 3:43970d8d642e 115 void dec_coins_for_y();
harryrance 3:43970d8d642e 116 void dec_coins_for_b();
harryrance 3:43970d8d642e 117 void dec_coins_for_r();
harryrance 1:95d7dd44bb0d 118
harryrance 1:95d7dd44bb0d 119 private:
harryrance 1:95d7dd44bb0d 120
harryrance 1:95d7dd44bb0d 121 UserShip _get_ship;
harryrance 1:95d7dd44bb0d 122 Vector2D _velocity;
harryrance 2:50feb42b982c 123
harryrance 1:95d7dd44bb0d 124 int _x_origin;
harryrance 1:95d7dd44bb0d 125 int _y_origin;
harryrance 1:95d7dd44bb0d 126 int _x;
harryrance 2:50feb42b982c 127 int _score;
harryrance 2:50feb42b982c 128 int _coins;
harryrance 1:95d7dd44bb0d 129
harryrance 1:95d7dd44bb0d 130 };
harryrance 1:95d7dd44bb0d 131
harryrance 1:95d7dd44bb0d 132 #endif
harryrance 1:95d7dd44bb0d 133