application.windows32/source/BattleCity_Tank.java
/*
  No idea why this code works
   */
No idea why this code works
No idea why this code works
public void checkHitTile() {
    if (state == ShellState.ACTIVE) {
      if (x < ACTUAL_WIDTH - SIZE/2 && x > -SIZE/2 && y < HEIGHT - SIZE/2 && y > -SIZE/2) { 
        if (tiles[(x - SIZE/2)/TILE_SIZE][(y)/TILE_SIZE] == TileType.BRICK && tiles[(x + SIZE/2)/TILE_SIZE][(y)/TILE_SIZE] == TileType.BRICK) {
          removeTile(x - SIZE/2, y);
          removeTile(x + SIZE/2, y);
          state = ShellState.REMOVED;
        }
        if (state == ShellState.ACTIVE) {
          if (tiles[(x)/TILE_SIZE][(y - SIZE/2)/TILE_SIZE] == TileType.BRICK && tiles[(x)/TILE_SIZE][(y + SIZE/2)/TILE_SIZE] == TileType.BRICK) { 
            removeTile(x, y - SIZE/2);
            removeTile(x, y + SIZE/2);
            state = ShellState.REMOVED;
          }
        }
        if (state == ShellState.ACTIVE) {
          if (tiles[(x - SIZE/2)/TILE_SIZE][(y)/TILE_SIZE] == TileType.STEEL && tiles[(x + SIZE/2)/TILE_SIZE][(y)/TILE_SIZE] == TileType.STEEL) {
            if (power == 2) {
              removeTile(x - SIZE/2, y);
              removeTile(x + SIZE/2, y);
            }
            state = ShellState.REMOVED;
          }
          if (state == ShellState.ACTIVE) {
            if (tiles[(x)/TILE_SIZE][(y - SIZE/2)/TILE_SIZE] == TileType.STEEL && tiles[(x)/TILE_SIZE][(y + SIZE/2)/TILE_SIZE] == TileType.STEEL) { 
              if (power == 2) {
                removeTile(x, y - SIZE/2);
                removeTile(x, y + SIZE/2);
              }
              state = ShellState.REMOVED;
            }
          }
        }
      }
    }
  }
public void checkHitTile ( ) { if ( state == ShellState . ACTIVE ) { if ( x < ACTUAL_WIDTH - SIZE / 2 && x > - SIZE / 2 && y < HEIGHT - SIZE / 2 && y > - SIZE / 2 ) { if ( tiles [ ( x - SIZE / 2 ) / TILE_SIZE ] [ ( y ) / TILE_SIZE ] == TileType . BRICK && tiles [ ( x + SIZE / 2 ) / TILE_SIZE ] [ ( y ) / TILE_SIZE ] == TileType . BRICK ) { removeTile ( x - SIZE / 2 , y ) ; removeTile ( x + SIZE / 2 , y ) ; state = ShellState . REMOVED ; } if ( state == ShellState . ACTIVE ) { if ( tiles [ ( x ) / TILE_SIZE ] [ ( y - SIZE / 2 ) / TILE_SIZE ] == TileType . BRICK && tiles [ ( x ) / TILE_SIZE ] [ ( y + SIZE / 2 ) / TILE_SIZE ] == TileType . BRICK ) { removeTile ( x , y - SIZE / 2 ) ; removeTile ( x , y + SIZE / 2 ) ; state = ShellState . REMOVED ; } } if ( state == ShellState . ACTIVE ) { if ( tiles [ ( x - SIZE / 2 ) / TILE_SIZE ] [ ( y ) / TILE_SIZE ] == TileType . STEEL && tiles [ ( x + SIZE / 2 ) / TILE_SIZE ] [ ( y ) / TILE_SIZE ] == TileType . STEEL ) { if ( power == 2 ) { removeTile ( x - SIZE / 2 , y ) ; removeTile ( x + SIZE / 2 , y ) ; } state = ShellState . REMOVED ; } if ( state == ShellState . ACTIVE ) { if ( tiles [ ( x ) / TILE_SIZE ] [ ( y - SIZE / 2 ) / TILE_SIZE ] == TileType . STEEL && tiles [ ( x ) / TILE_SIZE ] [ ( y + SIZE / 2 ) / TILE_SIZE ] == TileType . STEEL ) { if ( power == 2 ) { removeTile ( x , y - SIZE / 2 ) ; removeTile ( x , y + SIZE / 2 ) ; } state = ShellState . REMOVED ; } } } } } }
No idea why this code works
No idea why this code works
// remove two horizontal tiles in one hit // remove two vertical tiles in one hit    // remove two horizontal steel tiles in one hit // remove two vertical steel tiles in one hit   