-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.js
94 lines (74 loc) · 1.9 KB
/
button.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
class Button extends GraphicObject {
constructor(x, y, width, height, img, tlacidloID) {
super(x, y, width, height, img)
this.tlacidloID = tlacidloID
}
clickHandler(x, y, ctx) {
// klik sa spracuje, iba ak bol nad tlacidlom
if (x >= this.x && x <= (this.x + this.width) && y >= this.y && y <= (this.y + this.height) ) {
// je zapnuta uvodna obrazovka
if (localStorage.initScreen == 'true') {
switch (this.tlacidloID) {
case "newGame":
VykresliLevel();
level1(ctx)
break;
case "scoreMenu":
scoreScreen(ctx);
break;
case "tutorial":
tutorial(ctx);
break;
case "Sound":
localStorage.zvuk = 'false';
console.log("Klikla som na zvuk")
CheckAudio();
//znovaZobrazStart();
break;
}
}
// je zapnuta koncova obrazovka
else if (localStorage.endGame == 'true') {
switch (this.tlacidloID) {
case "buttonMenu":
localStorage.initScreen = 'true';
znovaZobrazStart();
VykresliLevel();
console.log("klikol si na menu");
localStorage.endGame = 'false';
break;
case "PlayAgain":
localStorage.endGame = 'false';
VykresliLevel();
console.log("klikol si na PLAY AGAIN ");
level1(ctx)
break;
case "MainMenuButton":
localStorage.initScreen = 'true';
znovaZobrazStart();
VykresliLevel();
console.log("klikol si na menu");
localStorage.endGame = 'false';
break;
}
}
//je zapnuta obrazovka tutorial
else if (localStorage.tutorial == 'true') {
switch (this.tlacidloID) {
case "ok":
localStorage.initScreen = 'true';
znovaZobrazStart();
break;
}
}
else if (localStorage.score == 'true') {
switch (this.tlacidloID) {
case "ok":
localStorage.initScreen = 'true';
znovaZobrazStart();
break;
}
}
}
}
}