ELEC2645 (2019/20)
/
ELEC2645_Project_el17oc1
Owen Cavender 201159294
Diff: snake.cpp
- Revision:
- 11:e7c56013acd9
- Parent:
- 10:ee781d18e0f6
--- a/snake.cpp Thu May 28 20:58:49 2020 +0000 +++ b/snake.cpp Thu May 28 21:59:12 2020 +0000 @@ -95,8 +95,7 @@ lcd.setPixel(_x1, _y1,1); lcd.setPixel(_x2, _y2,1); lcd.setPixel(_x3, _y3,1); - - + lcd.refresh(); } @@ -132,10 +131,8 @@ else { _direction = direction; } - } + - - void Snake::move_snake() { if (_direction == up) { // /-/ _x3 = _x2; _y3 = _y2; @@ -195,7 +192,8 @@ void Snake::render_clear_tail(N5110 &lcd) { - _oldscore = _score; + int x = _score; + _oldscore = x; lcd.clearPixel(_x3, _y3); } @@ -232,36 +230,4 @@ } } -void Snake::get_time(Timer &timer) -{ - _realtime = timer.read(); - _display_time = (Reset_value - _realtime); - - if(_realtime == Reset_value) { - _gameover = true; - } - - if (0 <= _score && _score < 10) { - Reset_value = 12; - } - if (10 <= _score && _score < 15) { - Reset_value = 10; - } - if (15 <= _score && _score < 20) { - Reset_value = 8; - } else { - Reset_value = 6; - } -} - -void Snake::print_display_time(N5110 &lcd) -{ - int countdown = _realtime; - - char buffer1[14]; - sprintf(buffer1,"%2d",countdown); - lcd.printString(buffer1,WIDTH/2,30); // font is 8 wide, so leave 4 pixel gape from middle assuming two digits - char buffer2[14]; - -} \ No newline at end of file