-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.js
40 lines (34 loc) · 950 Bytes
/
Entity.js
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
class Entity {
constructor(x, y, model, tiles) {
this.x = x;
this.y = y;
this.model = model;
this.tile = tiles[this.x][this.y];
this.tile.setClear(false);
this.tile.occupant = this;
}
update() {
}
interact() {
if (this.type && this.type == "PC") {
menu.menuState = MENU_STATES.BANK_MENU;
menu.lastIndex = menu.index;
menu.index = 0;
state = STATE.PAUSED;
}
}
draw(x, y) {
let newX = this.x + 4 - x;
let newY = this.y + 4 - y;
if (this.model == 0) {
push()
fill(255, 0, 255);
noStroke();
ellipseMode(CORNER);
circle(newX * TILE_WIDTH, newY * TILE_HEIGHT, TILE_WIDTH);
pop();
} else {
image(globalSpriteList.models[`${this.model}`], newX * TILE_WIDTH, newY * TILE_HEIGHT);
}
}
}