-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSticker.js
More file actions
54 lines (53 loc) · 1.19 KB
/
Sticker.js
File metadata and controls
54 lines (53 loc) · 1.19 KB
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
class Sticker
{
constructor()
{
this.coordsList=[];
}
getIndex([x,y])
{
for(let i=0;i<this.coordsList.length;i++)
{
if(this.coordsList[i][0]==x && this.coordsList[i][1]==y)
{
return i;
}
}
return -1;
}
removeRow(row)
{
let audio=new Audio('https://audio-previews.elements.envatousercontent.com/files/116837282/preview.mp3');
audio.play();
for(let i=0;i<10;i++)
{
this.coordsList.splice(this.getIndex([row,i]),1);
}
for(let i=0;i<this.coordsList.length;i++)
{
if(this.coordsList[i][0]<row) this.coordsList[i][0]+=1;
}
score+=10;
displayScore();
}
checkRow()
{
for(let i=19;i>=0;i--)
{
let isFull=true;
for(let j=0;j<10;j++)
{
if(this.getIndex([i,j])==-1) isFull=false;
}
if(isFull==true)
{
this.removeRow(i);
i+=1;
}
}
}
append(coordsList_)
{
Array.prototype.push.apply(this.coordsList,coordsList_);
}
}