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
Diff: Map/Map.cpp
- Revision:
- 9:fff2009f826e
- Parent:
- 8:5327418f823a
- Child:
- 10:8bf3713d9e9c
--- a/Map/Map.cpp Sat Mar 23 15:36:56 2019 +0000 +++ b/Map/Map.cpp Sun Mar 24 19:22:50 2019 +0000 @@ -1,99 +1,63 @@ #include "Map.h" -Map::Map(){} +Map::Map() {} -Map::~Map(){} +Map::~Map() {} void Map::init() { - _line_1.x_start = 0; - _line_1.x_end = 15; - _line_1.y = 40; - _line_2.x_start = 25; - _line_2.x_end = 50; - _line_2.y = 40; - _line_3.x_start = 60; - _line_3.x_end = 80; - _line_3.y = 40; - } - + _line_1.x_start = 0; + _line_1.x_end = 15; + _line_1.y = 40; + _line_2.x_start = 25; + _line_2.x_end = 50; + _line_2.y = 40; + _line_3.x_start = 60; + _line_3.x_end = 80; + _line_3.y = 40; +} void Map::generate_line_1(int length) { - _line_1.x_start--; - if(_line_1.x_start < 80 - length) { - _line_1.x_end--; - } - if(_line_1.x_start <= 0) { - _line_1.x_start = 0; - } - if(_line_1.x_end <= 0) { - _line_1.x_start = 80; - _line_1.x_end = 80; - } - } + _line_1.x_start--; + if(_line_1.x_start < 80 - length) _line_1.x_end--; + if(_line_1.x_start <= 0) _line_1.x_start = 0; + if(_line_1.x_end <= 0) { + _line_1.x_start = 80; + _line_1.x_end = 80; + } +} void Map::generate_line_2(int length) { - _line_2.x_start--; - if(_line_2.x_start < 80 - length) { - _line_2.x_end--; - } - if(_line_2.x_start <= 0) { - _line_2.x_start = 0; - } - if(_line_2.x_end <= 0) { - _line_2.x_start = 80; - _line_2.x_end = 80; - } - - } + _line_2.x_start--; + if(_line_2.x_start < 80 - length) _line_2.x_end--; + if(_line_2.x_start <= 0) _line_2.x_start = 0; + if(_line_2.x_end <= 0) { + _line_2.x_start = 80; + _line_2.x_end = 80; + } +} void Map::generate_line_3(int length) { - _line_3.x_start--; - if(_line_3.x_start < 80 - length) { - _line_3.x_end--; - } - if(_line_3.x_start <= 0) { - _line_3.x_start = 0; - } - if(_line_3.x_end <= 0) { - _line_3.x_start = 80; - _line_3.x_end = 80; - } + _line_3.x_start--; + if(_line_3.x_start < 80 - length) _line_3.x_end--; + if(_line_3.x_start <= 0) _line_3.x_start = 0; + if(_line_3.x_end <= 0) { + _line_3.x_start = 80; + _line_3.x_end = 80; + } +} + +Line Map::get_line_1() { + return _line_1; +} - } +Line Map::get_line_2() { + return _line_2; +} + +Line Map::get_line_3() { + return _line_3; +} - -Line Map::get_line_1() { - return _line_1; - } - - -Line Map::get_line_2() { - return _line_2; - } - -Line Map::get_line_3() { - return _line_3; - } - - - /* - if(_line_1.x_end < (80 - gap_size)) { // only start moving line 2 if the gap has passed - _line_2_counter = 1; - } else { - _line_2_counter = 0; - } - _line_2.x_start = _line_2.x_start - _line_2_counter; // on every iteration increase size of line 2, fixed on RHS and increasing on LHS - _line_2.x_end = _line_2.x_start + 80; - if(_line_2.x_end > 81) { - _line_2.x_end = 80; // ensure ends at 80 TEST THIS ON ITS OWN - } - - if(_line_2.x_start == 1) { - _line_1.x_start = 0; - _line_1.x_end = 80; - _line_2.x_start = 80; - _line_2.x_end = 80; - } - */ \ No newline at end of file + \ No newline at end of file