This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
roox gerrit-no-reply at lists.osmocom.orgroox has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/19488 ) Change subject: If the snake eats itself the score will be decremented. ...................................................................... If the snake eats itself the score will be decremented. Change-Id: I91eaf50c11321ada9ffdc2f692847a13ff3d3e6a --- M src/target/firmware/apps/snake_game/main.c 1 file changed, 5 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/88/19488/1 diff --git a/src/target/firmware/apps/snake_game/main.c b/src/target/firmware/apps/snake_game/main.c index c263df4..98a5b34 100644 --- a/src/target/firmware/apps/snake_game/main.c +++ b/src/target/firmware/apps/snake_game/main.c @@ -80,7 +80,7 @@ } pos; uint8_t field[WIDTH][HEIGHT]; -uint16_t score = 0, lenght = 0; +int16_t score = 0, lenght = 0; enum errors { ALLRIGHT, SNAKE_COL, } err; void printField(); @@ -177,7 +177,7 @@ switch (field[x][y]) { case FOOD: score++; setFood(); item = HEAD_FOOD; break; case BLANK: break; - default: err = SNAKE_COL; + default: err = SNAKE_COL;score--; } } field[x][y] = item; @@ -213,7 +213,7 @@ switch (err) { case SNAKE_COL: fb_putstr("The snake ate itself!!!", framebuffer->width); err = ALLRIGHT; break; - default: sprintf(text, "Score: %u", score); + default: sprintf(text, "Score: %d", score); fb_putstr(text, framebuffer->width); framebuffer->cursor_x = 45; fb_putstr("OsmocomBB", framebuffer->width); @@ -350,6 +350,7 @@ fb_clear(); bl_level(255); + osmo_timers_update(); intro(); delay_ms(5000); @@ -359,24 +360,13 @@ fb_setfg(FB_COLOR_BLACK); fb_setbg(FB_COLOR_WHITE); fb_setfont(FB_FONT_HELVR08); - int y = 0, i; - /* for (i = 1; i <= 7; i++) { */ - /* printf("%d\n", i); */ - /* print_display("OOOOOOOOOOOOOOOO", &y, cursor - 1); */ - /* } */ - /* print_snake_str("U",0, 0); */ - /* print_snake_str("U",0, 2); */ - /* print_snake_str("U",2, 0); */ - print_snake_str("U",2, 0); - print_snake_str("U",2, 5); - print_snake_str("U",6, 0); fb_flush(); pos.x = framebuffer->width/(6 * 2); pos.y = framebuffer->height/(8 * 2); setItem(pos.x, pos.y, HEAD); - osmo_timers_update(); + while (battery_info.bat_volt_mV == 0) osmo_timers_update(); srand(battery_info.bat_volt_mV); if (DEBUG > 0) printf("Initialize random number generator with %d\n", battery_info.bat_volt_mV); setFood(); -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/19488 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I91eaf50c11321ada9ffdc2f692847a13ff3d3e6a Gerrit-Change-Number: 19488 Gerrit-PatchSet: 1 Gerrit-Owner: roox <mardnh at gmx.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200801/e74b2857/attachment.htm>