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
Platforms Class Reference
#include <Platforms.h>
Public Member Functions | |
| Platforms () | |
| Constructor. | |
| ~Platforms () | |
| Destructor. | |
| void | init (int y) |
| Initialises Platforms object. | |
| void | set_line_1 (int length) |
| Sets all parameters of line 1. | |
| void | set_line_2 (int length) |
| Sets all parameters of line 2. | |
| void | set_line_3 (int length) |
| Sets all parameters of line 3. | |
| Line | get_line_1 () |
| Gets line 1. | |
| Line | get_line_2 () |
| Gets line 2. | |
| Line | get_line_3 () |
| Gets line 3. | |
Detailed Description
Platforms Class.
Generates a row of platforms (lines) for the skateboarder to move on
- Date:
- March 2019
#include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Platforms.h" #include <cstdlib> #include <ctime> N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad gamepad; Platforms _lower_platforms; int _length_1; int _length_2; int _length_3; Line _lower_line_1; Line _lower_line_2; Line _lower_line_3; int main() { _lower_platforms.init(20); // Set vertical height to 20; while(1) { // Set all the line lengths to random values. _length_1 = (rand() %20) + 10; _lower_platforms.set_line_1(_length_1); _lower_line_1 = _lower_platforms.get_line_1(); _length_2 = (rand() %20) + 10; _lower_platforms.set_line_2(_length_2); _lower_line_2 = _lower_platforms.get_line_2(); _length_3 = (rand() %20) + 10; _lower_platforms.set_line_3(_length_3); _lower_line_3 = _lower_platforms.get_line_3(); // Print lines. lcd.drawLine(_lower_line_2.x_start,_lower_line_2.y,_lower_line_2.x_end, _lower_line_2.y,FILL_BLACK); lcd.drawLine(_lower_line_1.x_start,_lower_line_1.y,_lower_line_1.x_end, _lower_line_1.y,FILL_BLACK); lcd.drawLine(_lower_line_3.x_start,_lower_line_3.y,_lower_line_3.x_end, _lower_line_3.y,FILL_BLACK); } }
Definition at line 67 of file Platforms.h.
Constructor & Destructor Documentation
| Platforms | ( | ) |
| ~Platforms | ( | ) |
Member Function Documentation
| Line get_line_1 | ( | ) |
| Line get_line_2 | ( | ) |
| Line get_line_3 | ( | ) |
| void init | ( | int | y ) |
Initialises Platforms object.
- Parameters:
-
y The initial vertical coordinate of the platforms.
Definition at line 8 of file Platforms.cpp.
| void set_line_1 | ( | int | length ) |
Sets all parameters of line 1.
- Parameters:
-
length the length of line 1
Definition at line 21 of file Platforms.cpp.
| void set_line_2 | ( | int | length ) |
Sets all parameters of line 2.
- Parameters:
-
length the length of line 2
Definition at line 35 of file Platforms.cpp.
| void set_line_3 | ( | int | length ) |
Sets all parameters of line 3.
- Parameters:
-
length the length of line 3
Definition at line 46 of file Platforms.cpp.
Generated on Mon Jul 18 2022 14:06:02 by
1.7.2