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@18:304700b5d8f8, 2019-04-12 (annotated)
- Committer:
- lewisgw
- Date:
- Fri Apr 12 11:30:25 2019 +0000
- Revision:
- 18:304700b5d8f8
- Parent:
- Map/Map.cpp@15:876c047a6ec9
- Child:
- 21:20478f086bc2
Added a large menu artwork and re-named variables and functions to make the code more readable
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 | 14:9861fe85c803 | 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 | 14:9861fe85c803 | 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 | 18:304700b5d8f8 | 21 | void Platforms::generate_line_1(int length) { |
lewisgw | 14:9861fe85c803 | 22 | // Always move the line from L to R, and only move the end of the line |
lewisgw | 14:9861fe85c803 | 23 | // if the start has not gone off the screen. If it has, start again. |
lewisgw | 14:9861fe85c803 | 24 | _line_1.x_start--; |
lewisgw | 9:fff2009f826e | 25 | if(_line_1.x_start < 80 - length) _line_1.x_end--; |
lewisgw | 9:fff2009f826e | 26 | if(_line_1.x_start <= 0) _line_1.x_start = 0; |
lewisgw | 9:fff2009f826e | 27 | if(_line_1.x_end <= 0) { |
lewisgw | 9:fff2009f826e | 28 | _line_1.x_start = 80; |
lewisgw | 9:fff2009f826e | 29 | _line_1.x_end = 80; |
lewisgw | 9:fff2009f826e | 30 | } |
lewisgw | 9:fff2009f826e | 31 | } |
lewisgw | 14:9861fe85c803 | 32 | |
lewisgw | 18:304700b5d8f8 | 33 | void Platforms::generate_line_2(int length) { |
lewisgw | 9:fff2009f826e | 34 | _line_2.x_start--; |
lewisgw | 9:fff2009f826e | 35 | if(_line_2.x_start < 80 - length) _line_2.x_end--; |
lewisgw | 9:fff2009f826e | 36 | if(_line_2.x_start <= 0) _line_2.x_start = 0; |
lewisgw | 9:fff2009f826e | 37 | if(_line_2.x_end <= 0) { |
lewisgw | 9:fff2009f826e | 38 | _line_2.x_start = 80; |
lewisgw | 9:fff2009f826e | 39 | _line_2.x_end = 80; |
lewisgw | 9:fff2009f826e | 40 | } |
lewisgw | 9:fff2009f826e | 41 | } |
lewisgw | 6:8741d2011692 | 42 | |
lewisgw | 18:304700b5d8f8 | 43 | void Platforms::generate_line_3(int length) { |
lewisgw | 9:fff2009f826e | 44 | _line_3.x_start--; |
lewisgw | 9:fff2009f826e | 45 | if(_line_3.x_start < 80 - length) _line_3.x_end--; |
lewisgw | 9:fff2009f826e | 46 | if(_line_3.x_start <= 0) _line_3.x_start = 0; |
lewisgw | 9:fff2009f826e | 47 | if(_line_3.x_end <= 0) { |
lewisgw | 9:fff2009f826e | 48 | _line_3.x_start = 80; |
lewisgw | 9:fff2009f826e | 49 | _line_3.x_end = 80; |
lewisgw | 9:fff2009f826e | 50 | } |
lewisgw | 9:fff2009f826e | 51 | } |
lewisgw | 9:fff2009f826e | 52 | |
lewisgw | 18:304700b5d8f8 | 53 | Line Platforms::get_line_1() { |
lewisgw | 9:fff2009f826e | 54 | return _line_1; |
lewisgw | 9:fff2009f826e | 55 | } |
lewisgw | 6:8741d2011692 | 56 | |
lewisgw | 18:304700b5d8f8 | 57 | Line Platforms::get_line_2() { |
lewisgw | 9:fff2009f826e | 58 | return _line_2; |
lewisgw | 9:fff2009f826e | 59 | } |
lewisgw | 9:fff2009f826e | 60 | |
lewisgw | 18:304700b5d8f8 | 61 | Line Platforms::get_line_3() { |
lewisgw | 9:fff2009f826e | 62 | return _line_3; |
lewisgw | 9:fff2009f826e | 63 | } |
lewisgw | 6:8741d2011692 | 64 | |
lewisgw | 6:8741d2011692 | 65 | |
lewisgw | 15:876c047a6ec9 | 66 |