-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
67 lines (55 loc) · 1.51 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>JS13k Offline</title>
<style>
* { box-sizing: border-box; }
html { min-height: 100vh; }
body { margin: 0; }
.scene {
width: 100vw;
height: 100vh;
position: relative;
}
#gerard {
position: absolute;
width: 32px;
height: 32px;
background-color: orange;
z-index: 3;
}
</style>
</head>
<body>
<div class="scene">
<div id="gerard"></div>
</div>
<script type="module">
import { Cube } from './cube.js'
const tower = new Cube({ width: 1000, height: 1000, y: 0, x: '200px', color: 'blue', zIndex: 1000 })
const platform = new Cube({ width: 100, height: 50, y: '100px', x: '100px', color: 'purple' })
tower.attachTo(platform, 3)
document.querySelector('.scene').appendChild(tower.element)
document.querySelector('.scene').appendChild(platform.element)
document.addEventListener('keydown', e => {
switch(e.key) {
case 'j': {
tower.rotateLeft()
break;
}
case 'k':
tower.rotateRight()
break;
}
})
import { Player } from './player.js'
const gerard = new Player()
const refreshRate = 1000/60
setInterval(() => {
gerard.move(refreshRate)
}, refreshRate)
</script>
</body>
</html>