-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.html
101 lines (88 loc) · 2.72 KB
/
help.html
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
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body onload="init()" id="script">
<canvas id='c' style='position: absolute; left: 0px; top: 0px; z-index: 2;'></canvas>
<script>
var mute = localStorage.getItem('muteState') || "no";
var musicMute = localStorage.getItem('musicMuteState') || "no";
var music = new Audio("sounds/Further_Away.mp3"); // buffers automatically when created
if (mute === "yes") {
music.pause();
} else if (mute === "no" && musicMute === "no") {
music.loop = true;
music.play();
}
var backgroundImage = new Image();
var ctx;
var buttons = [];
function draw() {
var canvasWidth = window.innerWidth;
var canvasHeight = window.innerHeight;
ctx.drawImage(backgroundImage, 0, 0, canvasWidth, canvasHeight);
}
function loadBackgroundImage() {
var canvas = document.getElementById("c");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
ctx = canvas.getContext("2d");
backgroundImage.src = "images/Pages/help.png";
backgroundImage.onload = function() {
draw();
}
}
function backToMainMenu() {
if (mute === "no") {
var navBack_snd = new Audio("sounds/navigateBack.wav"); // buffers automatically when created
navBack_snd.play();
navBack_snd.onended = function() {
window.location = "menu.html";
};
} else {
window.location = "menu.html";
}
}
function addButton(x1, y1, x2, y2, callback) {
buttons.push({
x1: x1,
y1: y1,
x2: x2,
y2: y2,
callback: callback
});
}
function setButtons() {
var canvasWidth = window.innerWidth;
var canvasHeight = window.innerHeight;
addButton(132 / 1920 * canvasWidth, 110 / 1080 * canvasHeight, 413 / 1920 * canvasWidth, 193 / 1080 * canvasHeight, backToMainMenu);
}
function touches(evt) {
var x = evt.changedTouches[0].pageX;
var y = evt.changedTouches[0].pageY;
checkButtons(x, y);
}
// function clicks(evt) {
//var x = evt.clientX;
//var y = evt.clientY;
//checkButtons(x, y);
//}
function checkButtons(x, y) {
for (var i = 0; i < buttons.length; i++) {
var b = buttons[i];
if (x > b.x1 && x < b.x2 && y > b.y1 && y < b.y2) {
b.callback();
}
}
}
function init() {
loadBackgroundImage();
setButtons();
window.addEventListener('touchstart', touches);
// window.addEventListener('click', clicks);
}
</script>
</body>
</html>