summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorMichiel Van Der Kolk <not.valid@email.address>2005-06-05 15:30:27 +0000
committerMichiel Van Der Kolk <not.valid@email.address>2005-06-05 15:30:27 +0000
commit40efb12b8c4c4a698bbff74492d4c14fd6839a88 (patch)
tree388ef45c24897cae1cb65c69ccb84b253dc2dd8d /apps/plugins
parent08bccbfda70786bbb0385aff7cf8da6e1f390761 (diff)
downloadrockbox-40efb12b8c4c4a698bbff74492d4c14fd6839a88.zip
rockbox-40efb12b8c4c4a698bbff74492d4c14fd6839a88.tar.gz
rockbox-40efb12b8c4c4a698bbff74492d4c14fd6839a88.tar.bz2
rockbox-40efb12b8c4c4a698bbff74492d4c14fd6839a88.tar.xz
iriver snake support..
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6572 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/snake.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c
index 21761f1..5d1e020 100644
--- a/apps/plugins/snake.c
+++ b/apps/plugins/snake.c
@@ -50,7 +50,10 @@ dir is the current direction of the snake - 0=up, 1=right, 2=down, 3=left;
#error "lacks keymapping"
#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 short dir,frames,apple,level=1,dead=0;
static struct plugin_api* rb;
@@ -90,7 +93,7 @@ void colission (short x, short y)
die();
break;
}
- if (x==28 || x<0 || y==16 || y<0)
+ if (x==BOARD_WIDTH || x<0 || y==BOARD_HEIGHT || y<0)
die();
}
@@ -120,8 +123,8 @@ void move_head (short x, short y)
void frame (void)
{
short x,y,head=0;
- for (x=0; x<28; x++) {
- for (y=0; y<16; y++) {
+ for (x=0; x<BOARD_WIDTH; x++) {
+ for (y=0; y<BOARD_HEIGHT; y++) {
switch (board[x][y]) {
case 1:
if (!head) {
@@ -154,8 +157,8 @@ void redraw (void)
{
short x,y;
rb->lcd_clear_display();
- for (x=0; x<28; x++) {
- for (y=0; y<16; y++) {
+ for (x=0; x<BOARD_WIDTH; x++) {
+ for (y=0; y<BOARD_HEIGHT; y++) {
switch (board[x][y]) {
case -1:
rb->lcd_fillrect((x*4)+1,y*4,2,4);
@@ -216,8 +219,8 @@ void game (void) {
frames=0;
if (!apple) {
do {
- x=rb->rand() % 28;
- y=rb->rand() % 16;
+ x=rb->rand() % BOARD_WIDTH;
+ y=rb->rand() % BOARD_HEIGHT;
} while (board[x][y]);
apple=1;
board[x][y]=-1;
@@ -263,8 +266,8 @@ void game_init(void) {
short x,y;
char plevel[10],phscore[20];
- for (x=0; x<28; x++) {
- for (y=0; y<16; y++) {
+ for (x=0; x<BOARD_WIDTH; x++) {
+ for (y=0; y<BOARD_HEIGHT; y++) {
board[x][y]=0;
}
}