summaryrefslogtreecommitdiffstats
path: root/apps/plugins/snake.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-02-05 14:22:04 +0000
committerThomas Martitz <kugel@rockbox.org>2009-02-05 14:22:04 +0000
commitd8662489dc19592abccca44c0e1254584c6a0d29 (patch)
treeea116005b859397acca88f8e4c8c8889c954c5d9 /apps/plugins/snake.c
parent6db3aace5931e722b7a68b2ec1646fa49c077688 (diff)
downloadrockbox-d8662489dc19592abccca44c0e1254584c6a0d29.tar.gz
rockbox-d8662489dc19592abccca44c0e1254584c6a0d29.tar.bz2
rockbox-d8662489dc19592abccca44c0e1254584c6a0d29.zip
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
Diffstat (limited to 'apps/plugins/snake.c')
-rw-r--r--apps/plugins/snake.c29
1 files 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;