Index: apps/plugins/brickmania.c =================================================================== --- apps/plugins/brickmania.c (revision 24771) +++ apps/plugins/brickmania.c (working copy) @@ -815,6 +815,7 @@ int level=0; int brick_on_board=0; int used_balls=1; +int used_fires=0; int difficulty = NORMAL; int pad_width; int flip_sides_delay; @@ -992,6 +993,7 @@ } used_balls = 1; + used_fires = 0; game_state = ST_READY; pad_type = PLAIN; pad_width = PAD_WIDTH; @@ -1007,11 +1009,6 @@ } } - for(i=0;iread(fd, &level, sizeof(level)) <= 0) || (rb->read(fd, &brick_on_board, sizeof(brick_on_board)) <= 0) || (rb->read(fd, &used_balls, sizeof(used_balls)) <= 0) || + (rb->read(fd, &used_fires, sizeof(used_fires)) <= 0) || (rb->read(fd, &pad_width, sizeof(pad_width)) <= 0) || (rb->read(fd, &flip_sides_delay, sizeof(flip_sides_delay)) <= 0) || (rb->read(fd, &brick, sizeof(brick)) <= 0) || @@ -1091,6 +1089,7 @@ (rb->write(fd, &level, sizeof(level)) <= 0) || (rb->write(fd, &brick_on_board, sizeof(brick_on_board)) <= 0) || (rb->write(fd, &used_balls, sizeof(used_balls)) <= 0) || + (rb->write(fd, &used_fires, sizeof(used_fires)) <= 0) || (rb->write(fd, &pad_width, sizeof(pad_width)) <= 0) || (rb->write(fd, &flip_sides_delay, sizeof(flip_sides_delay)) <= 0) || (rb->write(fd, &brick, sizeof(brick)) <= 0) || @@ -1307,17 +1306,6 @@ #endif } -/* Find an unused fire position */ -static int brickmania_find_empty_fire(void) -{ - int t; - for(t=0;t0 inactive) */ - if (fire[i].top >= 0) + /* move the fires */ + if (game_state!=ST_PAUSE) + for(k=0; klcd_vline( INT3(fire[i].x_pos), INT3(fire[i].top), - INT3(fire[i].top + FIRE_LENGTH)); + fire[k].top -= SPEED_FIRE; + if (fire[k].top <0) + { + used_fires--; + fire[k].top = fire[used_fires].top; + fire[k].x_pos = fire[used_fires].x_pos; + k--; + } + else if (fire[k].x_pos >= LEFTMARGIN && fire[k].x_pos < LEFTMARGIN + NUM_BRICKS_COLS*BRICK_WIDTH) + { + j = (fire[k].x_pos - LEFTMARGIN) / BRICK_WIDTH; + for (i = NUM_BRICKS_ROWS-1; !brick[NUM_BRICKS_COLS*i+j].used && brick[NUM_BRICKS_COLS*i+j].powertop>fire[k].top && i>0; i--); + if (brick[NUM_BRICKS_COLS*i+j].used) + { + score += SCORE_FIRE_HIT_BRICK; + brick_hit(NUM_BRICKS_COLS*i+j); + used_fires--; + fire[k].top = fire[used_fires].top; + fire[k].x_pos = fire[used_fires].x_pos; + k--; + } + } } - } + /* draw the fires */ + for(k=0; klcd_vline( INT3(fire[k].x_pos), INT3(fire[k].top), + INT3(fire[k].top + FIRE_LENGTH)); + /* Setup the pad line-later used in intersection test */ pad_line.p1.x = pad_pos_x; pad_line.p1.y = PAD_POS_Y; @@ -1638,30 +1645,6 @@ rght_brick.p2.x = brickx + BRICK_WIDTH; rght_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT; - /* Check if any of the active fires hit a brick */ - for (k=0;k 0) - { - /* Use misc_line to check if fire hit brick */ - misc_line.p1.x = fire[k].x_pos; - misc_line.p1.y = fire[k].top; - - misc_line.p2.x = fire[k].x_pos; - misc_line.p2.y = fire[k].top + SPEED_FIRE; - - /* If the fire hit the brick take care of it */ - if (check_lines(&misc_line, &bot_brick, - &pt_hit)) - { - score+=SCORE_FIRE_HIT_BRICK; - /* De-activate the fire */ - fire[k].top=-1; - brick_hit(bnum); - } - } - } - /* Draw the brick */ rb->lcd_bitmap_part(brickmania_bricks,0, INT3(BRICK_HEIGHT)*brick[bnum].color, @@ -2163,13 +2146,19 @@ } else if (pad_type == SHOOTER) { - k=brickmania_find_empty_fire(); - fire[k].top=PAD_POS_Y - FIRE_LENGTH; - fire[k].x_pos = pad_pos_x + 1; /* Add 1 for edge */ + if (used_fires < MAX_FIRES) + { + fire[used_fires].top=PAD_POS_Y - FIRE_LENGTH; + fire[used_fires].x_pos = pad_pos_x + 1; /* Add 1 for edge */ + used_fires++; + } - k=brickmania_find_empty_fire(); - fire[k].top=PAD_POS_Y - FIRE_LENGTH; - fire[k].x_pos = pad_pos_x + pad_width -1; /* Sub1 edge*/ + if (used_fires < MAX_FIRES) + { + fire[used_fires].top=PAD_POS_Y - FIRE_LENGTH; + fire[used_fires].x_pos = pad_pos_x + pad_width -1; /* Sub1 edge*/ + used_fires++; + } } break; #ifdef RC_QUIT