mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-27 15:56:18 -04:00
*patch by Mikael Magnusson, do not reinitialize the board when hit by a qix. *some code cleanup by me
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9076 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4092029b3b
commit
cee9568611
1 changed files with 45 additions and 42 deletions
|
|
@ -165,11 +165,7 @@ static struct pos
|
||||||
} stack[STACK_SIZE];
|
} stack[STACK_SIZE];
|
||||||
static int stackPointer;
|
static int stackPointer;
|
||||||
|
|
||||||
/* div function (divide two numbers and truncate the answer) */
|
#define div(a,b) (((a)/(b)))
|
||||||
static inline int div (int a, int b)
|
|
||||||
{
|
|
||||||
return (a/b);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool pop (struct pos *p)
|
static bool pop (struct pos *p)
|
||||||
{
|
{
|
||||||
|
|
@ -353,7 +349,7 @@ static inline int infested_area (int i, int j)
|
||||||
init_testboard ();
|
init_testboard ();
|
||||||
if (!push (&p))
|
if (!push (&p))
|
||||||
return -1;
|
return -1;
|
||||||
while ((pop (&p)) && (!hit)) {
|
while (pop (&p)) {
|
||||||
hit = (boardcopy[p.y][p.x] == QIX);
|
hit = (boardcopy[p.y][p.x] == QIX);
|
||||||
testboard[p.y][p.x] = CHECKED;
|
testboard[p.y][p.x] = CHECKED;
|
||||||
if (hit)
|
if (hit)
|
||||||
|
|
@ -436,17 +432,21 @@ static inline int fill_area (int i, int j)
|
||||||
|
|
||||||
|
|
||||||
/* take care of stuff after xonix has landed on a filled spot */
|
/* take care of stuff after xonix has landed on a filled spot */
|
||||||
static void complete_trail (void)
|
static void complete_trail (int fill)
|
||||||
{
|
{
|
||||||
int i, j, ret;
|
int i, j, ret;
|
||||||
for (j = 0; j < BOARD_H; j++)
|
for (j = 0; j < BOARD_H; j++)
|
||||||
for (i = 0; i < BOARD_W; i++)
|
for (i = 0; i < BOARD_W; i++) {
|
||||||
if (board[j][i] == TRAIL)
|
if (board[j][i] == TRAIL) {
|
||||||
|
if (fill)
|
||||||
board[j][i] = FILLED;
|
board[j][i] = FILLED;
|
||||||
|
else
|
||||||
for (j = 0; j < BOARD_H; j++)
|
board[j][i] = EMPTIED;
|
||||||
for (i = 0; i < BOARD_W; i++)
|
}
|
||||||
boardcopy[j][i] = board[j][i];
|
boardcopy[j][i] = board[j][i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fill) {
|
||||||
for (i = 0; i < player.level + STARTING_QIXES; i++) /* add qixes to board */
|
for (i = 0; i < player.level + STARTING_QIXES; i++) /* add qixes to board */
|
||||||
boardcopy[div (qixes[i].y - BOARD_Y, CUBE_SIZE)][div
|
boardcopy[div (qixes[i].y - BOARD_Y, CUBE_SIZE)][div
|
||||||
(qixes[i].x - BOARD_X,
|
(qixes[i].x - BOARD_X,
|
||||||
|
|
@ -465,6 +465,7 @@ static void complete_trail (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* returns the color the real pixel(x,y) on the lcd is pointing at */
|
/* returns the color the real pixel(x,y) on the lcd is pointing at */
|
||||||
static unsigned short getpixel (int x, int y)
|
static unsigned short getpixel (int x, int y)
|
||||||
|
|
@ -525,6 +526,22 @@ static bool line_check (int newx, int newy, int side)
|
||||||
return filled;
|
return filled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void die (void)
|
||||||
|
{
|
||||||
|
player.lives--;
|
||||||
|
if (player.lives == 0)
|
||||||
|
player.gameover = true;
|
||||||
|
else {
|
||||||
|
refresh_board ();
|
||||||
|
rb->splash (HZ, true, "Crash!");
|
||||||
|
complete_trail (false);
|
||||||
|
player.move = MOVE_NO;
|
||||||
|
player.drawing = false;
|
||||||
|
player.i = BOARD_W / 2;
|
||||||
|
player.j = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void move_qix (struct qix *q)
|
static void move_qix (struct qix *q)
|
||||||
{
|
{
|
||||||
int newx, newy, dir;
|
int newx, newy, dir;
|
||||||
|
|
@ -585,18 +602,8 @@ static void move_qix (struct qix *q)
|
||||||
}
|
}
|
||||||
q->x = newx;
|
q->x = newx;
|
||||||
q->y = newy;
|
q->y = newy;
|
||||||
refresh_board ();
|
|
||||||
newx = get_newx (newx, q->velocity, q->angle);
|
|
||||||
newy = get_newy (newy, q->velocity, q->angle);
|
|
||||||
q->x = newx;
|
|
||||||
q->y = newy;
|
|
||||||
} else if (nexthit == TRAIL) {
|
} else if (nexthit == TRAIL) {
|
||||||
player.lives--;
|
die();
|
||||||
if (player.lives == 0)
|
|
||||||
player.gameover = true;
|
|
||||||
refresh_board ();
|
|
||||||
rb->splash (HZ, true, "Crash!");
|
|
||||||
init_board ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -637,7 +644,7 @@ static inline void move_board (void)
|
||||||
else if ((player.drawing) && (board[newj][newi] == FILLED)) { /* finish drawing */
|
else if ((player.drawing) && (board[newj][newi] == FILLED)) { /* finish drawing */
|
||||||
player.move = MOVE_NO; /* stop moving */
|
player.move = MOVE_NO; /* stop moving */
|
||||||
player.drawing = false;
|
player.drawing = false;
|
||||||
complete_trail ();
|
complete_trail (true);
|
||||||
} else if ((board[player.j][player.i] == FILLED)
|
} else if ((board[player.j][player.i] == FILLED)
|
||||||
&& (board[newj][newi] == EMPTIED)) {
|
&& (board[newj][newi] == EMPTIED)) {
|
||||||
/* start drawing */
|
/* start drawing */
|
||||||
|
|
@ -656,8 +663,6 @@ static inline void move_board (void)
|
||||||
init_board ();
|
init_board ();
|
||||||
refresh_board ();
|
refresh_board ();
|
||||||
rb->splash (HZ * 2, true, "READY?");
|
rb->splash (HZ * 2, true, "READY?");
|
||||||
rb->lcd_update ();
|
|
||||||
refresh_board ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -719,8 +724,6 @@ static void init_game (void)
|
||||||
init_board ();
|
init_board ();
|
||||||
refresh_board ();
|
refresh_board ();
|
||||||
rb->splash (HZ * 2, true, "READY?");
|
rb->splash (HZ * 2, true, "READY?");
|
||||||
rb->lcd_update ();
|
|
||||||
refresh_board ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* general keypad handler loop */
|
/* general keypad handler loop */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue