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

📄 bloodbar.java

📁 坦克大战,最基本的Graphics 类进行的画图。TankClient.java这个是主文件
💻 JAVA
字号:
package tank;

import java.awt.Graphics;
import java.awt.Color;
public class BloodBar {
private int x,y;
private int oldX,oldY;


private int  BLOOD_WIDTH=50;

private static final int BLOOD_WIDTH_RECT=50;
private static final int BLOOD_HEIGHT=10;
public BloodBar(int x, int y) {
	this.x = x;
	this.y = y;
}
public void draw(Graphics g){
	Color c=g.getColor();
	g.setColor(Color.RED);
	g.drawRect(x, y, BLOOD_WIDTH_RECT, BLOOD_HEIGHT);
	g.fillRect(x, y, BLOOD_WIDTH, BLOOD_HEIGHT);
	g.setColor(c);
}
public void setBLOOD_WIDTH(int BLOOD_WIDTH){
	this.BLOOD_WIDTH=BLOOD_WIDTH;
}
public int getBLOOD_WIDTH() {
	return BLOOD_WIDTH;
}
public void setX(int x) {
	this.x = x;
}

public void setY(int y) {
	this.y = y;
}
public void setOldX(int oldX) {
	this.oldX = oldX;
}
public void setOldY(int oldY) {
	this.oldY = oldY;
}
public void moveBack() {
	this.x=this.oldX;
	this.y=this.oldY;
	
}

}

⌨️ 快捷键说明

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