![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Owen Cavender 201159294
Diff: GameEngine.cpp
- Revision:
- 8:997f90c88246
- Child:
- 9:a69a6a06dddf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GameEngine.cpp Thu May 28 18:50:56 2020 +0000 @@ -0,0 +1,63 @@ +#include "GameEngine.h" + +GameEngine::GameEngine() +{ + +} + +GameEngine::~GameEngine() +{ +} + + + +void GameEngine::print_display_time(N5110 &lcd) +{ + int countdown = _realtime; + + char buffer1[14]; + sprintf(buffer1,"%2d",countdown); + lcd.printString(buffer1,WIDTH/2,1); // font is 8 wide, so leave 4 pixel gape from middle assuming two digits + char buffer2[14]; +} +void GameEngine::print_scores(N5110 &lcd) +{ + int score = snake.get_score(); + + char buffer1[14]; + sprintf(buffer1,"%2d",score); + lcd.printString(buffer1,WIDTH/2 - 3,1); // font is 8 wide, so leave 4 pixel gape from middle assuming two digits + char buffer2[14]; +} + + + + +void GameEngine::get_LEDs(Gamepad &pad) +{ + pad.leds_off(); + Vector2D Snakehead = snake.get_Snakehead(); + int _x0 = Snakehead.x; + int _y0 = Snakehead.y; + + if (_x0 >= 42 && _y0 >= 24) { + // top right led on + + pad.led(4, 1); + } + // topleft led on + if (_x0 <= 42 && _y0 >=24) { + // top right led on + pad.led(1, 1); + } + //bottom left + if (_x0 <=42 && _y0 <= 24) { + + pad.led(3,1); + } + //bottom right + if (_x0 >= 42 && _y0 <= 24) { + // top right led on + pad.led(6, 1); + } +}