-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHUD.java
More file actions
53 lines (44 loc) · 996 Bytes
/
HUD.java
File metadata and controls
53 lines (44 loc) · 996 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
44
45
46
47
48
49
50
51
52
53
package com.tutorial.main;
import java.awt.Color;
import java.awt.Graphics;
public class HUD
{
public static float HEALTH = 100;
private float greenValue = 255;
private int score = 0;
private int level = 1;
public void tick()
{
HEALTH = (int) Game.clamp(HEALTH, 0, 100);
greenValue = (int) Game.clamp(greenValue, 0, 255);
greenValue = (HEALTH*2);
score++;
}
public void render(Graphics g)
{
g.setColor(Color.gray);
g.fillRect(15, 15, 200, 32);
g.setColor(new Color(75, (int)greenValue, 0));
g.fillRect(15, 15, (int)HEALTH * 2, 32);
g.setColor(Color.white);
g.drawRect(15, 15, 200, 32);
g.drawString("Homey Score: " + score, 15, 64);
g.drawString("Level " + level, 15, 80);
}
public void setScore(int score)
{
this.score = score;
}
public int getScore()
{
return score;
}
public void setLevel(int level)
{
this.level = level;
}
public int getLevel()
{
return level;
}
}