-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer
61 lines (51 loc) · 1.25 KB
/
Player
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
public class Player {
private int x, y;
private int water, food, life;
Planta planta = new Planta(this);
public Player(int x, int y) {
this.x = x;
this.y = y;
this.water = 5;
this.food = 5;
this.life = 10;
}
public void movimiento(int dx, int dy) {
this.x += dx;
this.y += dy;
}
public void recogioAgua() {
if (water != 10){
water++;
}
}
public void recogioComida() {
if (food != 10){
food++;
}
}
public void damagePlayer() {
if (life > 0){
life--;
if (life <= 0) life = 0;
}
}
public void reducirAguaYComida() {
if (water > 0) water--;
if (food > 0) food--;
}
public void actualizar() {
if (water == 10 && food == 10) {
life++;
if (life > 10) life = 10;
}
if (water == 0 || food == 0 || planta.getWater() == 0){
life--;
if (life < 0) life = 0;
}
}
public int getX() { return x; }
public int getY() { return y; }
public int getWater() { return water; }
public int getFood() { return food; }
public int getLife() { return life; }
}