-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
196 lines (171 loc) · 6.21 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>LimitPush</title> <!-- BRANDING: Change according to your project! -->
<link rel="icon" href="icon.ico">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap" rel="stylesheet">
<style>
body,
html {
height: 100%;
margin: 0;
font-family: 'Poppins', sans-serif;
color: white;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
background: linear-gradient(120deg, #1e1e2f, #4a4a6a);
}
.launching-container {
text-align: center;
opacity: 1;
transition: opacity 1s ease-out;
position: absolute;
z-index: 2;
}
.title {
font-size: 2rem;
font-weight: 700;
margin-bottom: 10px;
}
.subtitle {
font-size: 1.2rem;
color: #d1d1f0;
margin-bottom: 20px;
}
.lds-dual-ring {
display: inline-block;
width: 80px;
height: 80px;
margin: 20px 0;
}
.lds-dual-ring:after {
content: " ";
display: block;
width: 64px;
height: 64px;
border-radius: 50%;
border: 6px solid #fff;
border-color: #fff transparent #fff transparent;
animation: spin 1.2s linear infinite;
}
.game-container {
display: none;
width: 100vw;
height: 100vh;
justify-content: center;
align-items: center;
background: black;
opacity: 0;
animation: fadeIn 1s ease-in-out;
animation-fill-mode: forwards;
}
#bevy {
width: 100%;
height: 100%;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div class="launching-container">
<div class="title">Launching...</div> <!-- BRANDING: Change if you want to! -->
<div class="subtitle">Pushing the bevy boundaries!</div> <!-- BRANDING: Change if you want to! -->
<div class="lds-dual-ring"></div>
</div>
<div class="game-container">
<canvas id="bevy">Javascript and support for canvas is required</canvas>
</div>
<script>
window.addEventListener('load', () => {
const loadingContainer = document.querySelector('.launching-container');
const gameContainer = document.querySelector('.game-container');
const bevyCanvas = document.getElementById('bevy');
const observer = new MutationObserver(() => {
if (bevyCanvas.height > 1) {
setTimeout(() => {
loadingContainer.style.display = 'none';
gameContainer.style.display = 'flex';
}, 1000);
observer.disconnect();
}
});
observer.observe(bevyCanvas, { attributes: true, attributeFilter: ['height'] });
});
// Insert hack to make sound autoplay on Chrome as soon as the user interacts with the tab:
// https://developers.google.com/web/updates/2018/11/web-audio-autoplay#moving-forward
// the following function keeps track of all AudioContexts and resumes them on the first user
// interaction with the page. If the function is called and all contexts are already running,
// it will remove itself from all event listeners.
// [ ] Check if this even works and is useful!
(function () {
// An array of all contexts to resume on the page
const audioContextList = [];
// An array of various user interaction events we should listen for
const userInputEventNames = [
"click",
"contextmenu",
"auxclick",
"dblclick",
"mousedown",
"mouseup",
"pointerup",
"touchend",
"keydown",
"keyup",
];
// A proxy object to intercept AudioContexts and
// add them to the array for tracking and resuming later
self.AudioContext = new Proxy(self.AudioContext, {
construct(target, args) {
const result = new target(...args);
audioContextList.push(result);
return result;
},
});
// To resume all AudioContexts being tracked
function resumeAllContexts(_event) {
let count = 0;
audioContextList.forEach((context) => {
if (context.state !== "running") {
context.resume();
} else {
count++;
}
});
// If all the AudioContexts have now resumed then we unbind all
// the event listeners from the page to prevent unnecessary resume attempts
// Checking count > 0 ensures that the user interaction happens AFTER the game started up
if (count > 0 && count === audioContextList.length) {
userInputEventNames.forEach((eventName) => {
document.removeEventListener(eventName, resumeAllContexts);
});
}
}
// We bind the resume function for each user interaction
// event on the page
userInputEventNames.forEach((eventName) => {
document.addEventListener(eventName, resumeAllContexts);
});
})();
</script>
</body>
</html>