-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.js
64 lines (52 loc) · 1.06 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* ************************************************
** GAME PLAYER CLASS
************************************************ */
var Player = function (startX, startY) {
var x = startX
var y = startY
var id
var name
var killCount = 0;
var healthbar;
// Getters and setters
var getX = function () {
return x
}
var getY = function () {
return y
}
var getHealth = function(){
return healthbar;
}
var getKillCount = function(){
return killCount;
}
var setKillCount = function(){
killCount++;
};
var setHealth = function(newHealth){
healthbar = newHealth;
}
var setX = function (newX) {
x = newX
}
var setY = function (newY) {
y = newY
}
// Define which variables and methods can be accessed
return {
getX: getX,
getY: getY,
setX: setX,
setY: setY,
name: name,
getHealth: getHealth,
setHealth: setHealth,
setKillCount: setKillCount,
getKillCount: getKillCount,
id: id
}
}
// Export the Player class so you can use it in
// other files by using require("Player")
module.exports = Player