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
Floors/Floors.h@26:d16a5b1e0ace, 2019-05-08 (annotated)
- Committer:
- el17m2h
- Date:
- Wed May 08 17:24:35 2019 +0000
- Revision:
- 26:d16a5b1e0ace
- Parent:
- 24:67dc71a8f009
- Child:
- 29:15e9640646b7
Added comments for the documentation file.
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:0001cb3eb053 | 14 | class Floors{ |
el17m2h | 1:0001cb3eb053 | 15 | public: |
el17m2h | 1:0001cb3eb053 | 16 | Floors(); |
el17m2h | 1:0001cb3eb053 | 17 | ~Floors(); |
el17m2h | 24:67dc71a8f009 | 18 | |
el17m2h | 24:67dc71a8f009 | 19 | /** |
el17m2h | 26:d16a5b1e0ace | 20 | @brief Defines the initial position of the floor, its width and height |
el17m2h | 26:d16a5b1e0ace | 21 | @param int y |
el17m2h | 26:d16a5b1e0ace | 22 | @param int width |
el17m2h | 26:d16a5b1e0ace | 23 | @param int height |
el17m2h | 26:d16a5b1e0ace | 24 | @details The x-coordinate is initially random and excludes the space 30-40 so that the doodler falls |
el17m2h | 26:d16a5b1e0ace | 25 | to a floor that is set to be at the bottom center (instead of a random position) in the engine cpp |
el17m2h | 26:d16a5b1e0ace | 26 | (to make sure there is always a stating point position for the doodler). This is done by using a |
el17m2h | 26:d16a5b1e0ace | 27 | decision object to choose which randomly generated x-coordinate position the doodler will have |
el17m2h | 26:d16a5b1e0ace | 28 | (either at the left side or the right side). The y-coordinate position is inputed from the engine |
el17m2h | 26:d16a5b1e0ace | 29 | cpp and kept the same. |
el17m2h | 26:d16a5b1e0ace | 30 | */ |
el17m2h | 11:2041290b5a74 | 31 | void init(int y, int width, int height); |
el17m2h | 24:67dc71a8f009 | 32 | |
el17m2h | 24:67dc71a8f009 | 33 | /** |
el17m2h | 26:d16a5b1e0ace | 34 | @brief Prints the floor into the LCD screen |
el17m2h | 26:d16a5b1e0ace | 35 | @param N5110 &lcd |
el17m2h | 26:d16a5b1e0ace | 36 | @details The function draws a 14 x 1 rectangle |
el17m2h | 24:67dc71a8f009 | 37 | */ |
el17m2h | 1:0001cb3eb053 | 38 | void draw(N5110 &lcd); |
el17m2h | 24:67dc71a8f009 | 39 | |
el17m2h | 24:67dc71a8f009 | 40 | /** |
el17m2h | 26:d16a5b1e0ace | 41 | @brief Updates the position of the floor |
el17m2h | 26:d16a5b1e0ace | 42 | @param float doodler_pos_y is inputed into the function to decides if the floor should move |
el17m2h | 26:d16a5b1e0ace | 43 | or remain at its position. |
el17m2h | 26:d16a5b1e0ace | 44 | @details The function first checks if the position should change, which occurs if the doodler's position is above |
el17m2h | 26:d16a5b1e0ace | 45 | 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 | 46 | the y-coordinate). The function then checks if the floor has reached the bottom of the screen (y-coordinate over 45) |
el17m2h | 26:d16a5b1e0ace | 47 | 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 | 26:d16a5b1e0ace | 48 | making there be 6 floors always on the screen. |
el17m2h | 24:67dc71a8f009 | 49 | */ |
el17m2h | 15:4efa04a6a376 | 50 | void update(float doodler_pos_y); |
el17m2h | 24:67dc71a8f009 | 51 | |
el17m2h | 24:67dc71a8f009 | 52 | /** |
el17m2h | 26:d16a5b1e0ace | 53 | @brief Returns the current floor's position as a vector |
el17m2h | 26:d16a5b1e0ace | 54 | @details Gets the current value in the floor's class for the position |
el17m2h | 24:67dc71a8f009 | 55 | */ |
el17m2h | 14:529f798adae4 | 56 | Vector2D get_position(); |
el17m2h | 24:67dc71a8f009 | 57 | |
el17m2h | 26:d16a5b1e0ace | 58 | /** |
el17m2h | 26:d16a5b1e0ace | 59 | @brief Sets the floor's position in the Floor's class to equal the inputed vector parameter |
el17m2h | 26:d16a5b1e0ace | 60 | @param Vector2D pos is inputed to define the new position |
el17m2h | 26:d16a5b1e0ace | 61 | @details The function sets the floor's position by making the current position equal the inputed |
el17m2h | 26:d16a5b1e0ace | 62 | vector parameter to the function. |
el17m2h | 24:67dc71a8f009 | 63 | */ |
el17m2h | 14:529f798adae4 | 64 | void set_position(Vector2D pos); // mutators |
el17m2h | 1:0001cb3eb053 | 65 | |
el17m2h | 1:0001cb3eb053 | 66 | private: |
el17m2h | 1:0001cb3eb053 | 67 | int _height; |
el17m2h | 1:0001cb3eb053 | 68 | int _width; |
el17m2h | 14:529f798adae4 | 69 | Vector2D _position; |
el17m2h | 20:a359092079b0 | 70 | Enemy _eny; |
el17m2h | 20:a359092079b0 | 71 | int place; |
el17m2h | 1:0001cb3eb053 | 72 | |
el17m2h | 1:0001cb3eb053 | 73 | }; |
el17m2h | 1:0001cb3eb053 | 74 | #endif |