-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
74 lines (62 loc) · 2.19 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Snack</title>
<style>
body {
display: grid;
grid-template-columns: auto auto auto;
}
#tela {
width: 400px;
height: 400px;
border: 10px solid black;
image-rendering: crisp-edges;
image-rendering: pixelated;
image-rendering: -woz-crisp-edges;
}
p {
font-size: 20px
}
</style>
</head>
<body>
<span></span>
<canvas id='tela' width="20" height="20"></canvas>
<div id="scores">
<h1 id="score"></h1>
<h1 id="best-score"></h1>
<p>Obs: a fruta pode aparecer em qualquer lugar, <br> incluse no corpo da cobra!</p>
<p id="pHard"></p>
<h2>Modos</h2>
<div>
<button id="easy">Easy</button>
<button id="normal">Normal</button>
<button id="hard">Hard</button>
<button id="hardcore">Hard Core</button>
</div>
</div>
<script type="module">
import newEscutarTeclado from './input.js'
import newGame from './game.js'
import newRenderGame from './renderGame.js'
const tela = document.getElementById('tela')
const score = document.getElementById('score')
const bestScore = document.getElementById('best-score')
const paragraph = document.getElementById('pHard')
const escutarTeclado = newEscutarTeclado(document)
const game = newGame(tela)
escutarTeclado.subscribe(game.moveSnake)
const easy = document.getElementById('easy')
const normal = document.getElementById('normal')
const hard = document.getElementById('hard')
const hardcore = document.getElementById('hardcore')
easy.addEventListener('click', () => (game.endGame('easy')))
normal.addEventListener('click', () => (game.endGame('normal')))
hard.addEventListener('click', () => (game.endGame('hard')))
hardcore.addEventListener('click', () => (game.endGame('hardcore')))
const renderGame = newRenderGame (tela, game, score, bestScore, paragraph)
</script>
</body>
</html>