1
0
Fork 0
forked from len0rd/rockbox

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 int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength;
static unsigned int score,hiscore=0,level=1; 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) void die (void)
{ {
@ -224,7 +225,7 @@ void colission (short x, short y)
case -1: case -1:
snakelength+=2; snakelength+=2;
score+=level; score+=level;
apple=0; apple=false;
break; break;
default: default:
die(); die();
@ -356,19 +357,15 @@ void game (void) {
frame(); frame();
if (dead) if (dead)
return; return;
frames++; if (!apple) {
if (frames==10) { do {
frames=0; x=rb->rand() % BOARD_WIDTH;
if (!apple) { y=rb->rand() % BOARD_HEIGHT;
do { } while (board[x][y]);
x=rb->rand() % BOARD_WIDTH; apple=true;
y=rb->rand() % BOARD_HEIGHT; board[x][y]=-1;
} while (board[x][y]); rb->lcd_fillrect((x*4)+1,y*4,2,4);
apple=1; rb->lcd_fillrect(x*4,(y*4)+1,4,2);
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); rb->sleep(HZ/level);
@ -423,7 +420,7 @@ void game_init(void) {
} }
} }
dead=0; dead=0;
apple=0; apple=false;
snakelength=4; snakelength=4;
score=0; score=0;
board[11][7]=1; board[11][7]=1;