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
Map/Map.cpp@14:9861fe85c803, 2019-04-04 (annotated)
- Committer:
- lewisgw
- Date:
- Thu Apr 04 18:19:26 2019 +0000
- Revision:
- 14:9861fe85c803
- Parent:
- 10:8bf3713d9e9c
- Child:
- 15:876c047a6ec9
Same functionality as last commit, large functions have been broken up into smaller ones and every .cpp file commented.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lewisgw | 6:8741d2011692 | 1 | #include "Map.h" |
lewisgw | 6:8741d2011692 | 2 | |
lewisgw | 14:9861fe85c803 | 3 | // Constructor and destructor |
lewisgw | 9:fff2009f826e | 4 | Map::Map() {} |
lewisgw | 6:8741d2011692 | 5 | |
lewisgw | 9:fff2009f826e | 6 | Map::~Map() {} |
lewisgw | 6:8741d2011692 | 7 | |
lewisgw | 10:8bf3713d9e9c | 8 | void Map::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 | 9:fff2009f826e | 14 | _line_2.x_end = 50; |
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 | 6:8741d2011692 | 21 | void Map::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 | 6:8741d2011692 | 33 | void Map::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 | 6:8741d2011692 | 43 | void Map::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 | 9:fff2009f826e | 53 | Line Map::get_line_1() { |
lewisgw | 9:fff2009f826e | 54 | return _line_1; |
lewisgw | 9:fff2009f826e | 55 | } |
lewisgw | 6:8741d2011692 | 56 | |
lewisgw | 9:fff2009f826e | 57 | Line Map::get_line_2() { |
lewisgw | 9:fff2009f826e | 58 | return _line_2; |
lewisgw | 9:fff2009f826e | 59 | } |
lewisgw | 9:fff2009f826e | 60 | |
lewisgw | 9:fff2009f826e | 61 | Line Map::get_line_3() { |
lewisgw | 9:fff2009f826e | 62 | return _line_3; |
lewisgw | 9:fff2009f826e | 63 | } |
lewisgw | 6:8741d2011692 | 64 | |
lewisgw | 6:8741d2011692 | 65 | |
lewisgw | 9:fff2009f826e | 66 |