-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHUD.java
More file actions
43 lines (32 loc) · 748 Bytes
/
Copy pathHUD.java
File metadata and controls
43 lines (32 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.awt.*;
public class HUD {
//Heads Up Display
//This HUD is in response to the Player
private int maxHealth = 200;
private double health = 200;
public void draw(Graphics g){
g.setColor(Color.red);
g.fillRect(10, 10, maxHealth, 20);
g.setColor(Color.green);
g.fillRect(10, 10, (int)health, 20);
g.setColor(Color.black);
g.drawRect(10, 10, 200, 20);
}
public double getHealth(){
return health;
}
public void setHealth(int hp){
health = hp;
}
public int getMaxHealth(){
return maxHealth;
}
public void hit(int var){
health = health - var;
}
public void regen(double x){
health += x;
if(health >= maxHealth)
health = maxHealth;
}
}