-
Notifications
You must be signed in to change notification settings - Fork 0
/
DoorEntity.java
35 lines (30 loc) · 950 Bytes
/
DoorEntity.java
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
public class DoorEntity extends Entity {
public DoorEntity(Vector2 position, double rotation) {
super(position, rotation);
length = 2.0;
texture = "cross";
doCollide = true;
}
boolean unlocked = false;
int openframes = 0;
public void update(Player player) {
if (isColliding(player.position) && !unlocked) {
if (player.keys > 0) {
player.keys -= 1;
main.Message("Door Unlocked");
unlocked = true;
} else {
main.Message("you need a key");
}
} else if (unlocked) {
// Move the door slightly to the left obeying the rotation
position = position.add(Vector2.fromAngle(rotation).scale(-0.1));
openframes += 1;
if (openframes > 25) {
freeNextFrame = true;
}
}
}
public void onHit() {
}
}