-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scene.pde
95 lines (79 loc) · 1.87 KB
/
Scene.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
class Scene {
ArrayList<Element> elements;
Scene() {
elements = new ArrayList<Element>();
// Initialize Navigation
Button[] buttonsNav = new Button[3];
String[] buttonLabels = {"Start", "Infografik", "Quiz"};
int currXPos = 591;
for (int i = 0; i <= 2; i++) {
buttonsNav[i] = new ButtonNavigation(currXPos, 42, 24, buttonLabels[i], i);
elements.add(buttonsNav[i]);
currXPos += buttonsNav[i].w;
}
}
void onMousePressed() {
ArrayList<Element> visibleElements = new ArrayList<Element>();
for (Element e : elements) {
if (! e.isHidden) {
visibleElements.add(e);
}
}
for (Element e: visibleElements) {
if (isMouseInsideRect(e.x, e.y, e.x + e.w, e.y + e.h)) {
e.onClick(true);
}
else {
e.onClick(false);
}
}
}
void onMouseDragged() {
ArrayList<Element> visibleElements = new ArrayList<Element>();
for (Element e : elements) {
if (! e.isHidden) {
visibleElements.add(e);
}
}
for (Element e: visibleElements) {
if (isMouseInsideRect(e.x, e.y, e.x + e.w, e.y + e.h)) {
e.onMouseDragged(true);
}
else {
e.onMouseDragged(false);
}
}
}
void onKeyPressed() {
for (Element e : elements) {
if (! e.isHidden) {
e.onKeyPressed();
}
}
}
void onKeyReleased() {
for (Element e : elements) {
if (! e.isHidden) {
e.onKeyReleased();
}
}
}
void reset() {}
void draw() {
for (Element e : elements) {
if (! e.isHidden) {
e.isHovered = isMouseInsideRect(e.x, e.y, e.x + e.w, e.y + e.h);
e.draw();
}
}
// HEADER
// Title
pushStyle();
noStroke();
fill(colAccentDark);
textFont(fontTitle);
textAlign(LEFT, TOP);
text("Die Brennstoffzelle", 30, 25);
popStyle();
}
}