Index: apps/plugins/brickmania.c =================================================================== --- apps/plugins/brickmania.c (revision 24755) +++ apps/plugins/brickmania.c (working copy) @@ -778,6 +778,7 @@ }; #define MAX_BALLS 10 +#define MAX_FIRES 30 enum difficulty_options { EASY, NORMAL @@ -798,6 +799,7 @@ int level=0; int brick_on_board=0; int used_balls=1; +int used_fires=0; int difficulty = NORMAL; int pad_width; int num_count; @@ -838,7 +840,7 @@ int top; /* This stores the fire y position, it is a fixed point num */ int x_pos; /* This stores the fire x position, it is a whole number */ } sfire; -sfire fire[30]; +sfire fire[MAX_FIRES]; #define CONFIG_FILE_NAME "brickmania.cfg" #define SAVE_FILE PLUGIN_GAMES_DIR "/brickmania.save" @@ -975,6 +977,7 @@ } used_balls = 1; + used_fires = 0; game_state = ST_READY; pad_type = PLAIN; pad_width = PAD_WIDTH; @@ -990,11 +993,6 @@ } } - for(i=0;i<30;i++) { - /* No fire should be active */ - fire[i].top=-1; - } - for(i=0;i<=7;i++) { for(j=0;j<=9;j++) { int bnum = i*10+j; @@ -1039,6 +1037,7 @@ if(rb->read(fd, &level, sizeof(level)) <= 0) break; if(rb->read(fd, &brick_on_board, sizeof(brick_on_board)) <= 0) break; if(rb->read(fd, &used_balls, sizeof(used_balls)) <= 0) break; + if(rb->read(fd, &used_fires, sizeof(used_fires)) <= 0) break; if(rb->read(fd, &pad_width, sizeof(pad_width)) <= 0) break; if(rb->read(fd, &num_count, sizeof(num_count)) <= 0) break; if(rb->read(fd, &brick, sizeof(brick)) <= 0) break; @@ -1071,6 +1070,7 @@ rb->write(fd, &level, sizeof(level)); rb->write(fd, &brick_on_board, sizeof(brick_on_board)); rb->write(fd, &used_balls, sizeof(used_balls)); + rb->write(fd, &used_fires, sizeof(used_fires)); rb->write(fd, &pad_width, sizeof(pad_width)); rb->write(fd, &num_count, sizeof(num_count)); rb->write(fd, &brick, sizeof(brick)); @@ -1280,17 +1280,6 @@ #endif } -/* Find an unused fire position */ -static int brickmania_find_empty_fire(void) -{ - int t; - for(t=0;t<30;t++) - if (fire[t].top < 0) - return t; - - return 0; -} - void brick_hit(int brick_number) { if(!brick[brick_number].used) @@ -1409,19 +1398,21 @@ if (brick_on_board==0) brick_on_board--; - /* if the pad is fire */ - for(i=0; i<30; i++) - { - /* If the projectile is active (>0 inactive) */ - if (fire[i].top >= 0) - { - if (game_state!=ST_PAUSE) - fire[i].top -= SPEED_FIRE; - /* Draw the projectile */ - rb->lcd_vline( INT3(fire[i].x_pos), INT3(fire[i].top), - INT3(fire[i].top + FIRE_LENGTH)); - } - } + /* move the fires */ + if (game_state!=ST_PAUSE) + for(i=0; ilcd_vline( INT3(fire[i].x_pos), INT3(fire[i].top), + INT3(fire[i].top + FIRE_LENGTH)); /* Setup the pad line-later used in intersection test */ pad_line.p1.x = pad_pos_x; @@ -1612,26 +1603,26 @@ rght_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT; /* Check if any of the active fires hit a brick */ - for (k=0;k<30;k++) + 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; + /* Use misc_line to check if fire hit brick */ + misc_line.p1.x = fire[k].x_pos; + misc_line.p1.y = fire[k].top; - /* If the fire hit the brick take care of it */ - if (check_lines(&misc_line, &bot_brick, - &pt_hit)) - { - score+=13; - /* De-activate the fire */ - fire[k].top=-1; - brick_hit(bnum); - } + 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+=13; + /* De-activate the fire */ + used_fires--; + fire[k].top=fire[used_fires].top; + fire[k].x_pos=fire[used_fires].x_pos; + k--; + brick_hit(bnum); } } @@ -2136,13 +2127,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