1
0
Fork 0
forked from len0rd/rockbox

iriver snake support..

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6572 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michiel Van Der Kolk 2005-06-05 15:30:27 +00:00
parent 08bccbfda7
commit 40efb12b8c

View file

@ -50,7 +50,10 @@ dir is the current direction of the snake - 0=up, 1=right, 2=down, 3=left;
#error "lacks keymapping" #error "lacks keymapping"
#endif #endif
static int board[28][16],snakelength; #define BOARD_WIDTH (LCD_WIDTH/4)
#define BOARD_HEIGHT (LCD_HEIGHT/4)
static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength;
static unsigned int score,hiscore=0; static unsigned int score,hiscore=0;
static short dir,frames,apple,level=1,dead=0; static short dir,frames,apple,level=1,dead=0;
static struct plugin_api* rb; static struct plugin_api* rb;
@ -90,7 +93,7 @@ void colission (short x, short y)
die(); die();
break; break;
} }
if (x==28 || x<0 || y==16 || y<0) if (x==BOARD_WIDTH || x<0 || y==BOARD_HEIGHT || y<0)
die(); die();
} }
@ -120,8 +123,8 @@ void move_head (short x, short y)
void frame (void) void frame (void)
{ {
short x,y,head=0; short x,y,head=0;
for (x=0; x<28; x++) { for (x=0; x<BOARD_WIDTH; x++) {
for (y=0; y<16; y++) { for (y=0; y<BOARD_HEIGHT; y++) {
switch (board[x][y]) { switch (board[x][y]) {
case 1: case 1:
if (!head) { if (!head) {
@ -154,8 +157,8 @@ void redraw (void)
{ {
short x,y; short x,y;
rb->lcd_clear_display(); rb->lcd_clear_display();
for (x=0; x<28; x++) { for (x=0; x<BOARD_WIDTH; x++) {
for (y=0; y<16; y++) { for (y=0; y<BOARD_HEIGHT; y++) {
switch (board[x][y]) { switch (board[x][y]) {
case -1: case -1:
rb->lcd_fillrect((x*4)+1,y*4,2,4); rb->lcd_fillrect((x*4)+1,y*4,2,4);
@ -216,8 +219,8 @@ void game (void) {
frames=0; frames=0;
if (!apple) { if (!apple) {
do { do {
x=rb->rand() % 28; x=rb->rand() % BOARD_WIDTH;
y=rb->rand() % 16; y=rb->rand() % BOARD_HEIGHT;
} while (board[x][y]); } while (board[x][y]);
apple=1; apple=1;
board[x][y]=-1; board[x][y]=-1;
@ -263,8 +266,8 @@ void game_init(void) {
short x,y; short x,y;
char plevel[10],phscore[20]; char plevel[10],phscore[20];
for (x=0; x<28; x++) { for (x=0; x<BOARD_WIDTH; x++) {
for (y=0; y<16; y++) { for (y=0; y<BOARD_HEIGHT; y++) {
board[x][y]=0; board[x][y]=0;
} }
} }