-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbombs.js
More file actions
47 lines (40 loc) · 717 Bytes
/
bombs.js
File metadata and controls
47 lines (40 loc) · 717 Bytes
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
let bombs = [];
function addBomb(x, y, radius, timer)
{
const bomb = {
bomb_xy: {
x: x,
y: y
},
radius: radius,
timer: timer
}
bombs.push(bomb);
}
function removeBomb(x, y)
{
let i = 0;
bombs.forEach(bomb => {
if(bomb.bomb_xy.x === x && bomb.bomb_xy.y === y)
{
bombs.splice(i, 1);
return;
}
i++;
});
}
function decreaseTimeOfBombs(seconds)
{
bombs.forEach(bomb => {
bomb.timer-=seconds;
});
}
function getBombs()
{
return bombs;
}
function clearBombs()
{
bombs = [];
}
module.exports = {addBomb, removeBomb, getBombs, decreaseTimeOfBombs, clearBombs}