import java.awt.*;
public class wall{
private int xPos;
private int yPos;
private Rectangle[] border = new Rectangle[4];
private boolean[] shape = new boolean[16];
private boolean walldestoried;
private boolean bulletdestoried;
public wall(int a, int b){
xPos = a;
yPos = b;
border[0] = new Rectangle(xPos - 11, yPos - 11, 11, 11);
border[1] = new Rectangle(xPos + 1, yPos - 11, 11, 11);
border[2] = new Rectangle(xPos - 11, yPos + 1, 11, 11);
border[3] = new Rectangle(xPos + 1, yPos + 1, 11, 11);
}
public wall(int a, int b, int c){
xPos = a;
yPos = b;
if(c == 0){
border[0] = new Rectangle(xPos - 11, yPos - 11, 11, 11);
border[1] = new Rectangle(xPos + 1, yPos - 11, 11, 11);
for(int i = 8; i < 12; i ++)
shape[i] = true;
for(int i = 12; i < 16; i ++)
shape[i] = true;
}
if(c == 1){
border[2] = new Rectangle(xPos - 11, yPos + 1, 11, 11);
border[3] = new Rectangle(xPos + 1, yPos + 1, 11, 11);
for(int i = 0; i < 4; i ++)
shape[i] = true;
for(int i = 4; i < 8; i ++)
shape[i] = true;
}
if(c == 2){
border[0] = new Rectangle(xPos - 11, yPos - 11, 11, 11);
border[2] = new Rectangle(xPos - 11, yPos + 1, 11, 11);
for(int i = 3; i <= 15; i+=4)
shape[i] = true;
for(int i = 2; i <= 14; i+=4)
shape[i] = true;
}
if(c == 3){
border[1] = new Rectangle(xPos + 1, yPos - 11, 11, 11);
border[3] = new Rectangle(xPos + 1, yPos + 1, 11, 11);
for(int i = 1; i <= 13; i+=4)
shape[i] = true;
for(int i = 0; i <= 12; i+=4)
shape[i] = true;
}
}
public void damageWall(Rectangle bullet, int bulletpower, int bulletdirection){
if(bulletpower == 1){
if(border[0] != null && border[1] != null && bulletdirection == 1){
if(bullet.intersects(border[0]) && bullet.intersects(border[1])){
if(shape[1] && shape[2]){
for(int i = 4; i < 8; i ++)
shape[i] = true;
border[0] = null;
border[1] = null;
}
if(!shape[1] || !shape[2]){
for(int i = 0; i < 4; i ++)
shape[i] = true;
}
bulletdestoried = true;
}
}
if(border[0] != null && border[1] != null && bulletdirection == 0){
if(bullet.intersects(border[0]) && bullet.intersects(border[1])){
if(shape[5] && shape[6]){
for(int i = 0; i < 4; i ++)
shape[i] = true;
border[0] = null;
border[1] = null;
}
if(!shape[5] || !shape[6]){
for(int i = 4; i < 8; i ++)
shape[i] = true;
}
bulletdestoried = true;
}
}
if(border[2] != null && border[3] != null && bulletdirection == 1){
if(bullet.intersects(border[2]) && bullet.intersects(border[3])){
if(shape[9] && shape[10]){
for(int i = 12; i < 16; i ++)
shape[i] = true;
border[2] = null;
border[3] = null;
}
if(!shape[9] || !shape[10]){
for(int i = 8; i < 12; i ++)
shape[i] = true;
}
bulletdestoried = true;
}
}
if(border[2] != null && border[3] != null && bulletdirection == 0){
if(bullet.intersects(border[2]) && bullet.intersects(border[3])){
if(shape[13] && shape[14]){
for(int i = 8; i < 12; i ++)
shape[i] = true;
border[2] = null;
border[3] = null;
}
if(!shape[13] || !shape[14]){
for(int i = 12; i < 16; i ++)
shape[i] = true;
}
bulletdestoried = true;
}
}
if(border[0] != null && border[2] != null && bulletdirection == 3){
if(bullet.intersects(border[0]) && bullet.intersects(border[2])){
if(shape[4] && shape[8]){
for(int i = 1; i <= 13; i+=4)
shape[i] = true;
border[0] = null;
border[2] = null;
}
if(!shape[4] || !shape[8]){
for(int i = 0; i <= 12; i+=4)
shape[i] = true;
}
bulletdestoried = true;
}
}
if(border[0] != null && border[2] != null && bulletdirection == 2){
if(bullet.intersects(border[0]) && bullet.intersects(border[2])){
if(shape[5] && shape[9]){
for(int i = 0; i <= 12; i+=4)
shape[i] = true;
border[0] = null;
border[2] = null;
}
if(!shape[5] || !shape[9]){
for(int i = 1; i <= 13; i+=4)
shape[i] = true;
}
bulletdestoried = true;
}
}
if(border[1] != null && border[3] != null && bulletdirection == 3){
if(bullet.intersects(border[1]) && bullet.intersects(border[3])){
if(shape[6] && shape[10]){
for(int i = 3; i <= 15; i+=4)
shape[i] = true;
border[1] = null;
border[3] = null;
}
if(!shape[6] || !shape[10]){
for(int i = 2; i <= 14; i+=4)
shape[i] = true;
}
bulletdestoried = true;
}
}
if(border[1] != null && border[3] != null && bulletdirection == 2){
if(bullet.intersects(border[1]) && bullet.intersects(border[3])){
if(shape[7] && shape[11]){
for(int i = 2; i <= 14; i+=4)
shape[i] = true;
border[1] = null;
border[3] = null;
}
if(!shape[7] || !shape[11]){
for(int i = 3; i <= 15; i+=4)
shape[i] = true;
}
bulletdestoried = true;
}
}
}
if(bulletpower == 2){
if(border[0] != null && border[1] != null && (bulletdirection == 0 || bulletdirection == 1)){
if(bullet.intersects(border[0]) && bullet.intersects(border[1])){
for(int i = 0; i < 8; i++)
shape[i] = true;
border[0] = null;
border[1] = null;
bulletdestoried = true;
}
}
if(border[2] != null && border[3] != null && (bulletdirection == 0 || bulletdirection == 1)){
if(bullet.intersects(border[2]) && bullet.intersects(border[3])){
for(int i = 8; i < 16; i++)
shape[i] = true;
border[2] = null;
border[3] = null;
bulletdestoried = true;
}
}
if(border[0] != null && border[2] != null && (bulletdirection == 2 || bulletdirection == 3)){
if(bullet.intersects(border[0]) && bullet.intersects(border[2])){
for(int i = 0; i <= 12; i+=4)
shape[i] = true;
for(int i = 1; i <= 13; i+=4)
shape[i] = true;
border[0] = null;
border[2] = null;
bulletdestoried = true;
}
}
if(border[1] != null && border[3] != null && (bulletdirection == 2 || bulletdirection == 3)){
if(bullet.intersects(border[1]) && bullet.intersects(border[3])){
for(int i = 2; i <= 14; i+=4)
shape[i] = true;
for(int i = 3; i <= 15; i+=4)
shape[i] = true;
border[1] = null;
border[3] = null;
bulletdestoried = true;
}
}
}
//******************************************************************************************* if(border[0] != null ){
if(border[0] != null){
Rectangle a = new Rectangle(border[0].x, border[0].y, 5, 5);
Rectangle b = new Rectangle(border[0].x + 7, border[0].y, 5, 5);
Rectangle c = new Rectangle(border[0].x, border[0].y + 7, 5, 5);
Rectangle d = new Rectangle(border[0].x + 7, border[0].y + 7, 5, 5);
if(border[0] != null){
if(bullet.intersects(border[0]) && bulletdirection == 1 && !(bullet.intersects(b) && ((!shape[2] || !shape[6]) || (shape[1] && shape[2] && shape[5] && shape[6])))){
if(bullet.intersects(a) && shape[0] && !shape[4]){
shape[4] = true;
shape[5] = true;
bulletdestoried = true;
border[0] = null;
}
if(bullet.intersects(b) && shape[1] && !shape[5]){
shape[4] = true;
shape[5] = true;
bulletdestoried = true;
border[0] = null;
}
if(bullet.intersects(a) && !shape[0]) {
if(bulletpower == 1){
shape[0] = true;
shape[1] = true;
}
if(bulletpower == 2){
shape[0] = true;
shape[1] = true;
shape[4] = true;
shape[5] = true;
}
bulletdestoried = true;
if(shape[4] && shape[5])