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.
Diff: main.cpp
- Revision:
- 11:e7c56013acd9
- Parent:
- 10:ee781d18e0f6
diff -r ee781d18e0f6 -r e7c56013acd9 main.cpp
--- a/main.cpp Thu May 28 20:58:49 2020 +0000
+++ b/main.cpp Thu May 28 21:59:12 2020 +0000
@@ -38,6 +38,7 @@
void init();
void update_game_state();
void gameover_true();
+void _time();
//Serial pc(USBTX, USBRX);
@@ -58,24 +59,69 @@
snake.get_direction(pad);
snake.render_clear_tail(lcd);
engine.get_LEDs(pad, snake); // =needs to be cleared before _x3, _y3 is updated
- snake.move_snake();
+ // snake.move_snake();
snake.check_collisions();
snake.apple_collected(lcd, pad, timer);
- snake.get_time(timer);
+ _time();
engine.get_LEDs(pad, snake);
-
-
+
gameover_true();
snake.render(lcd);
- snake.print_display_time(lcd);
+ // snake.print_display_time(lcd);
wait(1.0f/fps);
+ }
+}
+
+void _time()
+{
+ int _display_time;
+int Reset_value;
+ int _realtime = timer.read();
+ _display_time = Reset_value - _realtime;
+
+ if(_realtime == Reset_value) {
+ lcd.printString("timer workd", 5,5);
}
+ /*/ 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;
+
+
+
+ // _realtime;
+
+ char buffer1[14];
+ sprintf(buffer1,"%2d",_realtime);
+ lcd.printString(buffer1,WIDTH/2,30); // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
+ char buffer2[14];
+
+}
+
//added old score - changed postion of timer and code
@@ -91,8 +137,6 @@
void welcome()
{
-
-
lcd.printString(" SNAKE ",0,1);
lcd.printString(" Press Start ",0,4);