private void draw_brick(int row, int col) { switch (b.get_tile(row, col)) { case ' ': erase_brick(row, col); break; case '#': draw_colour(row, col, "red"); break; case '=': draw_colour(row, col, "yellow"); break; case '-': draw_colour(row, col, "green"); break; case '<': draw_colour(row, col, "darkgrey"); break; case '>': draw_colour(row, col, "lightgrey"); break; } }
private bool hits_brick0(Context context, int nx, int ny, ref int vx, ref int vy, breakout b, gamewindow g) { int r = (ny * breakout.max_row) / breakout_definitions.y_res; int c = (nx * breakout.max_col) / breakout_definitions.x_res; if ((r < 0) || (c < 0) || (r >= breakout.max_row) || (c >= breakout.max_col)) { return(false); } if (b.get_tile(r, c) == ' ') { return(false); // no brick present } int bx0 = (breakout_definitions.x_res * c) / breakout.max_col; int by0 = (breakout_definitions.y_res * r) / breakout.max_row; int width = (breakout_definitions.x_res / breakout.max_col); int height = (breakout_definitions.y_res / breakout.max_row); if (in_range(nx, bx0, bx0 + width) && ((ny == by0) || (ny == by0 + height))) { // hit top of brick or bottom of brick vy = -vy; g.hit_brick(r, c); return(true); } if (in_range(ny, by0, by0 + height) && ((nx == bx0) || (nx == bx0 + width))) { // hit left or right of brick vx = -vx; g.hit_brick(r, c); return(true); } return(false); }