-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.pde
66 lines (57 loc) · 1.53 KB
/
Player.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
class Player {
private Camp ownCamp;
color farbe;
private int score;
int index;
Seeker[] seekers;
Bot control;
Player(int ind) {}
Player(int ind,Bot b) {
control = b;
index = ind;
PVector center = new PVector(300, 300);
PVector CampPos = new PVector(sin(TWO_PI * index/playerNum)*300, -1*cos(TWO_PI*index/playerNum)*300);
CampPos.mult(0.9);
CampPos.add(center);
farbe = color(random(255), random(255), random(255));
ownCamp = new Camp(CampPos, 20, this);
score = 0;
seekers = new Seeker[seekerNum];
for (int i = 0; i < seekerNum; i++) {
PVector playerPos;
if (playerNum == 1) {
playerPos = new PVector(random(600), random(600));
} else if (playerNum == 2) {
playerPos = new PVector(random(600), random(300*index, 300+300*index));
} else {
float val = random(300);
float alpha = TWO_PI/playerNum/2;
float val2 = tan(alpha)*val;
playerPos = new PVector(random(-val2, val2), -val);
playerPos.rotate(TWO_PI*index/playerNum);
playerPos.limit(300);
playerPos.add(center);
}
seekers[i] = new Seeker(playerPos, this);
}
}
void update() {
ownCamp.update();
}
void show() {
ownCamp.show();
}
void checkScore(){
if(scores[index] != score) scores[index] = score;
}
Camp getCamp() {
return new Camp(ownCamp.getPosition(), ownCamp.getSize(), new Player(0));
}
void score() {
score++;
scores[index]++;
}
int getScore() {
return score;
}
}