-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entity.java
51 lines (37 loc) · 1.35 KB
/
Entity.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
public class Entity {
// Funny moving wall
public Vector2 position = new Vector2(0, 0);
public double rotation = 0;
public double length = 1.0;
public String texture = "null";
public boolean doCollide = false;
public boolean freeNextFrame = false;
public Entity() {
}
public Entity(Vector2 position, double rotation) {
this.position = position;
this.rotation = rotation;
}
public void update(Player player) {
}
public boolean isColliding(Vector2 pos) {
// Calculate the distance between the entity and the point
double dist = Vector2.Distance(position, pos);
// Check if the distance is less than the length of the entity
if (dist < length) {
return true;
}
return false;
}
public Wall makeWall() {
// Subtract length / 2 from the position according to the rotation
Vector2 pos = new Vector2(position.x - (length / 2) * Math.cos(rotation),
position.y - (length / 2) * Math.sin(rotation));
// Add length / 2 to the position according to the rotation
Vector2 pos2 = new Vector2(position.x + (length / 2) * Math.cos(rotation),
position.y + (length / 2) * Math.sin(rotation));
return new Wall(pos, pos2, texture);
}
public void onHit() {
}
}