Spaces:
Running
Running
Upload 15 files
Browse files- .gitattributes +1 -0
- build/assets/index-5e419aca.js +0 -0
- build/assets/index-d2d2c12a.css +1 -0
- build/coi-serviceworker.min.js +2 -0
- build/game/coi-serviceworker.min.js +2 -0
- build/game/game.audio.worklet.js +213 -0
- build/game/game.html +264 -0
- build/game/game.js +0 -0
- build/game/game.pck +3 -0
- build/game/game.png +0 -0
- build/game/game.side.wasm +3 -0
- build/game/game.wasm +3 -0
- build/game/game.worker.js +163 -0
- build/img/godot.png +0 -0
- build/index.html +16 -0
- build/vite.svg +1 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
build/game/game.pck filter=lfs diff=lfs merge=lfs -text
|
build/assets/index-5e419aca.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
build/assets/index-d2d2c12a.css
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
#root{max-width:1280px;width:100vw;margin:0 auto;padding:2rem;text-align:center}.logo{height:6em;padding:1.5em;will-change:filter;transition:filter .3s}.logo:hover{filter:drop-shadow(0 0 2em #646cffaa)}.logo.react:hover{filter:drop-shadow(0 0 2em #61dafbaa)}#godot-game{width:100%;height:auto;aspect-ratio:3/2;max-width:100%;max-height:100%;object-fit:contain}.card{padding:2em}.read-the-docs{color:#888}:root{font-family:Inter,system-ui,Avenir,Helvetica,Arial,sans-serif;line-height:1.5;font-weight:400;color-scheme:light dark;color:#ffffffde;background-color:#242424;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}a{font-weight:500;color:#646cff;text-decoration:inherit}a:hover{color:#535bf2}body{margin:0;display:flex;place-items:center;min-width:320px;min-height:100vh}h1{font-size:3.2em;line-height:1.1}button{border-radius:8px;border:1px solid transparent;padding:.6em 1.2em;font-size:1em;font-weight:500;font-family:inherit;background-color:#1a1a1a;cursor:pointer;transition:border-color .25s}button:hover{border-color:#646cff}button:focus,button:focus-visible{outline:4px auto -webkit-focus-ring-color}@media (prefers-color-scheme: light){:root{color:#213547;background-color:#fff}a:hover{color:#747bff}button{background-color:#f9f9f9}}
|
build/coi-serviceworker.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
/*! coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */
|
2 |
+
"undefined"==typeof window?(self.addEventListener("install",(()=>self.skipWaiting())),self.addEventListener("activate",(e=>e.waitUntil(self.clients.claim()))),self.addEventListener("message",(e=>{e.data&&"deregister"===e.data.type&&self.registration.unregister().then((()=>self.clients.matchAll())).then((e=>{e.forEach((e=>e.navigate(e.url)))}))})),self.addEventListener("fetch",(function(e){"only-if-cached"===e.request.cache&&"same-origin"!==e.request.mode||e.respondWith(fetch(e.request).then((e=>{if(0===e.status)return e;const r=new Headers(e.headers);return r.set("Cross-Origin-Embedder-Policy","require-corp"),r.set("Cross-Origin-Opener-Policy","same-origin"),new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})})).catch((e=>console.error(e))))}))):(()=>{const e={shouldRegister:()=>!0,shouldDeregister:()=>!1,doReload:()=>window.location.reload(),quiet:!1,...window.coi},r=navigator;e.shouldDeregister()&&r.serviceWorker&&r.serviceWorker.controller&&r.serviceWorker.controller.postMessage({type:"deregister"}),!1===window.crossOriginIsolated&&e.shouldRegister()&&(window.isSecureContext?r.serviceWorker&&r.serviceWorker.register(window.document.currentScript.src).then((t=>{!e.quiet&&console.log("COOP/COEP Service Worker registered",t.scope),t.addEventListener("updatefound",(()=>{!e.quiet&&console.log("Reloading page to make use of updated COOP/COEP Service Worker."),e.doReload()})),t.active&&!r.serviceWorker.controller&&(!e.quiet&&console.log("Reloading page to make use of COOP/COEP Service Worker."),e.doReload())}),(r=>{!e.quiet&&console.error("COOP/COEP Service Worker failed to register:",r)})):!e.quiet&&console.log("COOP/COEP Service Worker not registered, a secure context is required."))})();
|
build/game/coi-serviceworker.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
/*! coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */
|
2 |
+
"undefined"==typeof window?(self.addEventListener("install",(()=>self.skipWaiting())),self.addEventListener("activate",(e=>e.waitUntil(self.clients.claim()))),self.addEventListener("message",(e=>{e.data&&"deregister"===e.data.type&&self.registration.unregister().then((()=>self.clients.matchAll())).then((e=>{e.forEach((e=>e.navigate(e.url)))}))})),self.addEventListener("fetch",(function(e){"only-if-cached"===e.request.cache&&"same-origin"!==e.request.mode||e.respondWith(fetch(e.request).then((e=>{if(0===e.status)return e;const r=new Headers(e.headers);return r.set("Cross-Origin-Embedder-Policy","require-corp"),r.set("Cross-Origin-Opener-Policy","same-origin"),new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})})).catch((e=>console.error(e))))}))):(()=>{const e={shouldRegister:()=>!0,shouldDeregister:()=>!1,doReload:()=>window.location.reload(),quiet:!1,...window.coi},r=navigator;e.shouldDeregister()&&r.serviceWorker&&r.serviceWorker.controller&&r.serviceWorker.controller.postMessage({type:"deregister"}),!1===window.crossOriginIsolated&&e.shouldRegister()&&(window.isSecureContext?r.serviceWorker&&r.serviceWorker.register(window.document.currentScript.src).then((t=>{!e.quiet&&console.log("COOP/COEP Service Worker registered",t.scope),t.addEventListener("updatefound",(()=>{!e.quiet&&console.log("Reloading page to make use of updated COOP/COEP Service Worker."),e.doReload()})),t.active&&!r.serviceWorker.controller&&(!e.quiet&&console.log("Reloading page to make use of COOP/COEP Service Worker."),e.doReload())}),(r=>{!e.quiet&&console.error("COOP/COEP Service Worker failed to register:",r)})):!e.quiet&&console.log("COOP/COEP Service Worker not registered, a secure context is required."))})();
|
build/game/game.audio.worklet.js
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**************************************************************************/
|
2 |
+
/* audio.worklet.js */
|
3 |
+
/**************************************************************************/
|
4 |
+
/* This file is part of: */
|
5 |
+
/* GODOT ENGINE */
|
6 |
+
/* https://godotengine.org */
|
7 |
+
/**************************************************************************/
|
8 |
+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
9 |
+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
10 |
+
/* */
|
11 |
+
/* Permission is hereby granted, free of charge, to any person obtaining */
|
12 |
+
/* a copy of this software and associated documentation files (the */
|
13 |
+
/* "Software"), to deal in the Software without restriction, including */
|
14 |
+
/* without limitation the rights to use, copy, modify, merge, publish, */
|
15 |
+
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
16 |
+
/* permit persons to whom the Software is furnished to do so, subject to */
|
17 |
+
/* the following conditions: */
|
18 |
+
/* */
|
19 |
+
/* The above copyright notice and this permission notice shall be */
|
20 |
+
/* included in all copies or substantial portions of the Software. */
|
21 |
+
/* */
|
22 |
+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
23 |
+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
24 |
+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
25 |
+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
26 |
+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
27 |
+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
28 |
+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
29 |
+
/**************************************************************************/
|
30 |
+
|
31 |
+
class RingBuffer {
|
32 |
+
constructor(p_buffer, p_state, p_threads) {
|
33 |
+
this.buffer = p_buffer;
|
34 |
+
this.avail = p_state;
|
35 |
+
this.threads = p_threads;
|
36 |
+
this.rpos = 0;
|
37 |
+
this.wpos = 0;
|
38 |
+
}
|
39 |
+
|
40 |
+
data_left() {
|
41 |
+
return this.threads ? Atomics.load(this.avail, 0) : this.avail;
|
42 |
+
}
|
43 |
+
|
44 |
+
space_left() {
|
45 |
+
return this.buffer.length - this.data_left();
|
46 |
+
}
|
47 |
+
|
48 |
+
read(output) {
|
49 |
+
const size = this.buffer.length;
|
50 |
+
let from = 0;
|
51 |
+
let to_write = output.length;
|
52 |
+
if (this.rpos + to_write > size) {
|
53 |
+
const high = size - this.rpos;
|
54 |
+
output.set(this.buffer.subarray(this.rpos, size));
|
55 |
+
from = high;
|
56 |
+
to_write -= high;
|
57 |
+
this.rpos = 0;
|
58 |
+
}
|
59 |
+
if (to_write) {
|
60 |
+
output.set(this.buffer.subarray(this.rpos, this.rpos + to_write), from);
|
61 |
+
}
|
62 |
+
this.rpos += to_write;
|
63 |
+
if (this.threads) {
|
64 |
+
Atomics.add(this.avail, 0, -output.length);
|
65 |
+
Atomics.notify(this.avail, 0);
|
66 |
+
} else {
|
67 |
+
this.avail -= output.length;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
write(p_buffer) {
|
72 |
+
const to_write = p_buffer.length;
|
73 |
+
const mw = this.buffer.length - this.wpos;
|
74 |
+
if (mw >= to_write) {
|
75 |
+
this.buffer.set(p_buffer, this.wpos);
|
76 |
+
this.wpos += to_write;
|
77 |
+
if (mw === to_write) {
|
78 |
+
this.wpos = 0;
|
79 |
+
}
|
80 |
+
} else {
|
81 |
+
const high = p_buffer.subarray(0, mw);
|
82 |
+
const low = p_buffer.subarray(mw);
|
83 |
+
this.buffer.set(high, this.wpos);
|
84 |
+
this.buffer.set(low);
|
85 |
+
this.wpos = low.length;
|
86 |
+
}
|
87 |
+
if (this.threads) {
|
88 |
+
Atomics.add(this.avail, 0, to_write);
|
89 |
+
Atomics.notify(this.avail, 0);
|
90 |
+
} else {
|
91 |
+
this.avail += to_write;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
class GodotProcessor extends AudioWorkletProcessor {
|
97 |
+
constructor() {
|
98 |
+
super();
|
99 |
+
this.threads = false;
|
100 |
+
this.running = true;
|
101 |
+
this.lock = null;
|
102 |
+
this.notifier = null;
|
103 |
+
this.output = null;
|
104 |
+
this.output_buffer = new Float32Array();
|
105 |
+
this.input = null;
|
106 |
+
this.input_buffer = new Float32Array();
|
107 |
+
this.port.onmessage = (event) => {
|
108 |
+
const cmd = event.data['cmd'];
|
109 |
+
const data = event.data['data'];
|
110 |
+
this.parse_message(cmd, data);
|
111 |
+
};
|
112 |
+
}
|
113 |
+
|
114 |
+
process_notify() {
|
115 |
+
if (this.notifier) {
|
116 |
+
Atomics.add(this.notifier, 0, 1);
|
117 |
+
Atomics.notify(this.notifier, 0);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
parse_message(p_cmd, p_data) {
|
122 |
+
if (p_cmd === 'start' && p_data) {
|
123 |
+
const state = p_data[0];
|
124 |
+
let idx = 0;
|
125 |
+
this.threads = true;
|
126 |
+
this.lock = state.subarray(idx, ++idx);
|
127 |
+
this.notifier = state.subarray(idx, ++idx);
|
128 |
+
const avail_in = state.subarray(idx, ++idx);
|
129 |
+
const avail_out = state.subarray(idx, ++idx);
|
130 |
+
this.input = new RingBuffer(p_data[1], avail_in, true);
|
131 |
+
this.output = new RingBuffer(p_data[2], avail_out, true);
|
132 |
+
} else if (p_cmd === 'stop') {
|
133 |
+
this.running = false;
|
134 |
+
this.output = null;
|
135 |
+
this.input = null;
|
136 |
+
this.lock = null;
|
137 |
+
this.notifier = null;
|
138 |
+
} else if (p_cmd === 'start_nothreads') {
|
139 |
+
this.output = new RingBuffer(p_data[0], p_data[0].length, false);
|
140 |
+
} else if (p_cmd === 'chunk') {
|
141 |
+
this.output.write(p_data);
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
static array_has_data(arr) {
|
146 |
+
return arr.length && arr[0].length && arr[0][0].length;
|
147 |
+
}
|
148 |
+
|
149 |
+
process(inputs, outputs, parameters) {
|
150 |
+
if (!this.running) {
|
151 |
+
return false; // Stop processing.
|
152 |
+
}
|
153 |
+
if (this.output === null) {
|
154 |
+
return true; // Not ready yet, keep processing.
|
155 |
+
}
|
156 |
+
const process_input = GodotProcessor.array_has_data(inputs);
|
157 |
+
if (process_input) {
|
158 |
+
const input = inputs[0];
|
159 |
+
const chunk = input[0].length * input.length;
|
160 |
+
if (this.input_buffer.length !== chunk) {
|
161 |
+
this.input_buffer = new Float32Array(chunk);
|
162 |
+
}
|
163 |
+
if (!this.threads) {
|
164 |
+
GodotProcessor.write_input(this.input_buffer, input);
|
165 |
+
this.port.postMessage({ 'cmd': 'input', 'data': this.input_buffer });
|
166 |
+
} else if (this.input.space_left() >= chunk) {
|
167 |
+
GodotProcessor.write_input(this.input_buffer, input);
|
168 |
+
this.input.write(this.input_buffer);
|
169 |
+
} else {
|
170 |
+
this.port.postMessage('Input buffer is full! Skipping input frame.');
|
171 |
+
}
|
172 |
+
}
|
173 |
+
const process_output = GodotProcessor.array_has_data(outputs);
|
174 |
+
if (process_output) {
|
175 |
+
const output = outputs[0];
|
176 |
+
const chunk = output[0].length * output.length;
|
177 |
+
if (this.output_buffer.length !== chunk) {
|
178 |
+
this.output_buffer = new Float32Array(chunk);
|
179 |
+
}
|
180 |
+
if (this.output.data_left() >= chunk) {
|
181 |
+
this.output.read(this.output_buffer);
|
182 |
+
GodotProcessor.write_output(output, this.output_buffer);
|
183 |
+
if (!this.threads) {
|
184 |
+
this.port.postMessage({ 'cmd': 'read', 'data': chunk });
|
185 |
+
}
|
186 |
+
} else {
|
187 |
+
this.port.postMessage('Output buffer has not enough frames! Skipping output frame.');
|
188 |
+
}
|
189 |
+
}
|
190 |
+
this.process_notify();
|
191 |
+
return true;
|
192 |
+
}
|
193 |
+
|
194 |
+
static write_output(dest, source) {
|
195 |
+
const channels = dest.length;
|
196 |
+
for (let ch = 0; ch < channels; ch++) {
|
197 |
+
for (let sample = 0; sample < dest[ch].length; sample++) {
|
198 |
+
dest[ch][sample] = source[sample * channels + ch];
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
static write_input(dest, source) {
|
204 |
+
const channels = source.length;
|
205 |
+
for (let ch = 0; ch < channels; ch++) {
|
206 |
+
for (let sample = 0; sample < source[ch].length; sample++) {
|
207 |
+
dest[sample * channels + ch] = source[ch][sample];
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
registerProcessor('godot-processor', GodotProcessor);
|
build/game/game.html
ADDED
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="utf-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, user-scalable=no" />
|
6 |
+
<title>HackerGPT</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
touch-action: none;
|
10 |
+
margin: 0;
|
11 |
+
border: 0 none;
|
12 |
+
padding: 0;
|
13 |
+
text-align: center;
|
14 |
+
background-color: black;
|
15 |
+
}
|
16 |
+
|
17 |
+
#canvas {
|
18 |
+
display: block;
|
19 |
+
margin: 0;
|
20 |
+
color: white;
|
21 |
+
}
|
22 |
+
|
23 |
+
#canvas:focus {
|
24 |
+
outline: none;
|
25 |
+
}
|
26 |
+
|
27 |
+
.godot {
|
28 |
+
font-family: "Noto Sans", "Droid Sans", Arial, sans-serif;
|
29 |
+
color: #e0e0e0;
|
30 |
+
background-color: #3b3943;
|
31 |
+
background-image: linear-gradient(to bottom, #403e48, #35333c);
|
32 |
+
border: 1px solid #45434e;
|
33 |
+
box-shadow: 0 0 1px 1px #2f2d35;
|
34 |
+
}
|
35 |
+
|
36 |
+
/* Status display */
|
37 |
+
|
38 |
+
#status {
|
39 |
+
position: absolute;
|
40 |
+
left: 0;
|
41 |
+
top: 0;
|
42 |
+
right: 0;
|
43 |
+
bottom: 0;
|
44 |
+
display: flex;
|
45 |
+
justify-content: center;
|
46 |
+
align-items: center;
|
47 |
+
/* don't consume click events - make children visible explicitly */
|
48 |
+
visibility: hidden;
|
49 |
+
}
|
50 |
+
|
51 |
+
#status-progress {
|
52 |
+
width: 366px;
|
53 |
+
height: 7px;
|
54 |
+
background-color: #38363a;
|
55 |
+
border: 1px solid #444246;
|
56 |
+
padding: 1px;
|
57 |
+
box-shadow: 0 0 2px 1px #1b1c22;
|
58 |
+
border-radius: 2px;
|
59 |
+
visibility: visible;
|
60 |
+
}
|
61 |
+
|
62 |
+
@media only screen and (orientation: portrait) {
|
63 |
+
#status-progress {
|
64 |
+
width: 61.8%;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
#status-progress-inner {
|
69 |
+
height: 100%;
|
70 |
+
width: 0;
|
71 |
+
box-sizing: border-box;
|
72 |
+
transition: width 0.5s linear;
|
73 |
+
background-color: #202020;
|
74 |
+
border: 1px solid #222223;
|
75 |
+
box-shadow: 0 0 1px 1px #27282e;
|
76 |
+
border-radius: 3px;
|
77 |
+
}
|
78 |
+
|
79 |
+
#status-indeterminate {
|
80 |
+
height: 42px;
|
81 |
+
visibility: visible;
|
82 |
+
position: relative;
|
83 |
+
}
|
84 |
+
|
85 |
+
#status-indeterminate > div {
|
86 |
+
width: 4.5px;
|
87 |
+
height: 0;
|
88 |
+
border-style: solid;
|
89 |
+
border-width: 9px 3px 0 3px;
|
90 |
+
border-color: #2b2b2b transparent transparent transparent;
|
91 |
+
transform-origin: center 21px;
|
92 |
+
position: absolute;
|
93 |
+
}
|
94 |
+
|
95 |
+
#status-indeterminate > div:nth-child(1) {
|
96 |
+
transform: rotate(22.5deg);
|
97 |
+
}
|
98 |
+
#status-indeterminate > div:nth-child(2) {
|
99 |
+
transform: rotate(67.5deg);
|
100 |
+
}
|
101 |
+
#status-indeterminate > div:nth-child(3) {
|
102 |
+
transform: rotate(112.5deg);
|
103 |
+
}
|
104 |
+
#status-indeterminate > div:nth-child(4) {
|
105 |
+
transform: rotate(157.5deg);
|
106 |
+
}
|
107 |
+
#status-indeterminate > div:nth-child(5) {
|
108 |
+
transform: rotate(202.5deg);
|
109 |
+
}
|
110 |
+
#status-indeterminate > div:nth-child(6) {
|
111 |
+
transform: rotate(247.5deg);
|
112 |
+
}
|
113 |
+
#status-indeterminate > div:nth-child(7) {
|
114 |
+
transform: rotate(292.5deg);
|
115 |
+
}
|
116 |
+
#status-indeterminate > div:nth-child(8) {
|
117 |
+
transform: rotate(337.5deg);
|
118 |
+
}
|
119 |
+
|
120 |
+
#status-notice {
|
121 |
+
margin: 0 100px;
|
122 |
+
line-height: 1.3;
|
123 |
+
visibility: visible;
|
124 |
+
padding: 4px 6px;
|
125 |
+
visibility: visible;
|
126 |
+
}
|
127 |
+
</style>
|
128 |
+
|
129 |
+
</head>
|
130 |
+
<body>
|
131 |
+
<canvas id="canvas">
|
132 |
+
HTML5 canvas appears to be unsupported in the current browser.<br />
|
133 |
+
Please try updating or use a different browser.
|
134 |
+
</canvas>
|
135 |
+
<div id="status">
|
136 |
+
<div id="status-progress" style="display: none" oncontextmenu="event.preventDefault();">
|
137 |
+
<div id="status-progress-inner"></div>
|
138 |
+
</div>
|
139 |
+
<div id="status-indeterminate" style="display: none" oncontextmenu="event.preventDefault();">
|
140 |
+
<div></div>
|
141 |
+
<div></div>
|
142 |
+
<div></div>
|
143 |
+
<div></div>
|
144 |
+
<div></div>
|
145 |
+
<div></div>
|
146 |
+
<div></div>
|
147 |
+
<div></div>
|
148 |
+
</div>
|
149 |
+
<div id="status-notice" class="godot" style="display: none"></div>
|
150 |
+
</div>
|
151 |
+
|
152 |
+
<script src="coi-serviceworker.min.js"></script><script src="game.js"></script>
|
153 |
+
<script>
|
154 |
+
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"game","experimentalVK":false,"fileSizes":{"game.pck":26233024,"game.wasm":2564551},"focusCanvas":true,"gdextensionLibs":[]};
|
155 |
+
const engine = new Engine(GODOT_CONFIG);
|
156 |
+
|
157 |
+
window.startGame = () => {
|
158 |
+
const INDETERMINATE_STATUS_STEP_MS = 100;
|
159 |
+
const statusProgress = document.getElementById("status-progress");
|
160 |
+
const statusProgressInner = document.getElementById("status-progress-inner");
|
161 |
+
const statusIndeterminate = document.getElementById("status-indeterminate");
|
162 |
+
const statusNotice = document.getElementById("status-notice");
|
163 |
+
|
164 |
+
let initializing = true;
|
165 |
+
let statusMode = "hidden";
|
166 |
+
|
167 |
+
let animationCallbacks = [];
|
168 |
+
const animate = (time) => {
|
169 |
+
animationCallbacks.forEach((callback) => callback(time));
|
170 |
+
requestAnimationFrame(animate);
|
171 |
+
};
|
172 |
+
requestAnimationFrame(animate);
|
173 |
+
|
174 |
+
const animateStatusIndeterminate = (ms) => {
|
175 |
+
const i = Math.floor((ms / INDETERMINATE_STATUS_STEP_MS) % 8);
|
176 |
+
if (statusIndeterminate.children[i].style.borderTopColor === "") {
|
177 |
+
Array.prototype.slice.call(statusIndeterminate.children).forEach((child) => {
|
178 |
+
child.style.borderTopColor = "";
|
179 |
+
});
|
180 |
+
statusIndeterminate.children[i].style.borderTopColor = "#dfdfdf";
|
181 |
+
}
|
182 |
+
};
|
183 |
+
|
184 |
+
const setStatusMode = (mode) => {
|
185 |
+
if (statusMode === mode || !initializing) {
|
186 |
+
return;
|
187 |
+
}
|
188 |
+
[statusProgress, statusIndeterminate, statusNotice].forEach((elem) => {
|
189 |
+
elem.style.display = "none";
|
190 |
+
});
|
191 |
+
animationCallbacks = animationCallbacks.filter((value) => {
|
192 |
+
return value !== animateStatusIndeterminate;
|
193 |
+
});
|
194 |
+
switch (mode) {
|
195 |
+
case "progress":
|
196 |
+
statusProgress.style.display = "block";
|
197 |
+
break;
|
198 |
+
case "indeterminate":
|
199 |
+
statusIndeterminate.style.display = "block";
|
200 |
+
animationCallbacks.push(animateStatusIndeterminate);
|
201 |
+
break;
|
202 |
+
case "notice":
|
203 |
+
statusNotice.style.display = "block";
|
204 |
+
break;
|
205 |
+
case "hidden":
|
206 |
+
break;
|
207 |
+
default:
|
208 |
+
throw new Error("Invalid status mode");
|
209 |
+
}
|
210 |
+
statusMode = mode;
|
211 |
+
};
|
212 |
+
|
213 |
+
const setStatusNotice = (text) => {
|
214 |
+
while (statusNotice.lastChild) {
|
215 |
+
statusNotice.removeChild(statusNotice.lastChild);
|
216 |
+
}
|
217 |
+
const lines = text.split("\n");
|
218 |
+
lines.forEach((line) => {
|
219 |
+
statusNotice.appendChild(document.createTextNode(line));
|
220 |
+
statusNotice.appendChild(document.createElement("br"));
|
221 |
+
});
|
222 |
+
};
|
223 |
+
|
224 |
+
const displayFailureNotice = (err) => {
|
225 |
+
const msg = err.message || err;
|
226 |
+
console.error(msg);
|
227 |
+
setStatusNotice(msg);
|
228 |
+
setStatusMode("notice");
|
229 |
+
initializing = false;
|
230 |
+
};
|
231 |
+
|
232 |
+
const missing = Engine.getMissingFeatures();
|
233 |
+
if (missing.length !== 0) {
|
234 |
+
const missingMsg = "Error\nThe following features required to run Godot projects on the Web are missing:\n";
|
235 |
+
displayFailureNotice(missingMsg + missing.join("\n"));
|
236 |
+
} else {
|
237 |
+
setStatusMode("indeterminate");
|
238 |
+
engine
|
239 |
+
.startGame({
|
240 |
+
onProgress: (current, total) => {
|
241 |
+
if (total > 0) {
|
242 |
+
statusProgressInner.style.width = `${(current / total) * 100}%`;
|
243 |
+
setStatusMode("progress");
|
244 |
+
if (current === total) {
|
245 |
+
// wait for progress bar animation
|
246 |
+
setTimeout(() => {
|
247 |
+
setStatusMode("indeterminate");
|
248 |
+
}, 500);
|
249 |
+
}
|
250 |
+
} else {
|
251 |
+
setStatusMode("indeterminate");
|
252 |
+
}
|
253 |
+
},
|
254 |
+
})
|
255 |
+
.then(() => {
|
256 |
+
setStatusMode("hidden");
|
257 |
+
initializing = false;
|
258 |
+
}, displayFailureNotice);
|
259 |
+
}
|
260 |
+
};
|
261 |
+
</script>
|
262 |
+
</body>
|
263 |
+
</html>
|
264 |
+
|
build/game/game.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
build/game/game.pck
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3b7ff60713aa98fc3d2c7d4e3d95ccaa84af54cf2f01b436b0682bc30ffa5046
|
3 |
+
size 26233024
|
build/game/game.png
ADDED
build/game/game.side.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1e00b9534cfc8b85103b826aa02742d55d916d0a4fda2240e31ebf3cb8a28fe1
|
3 |
+
size 51996894
|
build/game/game.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2274ad22786be9da2997b7c2a394a4b0fcdcb33787063dd5ad1ee55e1e2745da
|
3 |
+
size 2564551
|
build/game/game.worker.js
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @license
|
3 |
+
* Copyright 2015 The Emscripten Authors
|
4 |
+
* SPDX-License-Identifier: MIT
|
5 |
+
*/
|
6 |
+
|
7 |
+
// Pthread Web Worker startup routine:
|
8 |
+
// This is the entry point file that is loaded first by each Web Worker
|
9 |
+
// that executes pthreads on the Emscripten application.
|
10 |
+
|
11 |
+
'use strict';
|
12 |
+
|
13 |
+
var Module = {};
|
14 |
+
|
15 |
+
// Thread-local guard variable for one-time init of the JS state
|
16 |
+
var initializedJS = false;
|
17 |
+
|
18 |
+
// Proxying queues that were notified before the thread started and need to be
|
19 |
+
// executed as part of startup.
|
20 |
+
var pendingNotifiedProxyingQueues = [];
|
21 |
+
|
22 |
+
function assert(condition, text) {
|
23 |
+
if (!condition) abort('Assertion failed: ' + text);
|
24 |
+
}
|
25 |
+
|
26 |
+
function threadPrintErr() {
|
27 |
+
var text = Array.prototype.slice.call(arguments).join(' ');
|
28 |
+
console.error(text);
|
29 |
+
}
|
30 |
+
function threadAlert() {
|
31 |
+
var text = Array.prototype.slice.call(arguments).join(' ');
|
32 |
+
postMessage({cmd: 'alert', text: text, threadId: Module['_pthread_self']()});
|
33 |
+
}
|
34 |
+
// We don't need out() for now, but may need to add it if we want to use it
|
35 |
+
// here. Or, if this code all moves into the main JS, that problem will go
|
36 |
+
// away. (For now, adding it here increases code size for no benefit.)
|
37 |
+
var out = () => { throw 'out() is not defined in worker.js.'; }
|
38 |
+
var err = threadPrintErr;
|
39 |
+
self.alert = threadAlert;
|
40 |
+
|
41 |
+
Module['instantiateWasm'] = (info, receiveInstance) => {
|
42 |
+
// Instantiate from the module posted from the main thread.
|
43 |
+
// We can just use sync instantiation in the worker.
|
44 |
+
var instance = new WebAssembly.Instance(Module['wasmModule'], info);
|
45 |
+
receiveInstance(instance, Module['wasmModule']);
|
46 |
+
// We don't need the module anymore; new threads will be spawned from the main thread.
|
47 |
+
Module['wasmModule'] = null;
|
48 |
+
return instance.exports;
|
49 |
+
}
|
50 |
+
|
51 |
+
self.onmessage = (e) => {
|
52 |
+
try {
|
53 |
+
if (e.data.cmd === 'load') { // Preload command that is called once per worker to parse and load the Emscripten code.
|
54 |
+
|
55 |
+
// Module and memory were sent from main thread
|
56 |
+
Module['wasmModule'] = e.data.wasmModule;
|
57 |
+
|
58 |
+
Module['dynamicLibraries'] = e.data.dynamicLibraries;
|
59 |
+
|
60 |
+
Module['wasmMemory'] = e.data.wasmMemory;
|
61 |
+
|
62 |
+
Module['buffer'] = Module['wasmMemory'].buffer;
|
63 |
+
|
64 |
+
Module['ENVIRONMENT_IS_PTHREAD'] = true;
|
65 |
+
|
66 |
+
if (typeof e.data.urlOrBlob == 'string') {
|
67 |
+
importScripts(e.data.urlOrBlob);
|
68 |
+
} else {
|
69 |
+
var objectUrl = URL.createObjectURL(e.data.urlOrBlob);
|
70 |
+
importScripts(objectUrl);
|
71 |
+
URL.revokeObjectURL(objectUrl);
|
72 |
+
}
|
73 |
+
Godot(Module).then(function (instance) {
|
74 |
+
Module = instance;
|
75 |
+
});
|
76 |
+
} else if (e.data.cmd === 'run') {
|
77 |
+
// This worker was idle, and now should start executing its pthread entry
|
78 |
+
// point.
|
79 |
+
// performance.now() is specced to return a wallclock time in msecs since
|
80 |
+
// that Web Worker/main thread launched. However for pthreads this can
|
81 |
+
// cause subtle problems in emscripten_get_now() as this essentially
|
82 |
+
// would measure time from pthread_create(), meaning that the clocks
|
83 |
+
// between each threads would be wildly out of sync. Therefore sync all
|
84 |
+
// pthreads to the clock on the main browser thread, so that different
|
85 |
+
// threads see a somewhat coherent clock across each of them
|
86 |
+
// (+/- 0.1msecs in testing).
|
87 |
+
Module['__performance_now_clock_drift'] = performance.now() - e.data.time;
|
88 |
+
|
89 |
+
// Pass the thread address to wasm to store it for fast access.
|
90 |
+
Module['__emscripten_thread_init'](e.data.pthread_ptr, /*isMainBrowserThread=*/0, /*isMainRuntimeThread=*/0, /*canBlock=*/1);
|
91 |
+
|
92 |
+
assert(e.data.pthread_ptr);
|
93 |
+
// Also call inside JS module to set up the stack frame for this pthread in JS module scope
|
94 |
+
Module['establishStackSpace']();
|
95 |
+
Module['PThread'].receiveObjectTransfer(e.data);
|
96 |
+
Module['PThread'].threadInitTLS();
|
97 |
+
|
98 |
+
if (!initializedJS) {
|
99 |
+
|
100 |
+
// Execute any proxied work that came in before the thread was
|
101 |
+
// initialized. Only do this once because it is only possible for
|
102 |
+
// proxying notifications to arrive before thread initialization on
|
103 |
+
// fresh workers.
|
104 |
+
pendingNotifiedProxyingQueues.forEach(queue => {
|
105 |
+
Module['executeNotifiedProxyingQueue'](queue);
|
106 |
+
});
|
107 |
+
pendingNotifiedProxyingQueues = [];
|
108 |
+
initializedJS = true;
|
109 |
+
}
|
110 |
+
|
111 |
+
try {
|
112 |
+
Module['invokeEntryPoint'](e.data.start_routine, e.data.arg);
|
113 |
+
} catch(ex) {
|
114 |
+
if (ex != 'unwind') {
|
115 |
+
// ExitStatus not present in MINIMAL_RUNTIME
|
116 |
+
if (ex instanceof Module['ExitStatus']) {
|
117 |
+
if (Module['keepRuntimeAlive']()) {
|
118 |
+
err('Pthread 0x' + Module['_pthread_self']().toString(16) + ' called exit(), staying alive due to noExitRuntime.');
|
119 |
+
} else {
|
120 |
+
err('Pthread 0x' + Module['_pthread_self']().toString(16) + ' called exit(), calling _emscripten_thread_exit.');
|
121 |
+
Module['__emscripten_thread_exit'](ex.status);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
else
|
125 |
+
{
|
126 |
+
// The pthread "crashed". Do not call `_emscripten_thread_exit` (which
|
127 |
+
// would make this thread joinable. Instead, re-throw the exception
|
128 |
+
// and let the top level handler propagate it back to the main thread.
|
129 |
+
throw ex;
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
// else e == 'unwind', and we should fall through here and keep the pthread alive for asynchronous events.
|
133 |
+
err('Pthread 0x' + Module['_pthread_self']().toString(16) + ' completed its main entry point with an `unwind`, keeping the worker alive for asynchronous operation.');
|
134 |
+
}
|
135 |
+
}
|
136 |
+
} else if (e.data.cmd === 'cancel') { // Main thread is asking for a pthread_cancel() on this thread.
|
137 |
+
if (Module['_pthread_self']()) {
|
138 |
+
Module['__emscripten_thread_exit'](-1/*PTHREAD_CANCELED*/);
|
139 |
+
}
|
140 |
+
} else if (e.data.target === 'setimmediate') {
|
141 |
+
// no-op
|
142 |
+
} else if (e.data.cmd === 'processProxyingQueue') {
|
143 |
+
if (initializedJS) {
|
144 |
+
Module['executeNotifiedProxyingQueue'](e.data.queue);
|
145 |
+
} else {
|
146 |
+
// Defer executing this queue until the runtime is initialized.
|
147 |
+
pendingNotifiedProxyingQueues.push(e.data.queue);
|
148 |
+
}
|
149 |
+
} else {
|
150 |
+
err('worker.js received unknown command ' + e.data.cmd);
|
151 |
+
err(e.data);
|
152 |
+
}
|
153 |
+
} catch(ex) {
|
154 |
+
err('worker.js onmessage() captured an uncaught exception: ' + ex);
|
155 |
+
if (ex && ex.stack) err(ex.stack);
|
156 |
+
if (Module['__emscripten_thread_crashed']) {
|
157 |
+
Module['__emscripten_thread_crashed']();
|
158 |
+
}
|
159 |
+
throw ex;
|
160 |
+
}
|
161 |
+
};
|
162 |
+
|
163 |
+
|
build/img/godot.png
ADDED
build/index.html
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
+
<script src="/coi-serviceworker.min.js"></script>
|
8 |
+
<title>GenWorld</title>
|
9 |
+
<script type="module" crossorigin src="/assets/index-5e419aca.js"></script>
|
10 |
+
<link rel="stylesheet" href="/assets/index-d2d2c12a.css">
|
11 |
+
</head>
|
12 |
+
<body>
|
13 |
+
<div id="root"></div>
|
14 |
+
|
15 |
+
</body>
|
16 |
+
</html>
|
build/vite.svg
ADDED