-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.js
44 lines (34 loc) · 896 Bytes
/
player.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
41
42
43
44
// Constant values
const playerX = 0;
const playerY = 350;
const playerWidth = 58;
const playerHeight = 110;
class PlayerController {
constructor() {
this._position = new Points(playerX, playerY);
this._size = new Size(playerWidth, playerHeight);
this._direction = DIRECTION.LEFT;
this._canvas = document.querySelector('canvas#player-canvas');
this._context = this._canvas.getContext('2d');
this._canvas.width = GAME_WIDTH;
this._canvas.height = GAME_HEIGHT;
}
set direction(value) {
this._direction = value;
}
get direction() {
return this._direction;
}
get position() {
return this._position;
}
get size() {
return this._size;
}
get canvas() {
return this._canvas;
}
get context() {
return this._context;
}
}