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:
- 6:8741d2011692
- Child:
- 8:5327418f823a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Map/Map.cpp Tue Mar 19 11:34:21 2019 +0000 @@ -0,0 +1,99 @@ +#include "Map.h" + +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 = 40; + _line_2.y = 40; + _line_3.x_start = 50; + _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; + } + } + + +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; + } + + } + +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 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