-
Notifications
You must be signed in to change notification settings - Fork 1
/
Team.pde
81 lines (69 loc) · 1.54 KB
/
Team.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
class Team{
Team(String _title, PVector _pos, PVector _size, color _c, boolean _blue){
title = _title;
pos = _pos;
size = _size;
c = _c;
score = 0;
scoreToAdd = 0;
blueText = _blue;
}
void click(PVector click, boolean left){
if (left){
if(click.x > pos.x && click.x < pos.x+size.x && click.y > pos.y && click.y < pos.y+size.y ){
scoreToAdd += quiz.getPoints(c, true);
}
} else {
if(click.x > pos.x && click.x < pos.x+size.x && click.y > pos.y && click.y < pos.y+size.y ){
//score -= quiz.getPoints(c, false);
scoreToAdd -= quiz.getPoints(c, false);
}
}
}
void draw(){
if (scoreToAdd > 1){
score+=5;
scoreToAdd-=5;
} else if (scoreToAdd < -1){
score-=5;
scoreToAdd+=5;
}
if (turn){
fill(255,255,0);
rect(pos.x, pos.y, size.x, size.y);
fill(c);
rect(pos.x+5, pos.y+5, size.x-10, size.y-10);
} else {
fill(c);
rect(pos.x, pos.y, size.x, size.y);
}
textFont(createFont("Arial Bold", 46));
fill(color(255,255,0));
textSize(46);
if(blueText){
fill(color(0,0,255));
}
//textAlign(CENTER);
text(title + ": " + score, pos.x + size.x / 2, pos.y + size.y / 2);
}
void setPos(PVector _pos){
pos = _pos;
}
void setSize(PVector _size){
size = _size;
}
void turn(){
turn = true;
}
void noTurn(){
turn = false;
}
boolean blueText;
String title;
PVector pos;
PVector size;
color c;
int score;
int scoreToAdd;
boolean turn = false;
};