--- brickmania1.c 2010-02-21 14:27:37.482934108 +0200 +++ brickmania2.c 2010-02-21 14:27:50.222934571 +0200 @@ -379,9 +379,6 @@ #define NUM_BRICKS_ROWS 8 #define NUM_BRICKS_COLS 10 -#define BRICK_IDX(row, col) (NUM_BRICKS_COLS * (row) + (col)) -#define BRICK_ROW(bnum) (bnum / NUM_BRICKS_COLS) -#define BRICK_COL(bnum) (bnum % NUM_BRICKS_COLS) /* change the first number in [ ] to however many levels there are */ static unsigned char levels[NUM_LEVELS][NUM_BRICKS_ROWS][NUM_BRICKS_COLS] = @@ -834,7 +831,7 @@ int hits; /* How many hits can this brick take? */ int hiteffect; } cube; -cube brick[NUM_BRICKS_ROWS * NUM_BRICKS_COLS]; +cube brick[NUM_BRICKS_ROWS][NUM_BRICKS_COLS]; typedef struct balls { @@ -1020,13 +1017,12 @@ for(i=0;i=10? + brick[i][j].hits=levels[level][i][j]>=10? levels[level][i][j]/16-1:0; - brick[bnum].hiteffect=0; - brick[bnum].used=!(levels[level][i][j]==0); - brick[bnum].color=(levels[level][i][j]>=10? + brick[i][j].hiteffect=0; + brick[i][j].used=!(levels[level][i][j]==0); + brick[i][j].color=(levels[level][i][j]>=10? levels[level][i][j]%16: levels[level][i][j])-1; if (levels[level][i][j]!=0) @@ -1314,27 +1310,27 @@ #endif } -void brick_hit(int brick_number) +void brick_hit(int i, int j) { - if(!brick[brick_number].used) + if(!brick[i][j].used) return; /* if this is a crackable brick hits starts as * greater than 0. */ - if (brick[brick_number].hits > 0) { - brick[brick_number].hits--; - brick[brick_number].hiteffect++; + if (brick[i][j].hits > 0) { + brick[i][j].hits--; + brick[i][j].hiteffect++; score+=SCORE_BALL_HIT_BRICK; } else { - brick[brick_number].used=false; + brick[i][j].used=false; int ran = rb->rand()%25; /* +8 make the game with less powerups */ if (ran> 1); power[used_powers].type = ran; used_powers++; @@ -1456,19 +1452,18 @@ j = (fire[k].x_pos - LEFTMARGIN) / BRICK_WIDTH; for (i=NUM_BRICKS_ROWS-1;i>=0;i--) { - int bnum = BRICK_IDX(i, j); - if (brick[bnum].used) + if (brick[i][j].used) { score += SCORE_FIRE_HIT_BRICK; - brick_hit(bnum); + brick_hit(i,j); used_fires--; fire[k].top = fire[used_fires].top; fire[k].x_pos = fire[used_fires].x_pos; k--; break; } - if (TOPMARGIN+BRICK_HEIGHT*BRICK_ROW(bnum)<=fire[k].top) + if (TOPMARGIN+BRICK_HEIGHT*i<=fire[k].top) break; } } @@ -1617,10 +1612,9 @@ for (j=0; jlcd_bitmap_part(brickmania_bricks,0, - INT3(BRICK_HEIGHT)*brick[bnum].color, + INT3(BRICK_HEIGHT)*brick[i][j].color, STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_bricks, BMPHEIGHT_brickmania_bricks), @@ -1667,9 +1661,9 @@ INT3(BRICK_WIDTH), INT3(BRICK_HEIGHT) ); #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */ - if (brick[bnum].hiteffect > 0) + if (brick[i][j].hiteffect > 0) rb->lcd_bitmap_transparent_part(brickmania_break,0, - INT3(BRICK_HEIGHT)*brick[bnum].hiteffect, + INT3(BRICK_HEIGHT)*brick[i][j].hiteffect, STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_break, BMPHEIGHT_brickmania_break), @@ -1706,7 +1700,7 @@ ball[k].speedy = -ball[k].speedy; ball[k].tempy = pt_hit.y; ball[k].tempx = pt_hit.x; - brick_hit(bnum); + brick_hit(i,j); } /* Check the top, if the ball is moving up dont * count it as a hit. @@ -1717,7 +1711,7 @@ ball[k].speedy = -ball[k].speedy; ball[k].tempy = pt_hit.y; ball[k].tempx = pt_hit.x; - brick_hit(bnum); + brick_hit(i,j); } /* Check the left side of the brick */ else if( @@ -1726,7 +1720,7 @@ ball[k].speedx = -ball[k].speedx; ball[k].tempy = pt_hit.y; ball[k].tempx = pt_hit.x; - brick_hit(bnum); + brick_hit(i,j); } /* Check the right side of the brick */ else if( @@ -1735,7 +1729,7 @@ ball[k].speedx = -ball[k].speedx; ball[k].tempy = pt_hit.y; ball[k].tempx = pt_hit.x; - brick_hit(bnum); + brick_hit(i,j); } } /* for k */ } /* if(used) */