forked from gamedevnull/asteroids
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
159 lines (142 loc) · 5.22 KB
/
index.html
File metadata and controls
159 lines (142 loc) · 5.22 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Asteroids Warpage</title>
<style>
body {
display: block;
margin: 0 auto;
justify-content: center;
align-items: center;
background-color: #151515;
touch-action: manipulation; /* disable double-tap to zoom */
}
canvas {
border: 1px solid #4a4a4a;
display: block;
margin: 50px auto 0;
}
@media (hover: none) and (pointer: coarse) {
canvas {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) scale(0.6);
transform-origin: center center;
margin: 20px auto;
}
}
#touch-controls {
position: fixed;
bottom: 10px;
width: 97%;
display: flex;
justify-content: space-between;
padding: 0 10px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#left-controls, #right-controls {
display: flex;
gap: 50px;
}
#touch-controls button {
width: 80px;
height: 80px;
font-size: 16px;
border: none;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.5);
color: white;
}
@media (hover: none) and (pointer: coarse) {
#touch-controls {
display: flex;
}
}
@media (hover: hover) and (pointer: fine) {
#touch-controls {
display: none;
}
}
#up-button {
position: fixed;
margin-top: -45px;
margin-left: 65px;
z-index: 1000;
}
#options-controls {
display: block;
width:800px;
margin:auto;
position:relative;
}
@media (hover: none) and (pointer: coarse) {
#options-controls {
display: flex;
width: 100%;
}
}
#options-controls #sound-toggle-icon {
position: absolute;
top: 5px;
right: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div id="options-controls">
<svg id="sound-toggle-icon" style="color: beige; cursor: pointer;" width="24" height="24" viewBox="0 0 24 24" >
<svg id="sound-off" style="display: none;" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-volume-mute" viewBox="0 0 16 16">
<path d="M6.717 3.55A.5.5 0 0 1 7 4v8a.5.5 0 0 1-.812.39L3.825 10.5H1.5A.5.5 0 0 1 1 10V6a.5.5 0 0 1 .5-.5h2.325l2.363-1.89a.5.5 0 0 1 .529-.06M6 5.04 4.312 6.39A.5.5 0 0 1 4 6.5H2v3h2a.5.5 0 0 1 .312.11L6 10.96zm7.854.606a.5.5 0 0 1 0 .708L12.207 8l1.647 1.646a.5.5 0 0 1-.708.708L11.5 8.707l-1.646 1.647a.5.5 0 0 1-.708-.708L10.793 8 9.146 6.354a.5.5 0 1 1 .708-.708L11.5 7.293l1.646-1.647a.5.5 0 0 1 .708 0"/>
</svg>
<svg id="sound-on" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-volume-up" viewBox="0 0 16 16">
<path d="M11.536 14.01A8.47 8.47 0 0 0 14.026 8a8.47 8.47 0 0 0-2.49-6.01l-.708.707A7.48 7.48 0 0 1 13.025 8c0 2.071-.84 3.946-2.197 5.303z"/>
<path d="M10.121 12.596A6.48 6.48 0 0 0 12.025 8a6.48 6.48 0 0 0-1.904-4.596l-.707.707A5.48 5.48 0 0 1 11.025 8a5.48 5.48 0 0 1-1.61 3.89z"/>
<path d="M10.025 8a4.5 4.5 0 0 1-1.318 3.182L8 10.475A3.5 3.5 0 0 0 9.025 8c0-.966-.392-1.841-1.025-2.475l.707-.707A4.5 4.5 0 0 1 10.025 8M7 4a.5.5 0 0 0-.812-.39L3.825 5.5H1.5A.5.5 0 0 0 1 6v4a.5.5 0 0 0 .5.5h2.325l2.363 1.89A.5.5 0 0 0 7 12zM4.312 6.39 6 5.04v5.92L4.312 9.61A.5.5 0 0 0 4 9.5H2v-3h2a.5.5 0 0 0 .312-.11"/>
</svg>
</svg>
</div>
<canvas id="gameCanvas" width="800" height="600"></canvas>
<div id="touch-controls">
<div id="left-controls">
<button id="shoot-button">
<svg width="24" height="24" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="10" fill="white"/>
</svg>
</button>
</div>
<div id="right-controls">
<button id="left-button">
<svg width="24" height="24" viewBox="0 0 24 24">
<polygon points="22,2 2,12 22,22" fill="white"/>
</svg>
</button>
<button id="up-button">
<svg width="24" height="24" viewBox="0 0 24 24">
<polygon points="12,2 22,22 2,22" fill="white"/>
</svg>
</button>
<button id="right-button">
<svg width="24" height="24" viewBox="0 0 24 24">
<polygon points="2,2 22,12 2,22" fill="white"/>
</svg>
</button>
</div>
</div>
<script type="module" src="dist/main.js"></script>
<script>
// prevent default touch actions
document.addEventListener('touchstart', function (event) {
event.preventDefault();
}, {passive: false});
</script>
<script>
</script>
</body>
</html>