-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHUD.pde
102 lines (89 loc) · 2.24 KB
/
HUD.pde
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
class HUD {
// booleans to show certain parts of the HUD
boolean HP, ammo, items, emusKilled;
PImage boomerangIcon;
int selectedItem = 0;
HUD (boolean hp, boolean a, boolean i, boolean e) {
HP = hp;
ammo = a;
items = i;
emusKilled = e;
}
void showFPS() {
text("FPS: " + (int) frameRate, 10, 30);
}
void showHP() {
text("Truck Condition: " + (int) (truck.getHP()*100) + "%", 150, 30);
}
void showAmmo() {
for (Gun g : guns) {
if (g.getReloading()) {
text("Reloading", 500, 30);
} else {
text("Ammo: " + (int) g.getAmmo() + " | " + (int) g.getMaxAmmo(), 500, 30);
}
}
}
void showEmusKilled() {
for (Level l : levels) {
text("Emus Killed: " + l.getEmusKilled(), 1100, 30);
}
}
void setSelectedItem(int x) {
selectedItem = x;
}
int getSelectedItem() {
return selectedItem;
}
// draws inventory GUI and places items in it when they are in stock
void showItems() {
for (int i = 0; i < 5; i++) {
stroke(10);
fill(220);
rectMode(CORNER);
rect(75*i, height-75, 75, 75);
}
fill(100, 100);
rect(selectedItem*75, height-75, 75, 75);
textAlign(CENTER);
if (!boomerangTimer.isDone()) {
fill(0, 100);
rect(0, height-75, 75, 75);
}
fill(0);
if (inventory.get("Boomerang") > 0) {
image(boomerang, 30, height-30);
text(inventory.get("Boomerang"), 10, height-50);
}
if (inventory.get("Vegemite") > 0) {
image(vegemite, 115, height-30);
text(inventory.get("Vegemite"), 85, height-50);
}
if (inventory.get("Grenade") > 0) {
image(grenade, 190, height-30);
text(inventory.get("Grenade"), 160, height-50);
}
if (inventory.get("Landmine") > 0) {
image(landmine, 265, height-30);
text(inventory.get("Landmine"), 235, height-50);
}
if (inventory.get("Gas") > 0) {
image(grenade, 340, height-30);
text(inventory.get("Gas"), 310, height-50);
}
}
void showEmusAlive() {
text("Emus Alive: " + emusAlive(), 900, 30);
}
void update() {
textFont(stamp30);
fill(0);
textAlign(LEFT);
showFPS();
showHP();
showAmmo();
showEmusAlive();
showEmusKilled();
showItems();
}
}