ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Committer:
el17m2h
Date:
Wed May 08 21:11:35 2019 +0000
Revision:
29:15e9640646b7
Parent:
26:d16a5b1e0ace
Child:
31:5c4acae51026
Changed the enemy file so that it has functions to make it update its position or make it disappear from the screen. The floors h file includes the enemy, and depending on its position it updates it or not.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17m2h 1:0001cb3eb053 1 #ifndef FLOORS_H
el17m2h 1:0001cb3eb053 2 #define FLOORS_H
el17m2h 1:0001cb3eb053 3
el17m2h 1:0001cb3eb053 4 #include "mbed.h"
el17m2h 1:0001cb3eb053 5 #include "N5110.h"
el17m2h 1:0001cb3eb053 6 #include "Gamepad.h"
el17m2h 20:a359092079b0 7 #include "Enemy.h"
el17m2h 8:90e789413e0b 8
el17m2h 26:d16a5b1e0ace 9 /** Floor class
el17m2h 26:d16a5b1e0ace 10 @brief Class for the floor
el17m2h 24:67dc71a8f009 11 @author Melissa Hartmann
el17m2h 24:67dc71a8f009 12 @date May 2019
el17m2h 24:67dc71a8f009 13 */
el17m2h 29:15e9640646b7 14 class Floors
el17m2h 29:15e9640646b7 15 {
el17m2h 1:0001cb3eb053 16 public:
el17m2h 1:0001cb3eb053 17 Floors();
el17m2h 1:0001cb3eb053 18 ~Floors();
el17m2h 29:15e9640646b7 19
el17m2h 29:15e9640646b7 20 /**
el17m2h 26:d16a5b1e0ace 21 @brief Defines the initial position of the floor, its width and height
el17m2h 29:15e9640646b7 22 @param int y
el17m2h 29:15e9640646b7 23 @param int width
el17m2h 26:d16a5b1e0ace 24 @param int height
el17m2h 29:15e9640646b7 25 @details The x-coordinate is initially random and excludes the space 30-40 so that the doodler falls
el17m2h 29:15e9640646b7 26 to a floor that is set to be at the bottom center (instead of a random position) in the engine cpp
el17m2h 29:15e9640646b7 27 (to make sure there is always a stating point position for the doodler). This is done by using a
el17m2h 29:15e9640646b7 28 decision object to choose which randomly generated x-coordinate position the doodler will have
el17m2h 29:15e9640646b7 29 (either at the left side or the right side). The y-coordinate position is inputed from the engine
el17m2h 29:15e9640646b7 30 cpp and kept the same.
el17m2h 29:15e9640646b7 31 */
el17m2h 11:2041290b5a74 32 void init(int y, int width, int height);
el17m2h 29:15e9640646b7 33
el17m2h 29:15e9640646b7 34 /**
el17m2h 26:d16a5b1e0ace 35 @brief Prints the floor into the LCD screen
el17m2h 26:d16a5b1e0ace 36 @param N5110 &lcd
el17m2h 26:d16a5b1e0ace 37 @details The function draws a 14 x 1 rectangle
el17m2h 24:67dc71a8f009 38 */
el17m2h 1:0001cb3eb053 39 void draw(N5110 &lcd);
el17m2h 29:15e9640646b7 40
el17m2h 29:15e9640646b7 41 /**
el17m2h 26:d16a5b1e0ace 42 @brief Updates the position of the floor
el17m2h 29:15e9640646b7 43 @param float doodler_pos_y is inputed into the function to decides if the floor should move
el17m2h 26:d16a5b1e0ace 44 or remain at its position.
el17m2h 29:15e9640646b7 45 @details The function first checks if the position should change, which occurs if the doodler's position is above
el17m2h 29:15e9640646b7 46 the middle of the screen's height (x-coordinate less than 25). If it is so, the floor will shift downwards (add 1 to
el17m2h 26:d16a5b1e0ace 47 the y-coordinate). The function then checks if the floor has reached the bottom of the screen (y-coordinate over 45)
el17m2h 29:15e9640646b7 48 and if so, the floor will re-appear at the top of the screen (y-coordinate = 9) and at a random x-coordinate position,
el17m2h 29:15e9640646b7 49 making there be 6 floors always on the screen.
el17m2h 24:67dc71a8f009 50 */
el17m2h 29:15e9640646b7 51 void update(float doodler_pos_x, float doodler_pos_y, float _bullet_pos_x, float _bullet_pos_y);
el17m2h 29:15e9640646b7 52
el17m2h 24:67dc71a8f009 53
el17m2h 29:15e9640646b7 54 void check_enemy(float _bullet_pos_x, float _bullet_pos_y);
el17m2h 29:15e9640646b7 55
el17m2h 29:15e9640646b7 56 /**
el17m2h 26:d16a5b1e0ace 57 @brief Returns the current floor's position as a vector
el17m2h 26:d16a5b1e0ace 58 @details Gets the current value in the floor's class for the position
el17m2h 24:67dc71a8f009 59 */
el17m2h 29:15e9640646b7 60 Vector2D get_position();
el17m2h 29:15e9640646b7 61
el17m2h 26:d16a5b1e0ace 62 /**
el17m2h 26:d16a5b1e0ace 63 @brief Sets the floor's position in the Floor's class to equal the inputed vector parameter
el17m2h 26:d16a5b1e0ace 64 @param Vector2D pos is inputed to define the new position
el17m2h 29:15e9640646b7 65 @details The function sets the floor's position by making the current position equal the inputed
el17m2h 26:d16a5b1e0ace 66 vector parameter to the function.
el17m2h 24:67dc71a8f009 67 */
el17m2h 14:529f798adae4 68 void set_position(Vector2D pos); // mutators
el17m2h 29:15e9640646b7 69
el17m2h 1:0001cb3eb053 70 private:
el17m2h 1:0001cb3eb053 71 int _height;
el17m2h 1:0001cb3eb053 72 int _width;
el17m2h 14:529f798adae4 73 Vector2D _position;
el17m2h 29:15e9640646b7 74 Enemy eny;
el17m2h 29:15e9640646b7 75 bool put_enemy;
el17m2h 29:15e9640646b7 76 Vector2D enemy_position;
el17m2h 20:a359092079b0 77 int place;
el17m2h 29:15e9640646b7 78 float _doodler_pos_x;
el17m2h 29:15e9640646b7 79 float _doodler_pos_y;
el17m2h 29:15e9640646b7 80
el17m2h 1:0001cb3eb053 81 };
el17m2h 1:0001cb3eb053 82 #endif