protectwall.java

来自「java小项目,坦克大战,学习的好资料 eclipse下可运行」· Java 代码 · 共 38 行

JAVA
38
字号
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

public class ProtectWall {
	int x,y,w,h;
	private boolean life = true;
	Tank t;
	
	public ProtectWall(int x,int y,int w, int h,boolean life) {
		this.x = x;
		this.y = y;
		this.w = w;
		this.h = h;
		this.life = life;
	}
	
	public void draw(Graphics g) {
		if(!life) return;
		Color c = g.getColor();
		g.setColor(Color.gray);
		g.fillRect(x, y, w, h);
		g.setColor(c);
	}
	
	public Rectangle getRect() {
		return new Rectangle(x,y,w,h);
	}

	public boolean isLife() {
		return life;
	}

	public void setLife(boolean life) {
		this.life = life;
	}
}

⌨️ 快捷键说明

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