-
Notifications
You must be signed in to change notification settings - Fork 1
/
TagCanvas.pde
121 lines (105 loc) · 2.78 KB
/
TagCanvas.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
Copyright 2015 Antonio Jesús Sánchez Padial
See License info at the end of the file.
*/
class TagCanvas {
float w, h;
float x, y;
float textX, textY;
String tag;
ArrayList minis;
float deltaX, deltaY;
LuminanceColor c;
float wide;
PFont font;
TagCanvas(int sector, String tag, float wide, PFont font, LuminanceColor col) {
this.wide = wide;
this.font = font;
minis = new ArrayList();
this.tag = tag;
c = col;
if (sector == UP) {
x = wide;
y = 0;
this.w = width - wide;
this.h = wide;
textX = x + 0.8 * this.w;
textY = y + 0.35 * this.h;
deltaX = wide + 0.5;
deltaY = 0;
}
if (sector == DOWN) {
x = 0;
y = height - wide;
this.w = width - wide;
this.h = wide;
textX = x + 0.02 * this.w;
textY = y + 0.35 * this.h;
deltaX = wide + 0.5;
deltaY = 0;
}
if (sector == LEFT) {
x = 0;
y = 0;
w = wide;
this.h = height - wide;
this.w = wide;
textX = x + 0.3 * this.w;
textY = y + 0.1 * this.h;
deltaX = 0;
deltaY = wide + 0.5;
}
if (sector == RIGHT) {
x = width - wide;
y = wide;
this.h = height - wide;
this.w = wide;
textX = x + 0.3 * this.w;
textY = y + 0.95 * this.h;
deltaX = 0;
deltaY = wide + 0.5;
}
}
void update() {
for (int i = 0; i < minis.size(); i++) {
Sprite spr = (Sprite)minis.get(i);
spr.update();
}
}
void draw() {
noStroke();
textFont(font, 32);
fill(c.getColor());
rect(this.x, this.y, this.w, this.h);
for (int i = 0; i < minis.size(); i++) {
Sprite spr = (Sprite)minis.get(i);
spr.draw();
}
fill(c.copy().lighter().getColor());
text(tag, textX, textY);
noFill();
}
void addImage(Sprite img) {
Sprite spr = img.copy();
spr.scale = .7;
int i = minis.size();
spr.x = 0.05 * wide + this.x + i * this.deltaX;
spr.y = 0.05 * wide + this.y + i * this.deltaY;
img.animate(spr, 500);
img.setFPS(12);
minis.add(img);
}
}
/*
This file is part of Tag Attack.
Tag Attack is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Tag Attack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/