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/Platforms.cpp@27:c920c5ec31af, 2019-05-04 (annotated)
- Committer:
- lewisgw
- Date:
- Sat May 04 13:26:50 2019 +0000
- Revision:
- 27:c920c5ec31af
- Parent:
- 21:20478f086bc2
- Child:
- 29:bdc4138b5171
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lewisgw | 18:304700b5d8f8 | 1 | #include "Platforms.h" |
lewisgw | 6:8741d2011692 | 2 | |
lewisgw | 21:20478f086bc2 | 3 | // Constructor and destructor. |
lewisgw | 18:304700b5d8f8 | 4 | Platforms::Platforms() {} |
lewisgw | 6:8741d2011692 | 5 | |
lewisgw | 18:304700b5d8f8 | 6 | Platforms::~Platforms() {} |
lewisgw | 6:8741d2011692 | 7 | |
lewisgw | 18:304700b5d8f8 | 8 | void Platforms::init(int y) { |
lewisgw | 21:20478f086bc2 | 9 | // Starting values for the platforms. |
lewisgw | 9:fff2009f826e | 10 | _line_1.x_start = 0; |
lewisgw | 9:fff2009f826e | 11 | _line_1.x_end = 15; |
lewisgw | 10:8bf3713d9e9c | 12 | _line_1.y = y; |
lewisgw | 9:fff2009f826e | 13 | _line_2.x_start = 25; |
lewisgw | 18:304700b5d8f8 | 14 | _line_2.x_end = 60; |
lewisgw | 10:8bf3713d9e9c | 15 | _line_2.y = y; |
lewisgw | 9:fff2009f826e | 16 | _line_3.x_start = 60; |
lewisgw | 9:fff2009f826e | 17 | _line_3.x_end = 80; |
lewisgw | 10:8bf3713d9e9c | 18 | _line_3.y = y; |
lewisgw | 9:fff2009f826e | 19 | } |
lewisgw | 6:8741d2011692 | 20 | |
lewisgw | 21:20478f086bc2 | 21 | void Platforms::set_line_1(int length) { |
lewisgw | 27:c920c5ec31af | 22 | // Lines move from R to L via de-incrementing. |
lewisgw | 14:9861fe85c803 | 23 | _line_1.x_start--; |
lewisgw | 21:20478f086bc2 | 24 | if (_line_1.x_start < 80 - length) _line_1.x_end--; // Only move end of the |
lewisgw | 21:20478f086bc2 | 25 | // line if the line length is fully on the screen. |
lewisgw | 21:20478f086bc2 | 26 | if (_line_1.x_start <= 0) _line_1.x_start = 0; // Terminate line 1 start at 0 |
lewisgw | 21:20478f086bc2 | 27 | // when it reaches LHS of screen so it does not go negative. |
lewisgw | 21:20478f086bc2 | 28 | if (_line_1.x_end <= 0) { // Start Drawing line again from start once the end |
lewisgw | 21:20478f086bc2 | 29 | // has reaches LHS of screen. |
lewisgw | 9:fff2009f826e | 30 | _line_1.x_start = 80; |
lewisgw | 9:fff2009f826e | 31 | _line_1.x_end = 80; |
lewisgw | 9:fff2009f826e | 32 | } |
lewisgw | 9:fff2009f826e | 33 | } |
lewisgw | 14:9861fe85c803 | 34 | |
lewisgw | 21:20478f086bc2 | 35 | void Platforms::set_line_2(int length) { |
lewisgw | 9:fff2009f826e | 36 | _line_2.x_start--; |
lewisgw | 21:20478f086bc2 | 37 | if (_line_2.x_start < 80 - length) _line_2.x_end--; |
lewisgw | 21:20478f086bc2 | 38 | if (_line_2.x_start <= 0) _line_2.x_start = 0; |
lewisgw | 21:20478f086bc2 | 39 | if (_line_2.x_end <= 0) { |
lewisgw | 9:fff2009f826e | 40 | _line_2.x_start = 80; |
lewisgw | 9:fff2009f826e | 41 | _line_2.x_end = 80; |
lewisgw | 9:fff2009f826e | 42 | } |
lewisgw | 9:fff2009f826e | 43 | } |
lewisgw | 6:8741d2011692 | 44 | |
lewisgw | 21:20478f086bc2 | 45 | void Platforms::set_line_3(int length) { |
lewisgw | 9:fff2009f826e | 46 | _line_3.x_start--; |
lewisgw | 21:20478f086bc2 | 47 | if (_line_3.x_start < 80 - length) _line_3.x_end--; |
lewisgw | 21:20478f086bc2 | 48 | if (_line_3.x_start <= 0) _line_3.x_start = 0; |
lewisgw | 21:20478f086bc2 | 49 | if (_line_3.x_end <= 0) { |
lewisgw | 9:fff2009f826e | 50 | _line_3.x_start = 80; |
lewisgw | 9:fff2009f826e | 51 | _line_3.x_end = 80; |
lewisgw | 9:fff2009f826e | 52 | } |
lewisgw | 9:fff2009f826e | 53 | } |
lewisgw | 9:fff2009f826e | 54 | |
lewisgw | 18:304700b5d8f8 | 55 | Line Platforms::get_line_1() { |
lewisgw | 9:fff2009f826e | 56 | return _line_1; |
lewisgw | 9:fff2009f826e | 57 | } |
lewisgw | 6:8741d2011692 | 58 | |
lewisgw | 18:304700b5d8f8 | 59 | Line Platforms::get_line_2() { |
lewisgw | 9:fff2009f826e | 60 | return _line_2; |
lewisgw | 9:fff2009f826e | 61 | } |
lewisgw | 9:fff2009f826e | 62 | |
lewisgw | 18:304700b5d8f8 | 63 | Line Platforms::get_line_3() { |
lewisgw | 9:fff2009f826e | 64 | return _line_3; |
lewisgw | 9:fff2009f826e | 65 | } |
lewisgw | 6:8741d2011692 | 66 | |
lewisgw | 6:8741d2011692 | 67 | |
lewisgw | 15:876c047a6ec9 | 68 | |
lewisgw | 21:20478f086bc2 | 69 |