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
This commit is contained in:
Thomas Martitz 2009-02-05 14:22:04 +00:00
parent 6db3aace59
commit d8662489dc

View file

@ -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;