forked from mperes/ZombieAttack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.pde
49 lines (43 loc) · 1.07 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
class Player {
import java.util.UUID;
String name;
int energy;
int currentEnergy;
PVector position;
float facingDirection;
int kills;
int score;
float survival;
Weapon weapon;
UUID id;
DirectionSolver directionSolver;
Player(String name, float x, float y, float facingDirection, Weapon weapon) {
this.name = name;
this.position = new PVector(x, y, 0.0);
this.facingDirection = facingDirection;
kills = 0;
score = 0;
survival = millis();
energy = INITIALENERGY;
currentEnergy = INITIALENERGY;
this.weapon = weapon;
id = UUID.randomUUID();
directionSolver = new DirectionSolver();
}
void fire() {
weapon.fire(position.x, position.y, facingDirection-1.5*PI);
}
void reload() {
weapon.reload();
}
void update() {
directionSolver.update();
facingDirection = directionSolver.getDirection();
for(int x = 0;x<weapon.bullets.size();x++){
Bullet bullet = weapon.bullets.get(x);
bullet.update();
if(!bullet.alive)
weapon.bullets.remove(x);
}
}
}