-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiece.pde
77 lines (44 loc) · 966 Bytes
/
Piece.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
class Piece {
float x, y;
boolean col;
char type;
PImage icon;
boolean moving;
Piece(float x, float y, boolean col, char type) {
this.x = x;
this.y = y;
this.col = col;
this.type = type;
icon = loadImage((col ? "w" : "b") + type + "_.png");
icon.resize(0, int(w*.9));
moving = false;
}
void render() {
pushMatrix();
translate(x + w/2, y + w/2);
if (!col) rotate(PI);
if (USE_ICONS) {
//image
imageMode(CENTER);
image(icon, 0, 0);
} else {
//circle
fill(col ? white : black);
stroke(!col ? offwhite : offblack);
strokeWeight(3);
ellipse(0, 0, w*.9, w*.9);
//text
textAlign(CENTER, CENTER);
fill(!col ? offwhite : offblack);
textSize(w*.9);
text(type, 0, 0);
}
popMatrix();
}
void update() {
if (moving) {
x = mouseX - w/2;
y = mouseY - w/2 - OFFSET;
}
}
}