From d8662489dc19592abccca44c0e1254584c6a0d29 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Thu, 5 Feb 2009 14:22:04 +0000 Subject: Fix FS#2533, apple appearing late in the snake plugin git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19926 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/snake.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c index ef179c6654..a80aaa0cff 100644 --- a/apps/plugins/snake.c +++ b/apps/plugins/snake.c @@ -194,7 +194,8 @@ PLUGIN_HEADER static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength; static unsigned int score,hiscore=0,level=1; -static short dir,frames,apple,dead=0; +static int dir,dead=0; +static bool apple; void die (void) { @@ -224,7 +225,7 @@ void colission (short x, short y) case -1: snakelength+=2; score+=level; - apple=0; + apple=false; break; default: die(); @@ -356,19 +357,15 @@ void game (void) { frame(); if (dead) return; - frames++; - if (frames==10) { - frames=0; - if (!apple) { - do { - x=rb->rand() % BOARD_WIDTH; - y=rb->rand() % BOARD_HEIGHT; - } while (board[x][y]); - apple=1; - board[x][y]=-1; - rb->lcd_fillrect((x*4)+1,y*4,2,4); - rb->lcd_fillrect(x*4,(y*4)+1,4,2); - } + if (!apple) { + do { + x=rb->rand() % BOARD_WIDTH; + y=rb->rand() % BOARD_HEIGHT; + } while (board[x][y]); + apple=true; + board[x][y]=-1; + rb->lcd_fillrect((x*4)+1,y*4,2,4); + rb->lcd_fillrect(x*4,(y*4)+1,4,2); } rb->sleep(HZ/level); @@ -423,7 +420,7 @@ void game_init(void) { } } dead=0; - apple=0; + apple=false; snakelength=4; score=0; board[11][7]=1; -- cgit v1.2.3