Mochu Yao explorer game
Dependencies: mbed
Diff: Surface/surface.cpp
- Revision:
- 33:ea83f08fa466
- Parent:
- 32:47d98959b4ef
diff -r 47d98959b4ef -r ea83f08fa466 Surface/surface.cpp --- a/Surface/surface.cpp Wed Apr 29 12:19:12 2020 +0000 +++ b/Surface/surface.cpp Wed Apr 29 13:28:41 2020 +0000 @@ -40,47 +40,43 @@ //3 makesure there are two surface for player to stay void Surface::line_1() { if(_line_1.left > 0) { - _line_1.left-- ; - wait(1);} + _line_1.left-- ;} //the left side will keep moving until it disappear on the screen which also means equal to zero if (_line_1.left + _line_1.length < 80) { - _line_1.right-- ; wait(1);} + _line_1.right-- ;} //this line is mainly for regeneration of the line because I want the line to first disapper and then appear on the another edge - if (_line_1.right <= 0) { - _line_1.right--; wait(1) + if (_line_1.left <= 0) { _line_1.left = 0; } //if the left edge of the line is zero it will keep zero until the right edge equals to zero if (_line_1.right <= 0) { _line_1.left = 80; _line_1.right = 80;} - _line_1.length = (rand() %10) + 5; } + _line_1.length = (rand() %10) + 10; } void Surface::line_2() { if(_line_2.left > 0) { - _line_2.left-- ; wait(1);} + _line_2.left-- ;} //the left side will keep moving until it disappear on the screen which also means equal to zero if (_line_2.left + _line_1.length < 80) { - _line_2.right-- ;wait(1);} + _line_2.right-- ;} //this line is mainly for regeneration of the line because I want the line to first disapper and then appear on the another edge - if (_line_2.right <= 0) { - _line_2.right--; - _line_2.left = 0;wait(1);} + if (_line_2.left <= 0) { + _line_2.left = 0;} //if the left edge of the line is zero it will keep zero until the right edge equals to zero if (_line_2.right <= 0) { _line_2.left = 80; _line_2.right = 80;} - _line_2.length = (rand() %15) + 10; } + _line_2.length = (rand() %10) + 10; } void Surface::line_3() { if(_line_3.left > 0) { - _line_3.left-- ;wait(1);} + _line_3.left-- ;} //the left side will keep moving until it disappear on the screen which also means equal to zero if (_line_3.left + _line_1.length < 80) { - _line_3.right-- ;wait(1);} + _line_3.right-- ;} //this line is mainly for regeneration of the line because I want the line to first disapper and then appear on the another edge - if (_line_3.right <= 0) { - _line_3.right--; - _line_3.left = 0; wait(1);} + if (_line_3.left <= 0) { + _line_3.left = 0;} //if the left edge of the line is zero it will keep zero until the right edge equals to zero if (_line_3.right <= 0) { _line_3.left = 80; @@ -89,14 +85,13 @@ void Surface::line_4() { if(_line_4.left > 0) { - _line_4.left-- ;wait(1);} + _line_4.left-- ;} //the left side will keep moving until it disappear on the screen which also means equal to zero if (_line_4.left + _line_1.length < 80) { - _line_4.right-- ;wait(1);} + _line_4.right-- ;} //this line is mainly for regeneration of the line because I want the line to first disapper and then appear on the another edge - if (_line_4.right <= 0) { - _line_4.right--; - _line_4.left = 0;wait(1);} + if (_line_4.left <= 0) { + _line_4.left = 0;} //if the left edge of the line is zero it will keep zero until the right edge equals to zero if (_line_4.right <= 0) { _line_4.left = 80; @@ -108,27 +103,25 @@ _line_5.left-- ;} //the left side will keep moving until it disappear on the screen which also means equal to zero if (_line_5.left + _line_1.length < 80) { - _line_5.right-- ;wait(1);} + _line_5.right-- ;} //this line is mainly for regeneration of the line because I want the line to first disapper and then appear on the another edge - if (_line_5.right <= 0) { - _line_5.right--; - _line_5.left = 0;wait(1);} + if (_line_5.left <= 0) { + _line_5.left = 0;} //if the left edge of the line is zero it will keep zero until the right edge equals to zero if (_line_5.right <= 0) { _line_5.left = 80; _line_5.right = 80;} - _line_5.length = (rand() %10) + 5; } + _line_5.length = (rand() %10) + 10; } void Surface::line_6() { if(_line_6.left > 0) { - _line_6.left-- ;wait(1);} + _line_6.left-- ;} //the left side will keep moving until it disappear on the screen which also means equal to zero if (_line_6.left + _line_1.length < 80) { - _line_6.right-- ;wait(1);} + _line_6.right-- ;} //this line is mainly for regeneration of the line because I want the line to first disapper and then appear on the another edge - if (_line_6.right <= 0) { - _line_6.right--; - _line_6.left = 0;wait(1);} + if (_line_6.left <= 0) { + _line_6.left = 0;} //if the left edge of the line is zero it will keep zero until the right edge equals to zero if (_line_6.right <= 0) { _line_6.left = 80;