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

📄 myhome.java

📁 java小项目,坦克大战,学习的好资料 eclipse下可运行
💻 JAVA
字号:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

public class MyHome {
	private static final int WIDTH = 30;
	private static final int HEIGHT = 30;
	
	int x,y;
	private boolean life = true;
	TankClient tc;
	
	public MyHome(int x,int y,boolean life,TankClient tc) {
		this.x = x;
		this.y = y;
		this.life = life;
		this.tc = tc;
	}
	
	public void draw(Graphics g) {
		if(!life) {
			return;
		}
		Color c = g.getColor();
		g.setColor(Color.RED);
		g.fillRect(x, y, WIDTH, HEIGHT);
		g.setColor(c);
	}
	
	public Rectangle getRect() {
		return new Rectangle(x,y,WIDTH,HEIGHT);
	}

	public boolean isLife() {
		return life;
	}

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

⌨️ 快捷键说明

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