-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entity.java
70 lines (55 loc) · 1.12 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* An entity that belongs to the world
* @author Johnson Zhou 1302442 <[email protected]>
*
*/
public abstract class Entity {
private int posX;
private int posY;
public Entity() {}
/** setters */
/**
* @param x - x coordinate as int
*/
public void setX(int x) {
this.posX = x;
}
/**
* @param y - y coordinate as int
*/
public void setY(int y) {
this.posY = y;
}
/** getters */
/**
* @return x coordinate as int
*/
public int getX() {
return this.posX;
}
/**
* @return y coordinate as int
*/
public int getY() {
return this.posY;
}
/** public */
/**
* Checks whether this entity has collided with another entity
* @return true | false
*/
public boolean checkCollision(Entity otherEntity) {
return (
this.posX == otherEntity.getX() && this.posY == otherEntity.getY()
);
}
/** abstract */
/**
* @return a marker used to render in the world map
*/
public abstract char getMapMarker();
/** override */
public String toString() {
return String.valueOf(this.getMapMarker());
}
}