-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHUD.java
More file actions
80 lines (68 loc) · 1.28 KB
/
HUD.java
File metadata and controls
80 lines (68 loc) · 1.28 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import processing.core.PApplet;
import java.util.ArrayList;
//TODO: this class should be a Singleton
public class HUD
{
private ArrayList objects;
public HUD()
{
this.objects = new ArrayList();
}
public void addObject(HUDObject obj)
{
this.objects.add(obj);
}
public boolean isActive(String name)
{
return this.get(name).isActive();
}
public void activateObject(String name)
{
HUDObject hudObj = this.get(name);
if (hudObj != null)
{
hudObj.activate();
}
}
public void deactivateObject(String name)
{
HUDObject hudObj = this.get(name);
if (hudObj != null)
{
hudObj.deactivate();
}
}
public HUDObject get(int i)
{
return (HUDObject) objects.get(i);
}
public HUDObject get(String name)
{
HUDObject cur;
for (int i=0; i<objects.size(); i++)
{
cur = (HUDObject) objects.get(i);
if(cur.getName() == name)
{
return cur;
}
}
return null;
}
public int size()
{
return objects.size();
}
public void render()
{
HUDObject cur;
for (int i=0; i<objects.size(); i++)
{
cur = (HUDObject) objects.get(i);
if(cur.isActive())
{
cur.render();
}
}
}
}