-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathindex.html
47 lines (46 loc) · 2.11 KB
/
index.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
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title> The melon man </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="game">
<canvas id="canvas"></canvas>
<div class="mobileControls">
<button class="mobileControls__button" onmousedown="game.moveLeft()" ontouchstart="game.moveLeft()" onmouseup="clearInterval(game.player.moveLeftInterval" ontouchend="clearInterval(game.player.moveInterval)">Left</button>
<button class="mobileControls__button" onmousedown="game.moveRight()" ontouchstart="game.moveRight()" onmouseup="clearInterval(game.player.moveRightInterval)" ontouchend="clearInterval(game.player.moveInterval)">Right</button>
<button class="mobileControls__button" onmousedown="game.player.jump()" ontouchstart="game.player.jump()">Jump</button>
</div>
<p class="counter" id="counter">A game by Karol Swierczek | Controls: W, D / arrows and SPACE | Points: 0</p>
</div>
<script src="js/index.js"></script>
<script src="js/player.js"></script>
<script src="js/keyboard.js"></script>
<script src="js/drawing.js"></script>
<script src="js/generator.js"></script>
<script src="js/collisionDetection.js"></script>
<script>
// Event listeners
document.addEventListener("keydown", game.keydown.bind(game), false)
document.addEventListener("keyup", game.keyup.bind(game), false)
document.body.onresize = function () {
game.options.canvasWidth = window.innerWidth / 3,
game.options.canvasHeight = window.innerHeight / 3
game.canvas.width = game.options.canvasWidth
game.canvas.height = game.options.canvasHeight
game.requestRedraw()
}
game.init(function () {
game.generateMap()
game.requestRedraw()
})
</script>
<audio controls loop autoplay hidden>
<source src="sounds/music.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>