📄 bloodbar.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 + -