forked from danicarrion/roboscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
box.js
33 lines (29 loc) · 890 Bytes
/
box.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
const box = {
x: null,
y: null,
currentCell: null,
show: function (newX, newY) {
if (newX !== null && newX !== undefined) {
this.x = parseInt(newX);
}
if (newY !== null && newY !== undefined) {
this.y = parseInt(newY);
}
this.currentCell = document.getElementById("cell_" + this.x.toString() + this.y.toString());
if (!(this.currentCell)) {
return false;
}
this.currentCell.style.backgroundImage = "url('box.png')";
this.currentCell.style.backgroundSize = "cover";
return true;
},
hide: function () {
if (this.currentCell) {
this.currentCell.style.backgroundImage = null;
this.currentCell = null;
if (robo.x == this.x && robo.y == this.y) {
robo.show();
}
}
}
}