diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-02-05 14:22:04 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-02-05 14:22:04 +0000 |
commit | d8662489dc19592abccca44c0e1254584c6a0d29 (patch) | |
tree | ea116005b859397acca88f8e4c8c8889c954c5d9 | |
parent | 6db3aace5931e722b7a68b2ec1646fa49c077688 (diff) | |
download | rockbox-d8662489dc19592abccca44c0e1254584c6a0d29.tar.gz 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
-rw-r--r-- | apps/plugins/snake.c | 29 |
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 | |||
194 | 194 | ||
195 | static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength; | 195 | static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength; |
196 | static unsigned int score,hiscore=0,level=1; | 196 | static unsigned int score,hiscore=0,level=1; |
197 | static short dir,frames,apple,dead=0; | 197 | static int dir,dead=0; |
198 | static bool apple; | ||
198 | 199 | ||
199 | void die (void) | 200 | void die (void) |
200 | { | 201 | { |
@@ -224,7 +225,7 @@ void colission (short x, short y) | |||
224 | case -1: | 225 | case -1: |
225 | snakelength+=2; | 226 | snakelength+=2; |
226 | score+=level; | 227 | score+=level; |
227 | apple=0; | 228 | apple=false; |
228 | break; | 229 | break; |
229 | default: | 230 | default: |
230 | die(); | 231 | die(); |
@@ -356,19 +357,15 @@ void game (void) { | |||
356 | frame(); | 357 | frame(); |
357 | if (dead) | 358 | if (dead) |
358 | return; | 359 | return; |
359 | frames++; | 360 | if (!apple) { |
360 | if (frames==10) { | 361 | do { |
361 | frames=0; | 362 | x=rb->rand() % BOARD_WIDTH; |
362 | if (!apple) { | 363 | y=rb->rand() % BOARD_HEIGHT; |
363 | do { | 364 | } while (board[x][y]); |
364 | x=rb->rand() % BOARD_WIDTH; | 365 | apple=true; |
365 | y=rb->rand() % BOARD_HEIGHT; | 366 | board[x][y]=-1; |
366 | } while (board[x][y]); | 367 | rb->lcd_fillrect((x*4)+1,y*4,2,4); |
367 | apple=1; | 368 | rb->lcd_fillrect(x*4,(y*4)+1,4,2); |
368 | board[x][y]=-1; | ||
369 | rb->lcd_fillrect((x*4)+1,y*4,2,4); | ||
370 | rb->lcd_fillrect(x*4,(y*4)+1,4,2); | ||
371 | } | ||
372 | } | 369 | } |
373 | 370 | ||
374 | rb->sleep(HZ/level); | 371 | rb->sleep(HZ/level); |
@@ -423,7 +420,7 @@ void game_init(void) { | |||
423 | } | 420 | } |
424 | } | 421 | } |
425 | dead=0; | 422 | dead=0; |
426 | apple=0; | 423 | apple=false; |
427 | snakelength=4; | 424 | snakelength=4; |
428 | score=0; | 425 | score=0; |
429 | board[11][7]=1; | 426 | board[11][7]=1; |