wjump2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.audio.worklet.js +213 -0
- package/index.html +241 -0
- package/index.js +14532 -0
- package/index.pck +0 -0
- package/index.wasm +0 -0
- package/index.worker.js +164 -0
- package/package.json +20 -0
|
@@ -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);
|
package/index.html
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
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>Wrestle Jump 2</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: 10px;
|
|
54
|
+
background-color: #4c3d2e;
|
|
55
|
+
padding: 1px;
|
|
56
|
+
visibility: visible;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@media only screen and (orientation:portrait) {
|
|
60
|
+
#status-progress {
|
|
61
|
+
width: 61.8%;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#status-progress-inner {
|
|
66
|
+
height: 100%;
|
|
67
|
+
width: 0;
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
transition: width 0.5s linear;
|
|
70
|
+
background-color: #ffcf39;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#status-indeterminate {
|
|
74
|
+
height: 42px;
|
|
75
|
+
visibility: visible;
|
|
76
|
+
position: relative;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#status-indeterminate > div {
|
|
80
|
+
width: 4.5px;
|
|
81
|
+
height: 0;
|
|
82
|
+
border-style: solid;
|
|
83
|
+
border-width: 9px 3px 0 3px;
|
|
84
|
+
border-color: #2b2b2b transparent transparent transparent;
|
|
85
|
+
transform-origin: center 21px;
|
|
86
|
+
position: absolute;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#status-indeterminate > div:nth-child(1) { transform: rotate( 22.5deg); }
|
|
90
|
+
#status-indeterminate > div:nth-child(2) { transform: rotate( 67.5deg); }
|
|
91
|
+
#status-indeterminate > div:nth-child(3) { transform: rotate(112.5deg); }
|
|
92
|
+
#status-indeterminate > div:nth-child(4) { transform: rotate(157.5deg); }
|
|
93
|
+
#status-indeterminate > div:nth-child(5) { transform: rotate(202.5deg); }
|
|
94
|
+
#status-indeterminate > div:nth-child(6) { transform: rotate(247.5deg); }
|
|
95
|
+
#status-indeterminate > div:nth-child(7) { transform: rotate(292.5deg); }
|
|
96
|
+
#status-indeterminate > div:nth-child(8) { transform: rotate(337.5deg); }
|
|
97
|
+
|
|
98
|
+
#status-notice {
|
|
99
|
+
margin: 0 100px;
|
|
100
|
+
line-height: 1.3;
|
|
101
|
+
visibility: visible;
|
|
102
|
+
padding: 4px 6px;
|
|
103
|
+
visibility: visible;
|
|
104
|
+
}
|
|
105
|
+
</style>
|
|
106
|
+
<link id='-gd-engine-icon' rel='icon' type='image/png' href='index.icon.png' />
|
|
107
|
+
<link rel='apple-touch-icon' href='index.apple-touch-icon.png'/>
|
|
108
|
+
|
|
109
|
+
</head>
|
|
110
|
+
<body>
|
|
111
|
+
<canvas id="canvas">
|
|
112
|
+
HTML5 canvas appears to be unsupported in the current browser.<br >
|
|
113
|
+
Please try updating or use a different browser.
|
|
114
|
+
</canvas>
|
|
115
|
+
<div id="status">
|
|
116
|
+
<div id="status-progress" style="display: none;" oncontextmenu="event.preventDefault();">
|
|
117
|
+
<div id ="status-progress-inner"></div>
|
|
118
|
+
</div>
|
|
119
|
+
<div id="status-indeterminate" style="display: none;" oncontextmenu="event.preventDefault();">
|
|
120
|
+
<div></div>
|
|
121
|
+
<div></div>
|
|
122
|
+
<div></div>
|
|
123
|
+
<div></div>
|
|
124
|
+
<div></div>
|
|
125
|
+
<div></div>
|
|
126
|
+
<div></div>
|
|
127
|
+
<div></div>
|
|
128
|
+
</div>
|
|
129
|
+
<div id="status-notice" class="godot" style="display: none;"></div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<script src="index.js"></script>
|
|
133
|
+
<script>
|
|
134
|
+
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":23248976,"index.wasm":28965264},"focusCanvas":true,"gdextensionLibs":[]};
|
|
135
|
+
const engine = new Engine(GODOT_CONFIG);
|
|
136
|
+
|
|
137
|
+
(function () {
|
|
138
|
+
const INDETERMINATE_STATUS_STEP_MS = 100;
|
|
139
|
+
const statusProgress = document.getElementById('status-progress');
|
|
140
|
+
const statusProgressInner = document.getElementById('status-progress-inner');
|
|
141
|
+
const statusIndeterminate = document.getElementById('status-indeterminate');
|
|
142
|
+
const statusNotice = document.getElementById('status-notice');
|
|
143
|
+
|
|
144
|
+
let initializing = true;
|
|
145
|
+
let statusMode = 'hidden';
|
|
146
|
+
|
|
147
|
+
let animationCallbacks = [];
|
|
148
|
+
function animate(time) {
|
|
149
|
+
animationCallbacks.forEach((callback) => callback(time));
|
|
150
|
+
requestAnimationFrame(animate);
|
|
151
|
+
}
|
|
152
|
+
requestAnimationFrame(animate);
|
|
153
|
+
|
|
154
|
+
function animateStatusIndeterminate(ms) {
|
|
155
|
+
const i = Math.floor((ms / INDETERMINATE_STATUS_STEP_MS) % 8);
|
|
156
|
+
if (statusIndeterminate.children[i].style.borderTopColor === '') {
|
|
157
|
+
Array.prototype.slice.call(statusIndeterminate.children).forEach((child) => {
|
|
158
|
+
child.style.borderTopColor = '';
|
|
159
|
+
});
|
|
160
|
+
statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf';
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function setStatusMode(mode) {
|
|
165
|
+
if (statusMode === mode || !initializing) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
[statusProgress, statusIndeterminate, statusNotice].forEach((elem) => {
|
|
169
|
+
elem.style.display = 'none';
|
|
170
|
+
});
|
|
171
|
+
animationCallbacks = animationCallbacks.filter(function (value) {
|
|
172
|
+
return (value !== animateStatusIndeterminate);
|
|
173
|
+
});
|
|
174
|
+
switch (mode) {
|
|
175
|
+
case 'progress':
|
|
176
|
+
statusProgress.style.display = 'block';
|
|
177
|
+
break;
|
|
178
|
+
case 'indeterminate':
|
|
179
|
+
statusIndeterminate.style.display = 'block';
|
|
180
|
+
animationCallbacks.push(animateStatusIndeterminate);
|
|
181
|
+
break;
|
|
182
|
+
case 'notice':
|
|
183
|
+
statusNotice.style.display = 'block';
|
|
184
|
+
break;
|
|
185
|
+
case 'hidden':
|
|
186
|
+
break;
|
|
187
|
+
default:
|
|
188
|
+
throw new Error('Invalid status mode');
|
|
189
|
+
}
|
|
190
|
+
statusMode = mode;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function setStatusNotice(text) {
|
|
194
|
+
while (statusNotice.lastChild) {
|
|
195
|
+
statusNotice.removeChild(statusNotice.lastChild);
|
|
196
|
+
}
|
|
197
|
+
const lines = text.split('\n');
|
|
198
|
+
lines.forEach((line) => {
|
|
199
|
+
statusNotice.appendChild(document.createTextNode(line));
|
|
200
|
+
statusNotice.appendChild(document.createElement('br'));
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function displayFailureNotice(err) {
|
|
205
|
+
const msg = err.message || err;
|
|
206
|
+
console.error(msg);
|
|
207
|
+
setStatusNotice(msg);
|
|
208
|
+
setStatusMode('notice');
|
|
209
|
+
initializing = false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const missing = Engine.getMissingFeatures();
|
|
213
|
+
if (missing.length !== 0) {
|
|
214
|
+
const missingMsg = 'Error\nThe following features required to run Godot projects on the Web are missing:\n';
|
|
215
|
+
displayFailureNotice(missingMsg + missing.join('\n'));
|
|
216
|
+
} else {
|
|
217
|
+
setStatusMode('indeterminate');
|
|
218
|
+
engine.startGame({
|
|
219
|
+
'onProgress': function (current, total) {
|
|
220
|
+
if (total > 0) {
|
|
221
|
+
statusProgressInner.style.width = `${(current / total) * 100}%`;
|
|
222
|
+
setStatusMode('progress');
|
|
223
|
+
if (current === total) {
|
|
224
|
+
// wait for progress bar animation
|
|
225
|
+
setTimeout(() => {
|
|
226
|
+
setStatusMode('indeterminate');
|
|
227
|
+
}, 500);
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
setStatusMode('indeterminate');
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
}).then(() => {
|
|
234
|
+
setStatusMode('hidden');
|
|
235
|
+
initializing = false;
|
|
236
|
+
}, displayFailureNotice);
|
|
237
|
+
}
|
|
238
|
+
}());
|
|
239
|
+
</script>
|
|
240
|
+
</body>
|
|
241
|
+
</html>
|