⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 steelwall.java

📁 java 自己写的小程序!!!欢迎使用!!!!
💻 JAVA
字号:
import java.awt.*;

public class Steelwall{
	private int xPos;
	private int yPos;
	private Rectangle[] border = new Rectangle[4];
	private boolean[] shape = new boolean[4];
	private boolean walldestoried;
	private boolean bulletdestoried;

	public Steelwall(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 Steelwall(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);
				shape[2] = true;
				shape[3] = true;
		}
		if(c == 1){
			border[2] = new Rectangle(xPos - 11, yPos + 1, 11, 11);
			border[3] = new Rectangle(xPos + 1, yPos + 1, 11, 11);
				shape[0] = true;
				shape[1] = true;
		}
		if(c == 2){
			border[0] = new Rectangle(xPos - 11, yPos - 11, 11, 11);
			border[2] = new Rectangle(xPos - 11, yPos + 1, 11, 11);
				shape[1] = true;
				shape[3] = true;
		}
		if(c == 3){
			border[1] = new Rectangle(xPos + 1, yPos - 11, 11, 11);
			border[3] = new Rectangle(xPos + 1, yPos + 1, 11, 11);
				shape[0] = true;
				shape[2] = true;
		}
	}


	public void damageWall(Rectangle bullet, int bulletpower, int bulletdirection){
		if(bulletpower == 2){
			for(int i = 0; i < 4; i++){
				if(border[i] != null){
					if(bullet.intersects(border[i])){
						bulletdestoried = true;
						border[i] = null;
						shape[i] = true;
					}
				}
			}
		}
		if(bulletpower == 1){
			for(int i = 0; i < 4; i++){
				if(border[i] != null){
					if(bullet.intersects(border[i]))
						bulletdestoried = true;
				}
			}
		}
	}

	public int getxPos(){
		return xPos;
	}

	public int getyPos(){
		return yPos;
	}

	public boolean Bulletdestoried(){
		return bulletdestoried;
	}

	public void restore(){
		bulletdestoried = false;
	}

	public boolean walldestoried(){
		boolean walldestory = false;
		if(border[0] == null && border[1] == null && border[2] == null && border[3] == null)
			walldestory = true;
		return walldestory;
	}

	public Rectangle getborder(){
		return new Rectangle(xPos - 12, yPos - 12, 25, 25);
	}

	public Rectangle[] detailborder(){
		return border;
	}

	public void draw(Graphics g) {
		g.setColor(new Color(128, 64, 0));
		if(shape[0])
			g.fillRect(xPos - 12, yPos - 12, 13, 13);
		if(shape[1])
			g.fillRect(xPos, yPos - 12, 13, 13);
		if(shape[2])
			g.fillRect(xPos - 12, yPos, 13, 13);
		if(shape[3])
			g.fillRect(xPos, yPos, 13, 13);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -