-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrick.pde
More file actions
47 lines (40 loc) · 1.23 KB
/
brick.pde
File metadata and controls
47 lines (40 loc) · 1.23 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
class Brick {
PVector position;
boolean destroyed;
final float w = brick_w, h = brick_h;
final float darkenAmount = 0.4;
int col_number;
color darkerColor, brighterColor;
final color[] colors = {
color(235, 0, 0), // Red
color(235, 150, 0), // Orange
color(235, 235, 0), // Yellow
color(0, 235, 0), // Green
color(0, 235, 235), // Cyan
color(0, 0, 235), // Blue
color(255, 0, 255), // Magenta
};
Brick(PVector pos, int color_number) {
reset(pos, color_number);
}
void destroy() {
destroyed = true;
}
void reset(PVector pos, int color_number) {
position = new PVector(pos.x, pos.y);
destroyed = false;
col_number = color_number;
}
void draw() {
if(!destroyed) {
darkerColor = lerpColor(colors[col_number], color(0), darkenAmount);
brighterColor = lerpColor(colors[col_number], color(255), darkenAmount);
fill(darkerColor);
rect(position.x, position.y, w, h);
fill(brighterColor);
triangle(position.x, position.y, position.x + w, position.y, position.x, position.y + h);
fill(colors[col_number]);
rect(position.x + w / 9, position.y + h / 8, w / 9 * 7, h / 8 * 6);
}
}
}