upload-snake-game
Browse files- .gitattributes +1 -0
- snake/GluttonousSnake.apple-touch-icon.png +0 -0
- snake/GluttonousSnake.apple-touch-icon.png.import +35 -0
- snake/GluttonousSnake.audio.worklet.js +211 -0
- snake/GluttonousSnake.html +251 -0
- snake/GluttonousSnake.icon.png +0 -0
- snake/GluttonousSnake.icon.png.import +35 -0
- snake/GluttonousSnake.js +0 -0
- snake/GluttonousSnake.pck +3 -0
- snake/GluttonousSnake.png +0 -0
- snake/GluttonousSnake.png.import +35 -0
- snake/GluttonousSnake.wasm +3 -0
- snake/anan.tool.js +81 -0
- snake/gameapp.js +151 -0
- snake/uni.webview.1.5.5.js +1 -0
.gitattributes
CHANGED
|
@@ -34,3 +34,4 @@ saved_model/**/* 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 |
house/TowerBlocksGame.pck 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 |
house/TowerBlocksGame.pck filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
snake/GluttonousSnake.pck filter=lfs diff=lfs merge=lfs -text
|
snake/GluttonousSnake.apple-touch-icon.png
ADDED
|
|
snake/GluttonousSnake.apple-touch-icon.png.import
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[remap]
|
| 2 |
+
|
| 3 |
+
importer="texture"
|
| 4 |
+
type="StreamTexture"
|
| 5 |
+
path="res://.import/GluttonousSnake.apple-touch-icon.png-daab55bbef3423d0b72520d06fe099e2.stex"
|
| 6 |
+
metadata={
|
| 7 |
+
"vram_texture": false
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
[deps]
|
| 11 |
+
|
| 12 |
+
source_file="res://Package/HTML/snake/GluttonousSnake.apple-touch-icon.png"
|
| 13 |
+
dest_files=[ "res://.import/GluttonousSnake.apple-touch-icon.png-daab55bbef3423d0b72520d06fe099e2.stex" ]
|
| 14 |
+
|
| 15 |
+
[params]
|
| 16 |
+
|
| 17 |
+
compress/mode=0
|
| 18 |
+
compress/lossy_quality=0.7
|
| 19 |
+
compress/hdr_mode=0
|
| 20 |
+
compress/bptc_ldr=0
|
| 21 |
+
compress/normal_map=0
|
| 22 |
+
flags/repeat=0
|
| 23 |
+
flags/filter=true
|
| 24 |
+
flags/mipmaps=false
|
| 25 |
+
flags/anisotropic=false
|
| 26 |
+
flags/srgb=2
|
| 27 |
+
process/fix_alpha_border=true
|
| 28 |
+
process/premult_alpha=false
|
| 29 |
+
process/HDR_as_SRGB=false
|
| 30 |
+
process/invert_color=false
|
| 31 |
+
process/normal_map_invert_y=false
|
| 32 |
+
stream=false
|
| 33 |
+
size_limit=0
|
| 34 |
+
detect_3d=true
|
| 35 |
+
svg/scale=1.0
|
snake/GluttonousSnake.audio.worklet.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
} else if (p_cmd === 'start_nothreads') {
|
| 137 |
+
this.output = new RingBuffer(p_data[0], p_data[0].length, false);
|
| 138 |
+
} else if (p_cmd === 'chunk') {
|
| 139 |
+
this.output.write(p_data);
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
static array_has_data(arr) {
|
| 144 |
+
return arr.length && arr[0].length && arr[0][0].length;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
process(inputs, outputs, parameters) {
|
| 148 |
+
if (!this.running) {
|
| 149 |
+
return false; // Stop processing.
|
| 150 |
+
}
|
| 151 |
+
if (this.output === null) {
|
| 152 |
+
return true; // Not ready yet, keep processing.
|
| 153 |
+
}
|
| 154 |
+
const process_input = GodotProcessor.array_has_data(inputs);
|
| 155 |
+
if (process_input) {
|
| 156 |
+
const input = inputs[0];
|
| 157 |
+
const chunk = input[0].length * input.length;
|
| 158 |
+
if (this.input_buffer.length !== chunk) {
|
| 159 |
+
this.input_buffer = new Float32Array(chunk);
|
| 160 |
+
}
|
| 161 |
+
if (!this.threads) {
|
| 162 |
+
GodotProcessor.write_input(this.input_buffer, input);
|
| 163 |
+
this.port.postMessage({ 'cmd': 'input', 'data': this.input_buffer });
|
| 164 |
+
} else if (this.input.space_left() >= chunk) {
|
| 165 |
+
GodotProcessor.write_input(this.input_buffer, input);
|
| 166 |
+
this.input.write(this.input_buffer);
|
| 167 |
+
} else {
|
| 168 |
+
this.port.postMessage('Input buffer is full! Skipping input frame.');
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
const process_output = GodotProcessor.array_has_data(outputs);
|
| 172 |
+
if (process_output) {
|
| 173 |
+
const output = outputs[0];
|
| 174 |
+
const chunk = output[0].length * output.length;
|
| 175 |
+
if (this.output_buffer.length !== chunk) {
|
| 176 |
+
this.output_buffer = new Float32Array(chunk);
|
| 177 |
+
}
|
| 178 |
+
if (this.output.data_left() >= chunk) {
|
| 179 |
+
this.output.read(this.output_buffer);
|
| 180 |
+
GodotProcessor.write_output(output, this.output_buffer);
|
| 181 |
+
if (!this.threads) {
|
| 182 |
+
this.port.postMessage({ 'cmd': 'read', 'data': chunk });
|
| 183 |
+
}
|
| 184 |
+
} else {
|
| 185 |
+
this.port.postMessage('Output buffer has not enough frames! Skipping output frame.');
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
this.process_notify();
|
| 189 |
+
return true;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
static write_output(dest, source) {
|
| 193 |
+
const channels = dest.length;
|
| 194 |
+
for (let ch = 0; ch < channels; ch++) {
|
| 195 |
+
for (let sample = 0; sample < dest[ch].length; sample++) {
|
| 196 |
+
dest[ch][sample] = source[sample * channels + ch];
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
static write_input(dest, source) {
|
| 202 |
+
const channels = source.length;
|
| 203 |
+
for (let ch = 0; ch < channels; ch++) {
|
| 204 |
+
for (let sample = 0; sample < source[ch].length; sample++) {
|
| 205 |
+
dest[sample * channels + ch] = source[ch][sample];
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
registerProcessor('godot-processor', GodotProcessor);
|
snake/GluttonousSnake.html
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html xmlns='http://www.w3.org/1999/xhtml' lang='' xml:lang=''>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset='utf-8' />
|
| 5 |
+
<meta name='viewport' content='width=device-width, user-scalable=no' />
|
| 6 |
+
<title>GluttonousSnake</title>
|
| 7 |
+
<style type='text/css'>
|
| 8 |
+
|
| 9 |
+
body {
|
| 10 |
+
touch-action: none;
|
| 11 |
+
margin: 0;
|
| 12 |
+
border: 0 none;
|
| 13 |
+
padding: 0;
|
| 14 |
+
text-align: center;
|
| 15 |
+
background-color: black;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
#canvas {
|
| 19 |
+
display: block;
|
| 20 |
+
margin: 0;
|
| 21 |
+
color: white;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
#canvas:focus {
|
| 25 |
+
outline: none;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.godot {
|
| 29 |
+
font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif;
|
| 30 |
+
color: #e0e0e0;
|
| 31 |
+
background-color: #3b3943;
|
| 32 |
+
background-image: linear-gradient(to bottom, #403e48, #35333c);
|
| 33 |
+
border: 1px solid #45434e;
|
| 34 |
+
box-shadow: 0 0 1px 1px #2f2d35;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
/* Status display
|
| 39 |
+
* ============== */
|
| 40 |
+
|
| 41 |
+
#status {
|
| 42 |
+
position: absolute;
|
| 43 |
+
left: 0;
|
| 44 |
+
top: 0;
|
| 45 |
+
right: 0;
|
| 46 |
+
bottom: 0;
|
| 47 |
+
display: flex;
|
| 48 |
+
justify-content: center;
|
| 49 |
+
align-items: center;
|
| 50 |
+
/* don't consume click events - make children visible explicitly */
|
| 51 |
+
visibility: hidden;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
#status-progress {
|
| 55 |
+
width: 366px;
|
| 56 |
+
height: 7px;
|
| 57 |
+
background-color: #38363A;
|
| 58 |
+
border: 1px solid #444246;
|
| 59 |
+
padding: 1px;
|
| 60 |
+
box-shadow: 0 0 2px 1px #1B1C22;
|
| 61 |
+
border-radius: 2px;
|
| 62 |
+
visibility: visible;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
@media only screen and (orientation:portrait) {
|
| 66 |
+
#status-progress {
|
| 67 |
+
width: 61.8%;
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
#status-progress-inner {
|
| 72 |
+
height: 100%;
|
| 73 |
+
width: 0;
|
| 74 |
+
box-sizing: border-box;
|
| 75 |
+
transition: width 0.5s linear;
|
| 76 |
+
background-color: #202020;
|
| 77 |
+
border: 1px solid #222223;
|
| 78 |
+
box-shadow: 0 0 1px 1px #27282E;
|
| 79 |
+
border-radius: 3px;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
#status-indeterminate {
|
| 83 |
+
height: 42px;
|
| 84 |
+
visibility: visible;
|
| 85 |
+
position: relative;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
#status-indeterminate > div {
|
| 89 |
+
width: 4.5px;
|
| 90 |
+
height: 0;
|
| 91 |
+
border-style: solid;
|
| 92 |
+
border-width: 9px 3px 0 3px;
|
| 93 |
+
border-color: #2b2b2b transparent transparent transparent;
|
| 94 |
+
transform-origin: center 21px;
|
| 95 |
+
position: absolute;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
#status-indeterminate > div:nth-child(1) { transform: rotate( 22.5deg); }
|
| 99 |
+
#status-indeterminate > div:nth-child(2) { transform: rotate( 67.5deg); }
|
| 100 |
+
#status-indeterminate > div:nth-child(3) { transform: rotate(112.5deg); }
|
| 101 |
+
#status-indeterminate > div:nth-child(4) { transform: rotate(157.5deg); }
|
| 102 |
+
#status-indeterminate > div:nth-child(5) { transform: rotate(202.5deg); }
|
| 103 |
+
#status-indeterminate > div:nth-child(6) { transform: rotate(247.5deg); }
|
| 104 |
+
#status-indeterminate > div:nth-child(7) { transform: rotate(292.5deg); }
|
| 105 |
+
#status-indeterminate > div:nth-child(8) { transform: rotate(337.5deg); }
|
| 106 |
+
|
| 107 |
+
#status-notice {
|
| 108 |
+
margin: 0 100px;
|
| 109 |
+
line-height: 1.3;
|
| 110 |
+
visibility: visible;
|
| 111 |
+
padding: 4px 6px;
|
| 112 |
+
visibility: visible;
|
| 113 |
+
}
|
| 114 |
+
</style>
|
| 115 |
+
<link id='-gd-engine-icon' rel='icon' type='image/png' href='GluttonousSnake.icon.png' />
|
| 116 |
+
<link rel='apple-touch-icon' href='GluttonousSnake.apple-touch-icon.png'/>
|
| 117 |
+
|
| 118 |
+
<script type="text/javascript" src="./uni.webview.1.5.5.js"></script>
|
| 119 |
+
<script type="text/javascript" src="./anan.tool.js"></script>
|
| 120 |
+
<script type="text/javascript" src="./gameapp.js"></script>
|
| 121 |
+
</head>
|
| 122 |
+
<body>
|
| 123 |
+
<canvas id='canvas'>
|
| 124 |
+
HTML5 canvas appears to be unsupported in the current browser.<br />
|
| 125 |
+
Please try updating or use a different browser.
|
| 126 |
+
</canvas>
|
| 127 |
+
<div id='status'>
|
| 128 |
+
<div id='status-progress' style='display: none;' oncontextmenu='event.preventDefault();'><div id ='status-progress-inner'></div></div>
|
| 129 |
+
<div id='status-indeterminate' style='display: none;' oncontextmenu='event.preventDefault();'>
|
| 130 |
+
<div></div>
|
| 131 |
+
<div></div>
|
| 132 |
+
<div></div>
|
| 133 |
+
<div></div>
|
| 134 |
+
<div></div>
|
| 135 |
+
<div></div>
|
| 136 |
+
<div></div>
|
| 137 |
+
<div></div>
|
| 138 |
+
</div>
|
| 139 |
+
<div id='status-notice' class='godot' style='display: none;'></div>
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
<script type='text/javascript' src='GluttonousSnake.js'></script>
|
| 143 |
+
<script type='text/javascript'>//<![CDATA[
|
| 144 |
+
|
| 145 |
+
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"GluttonousSnake","experimentalVK":false,"fileSizes":{"GluttonousSnake.pck":61951632,"GluttonousSnake.wasm":13790961},"focusCanvas":true,"gdnativeLibs":[]};
|
| 146 |
+
var engine = new Engine(GODOT_CONFIG);
|
| 147 |
+
|
| 148 |
+
(function() {
|
| 149 |
+
const INDETERMINATE_STATUS_STEP_MS = 100;
|
| 150 |
+
var statusProgress = document.getElementById('status-progress');
|
| 151 |
+
var statusProgressInner = document.getElementById('status-progress-inner');
|
| 152 |
+
var statusIndeterminate = document.getElementById('status-indeterminate');
|
| 153 |
+
var statusNotice = document.getElementById('status-notice');
|
| 154 |
+
|
| 155 |
+
var initializing = true;
|
| 156 |
+
var statusMode = 'hidden';
|
| 157 |
+
|
| 158 |
+
var animationCallbacks = [];
|
| 159 |
+
function animate(time) {
|
| 160 |
+
animationCallbacks.forEach(callback => callback(time));
|
| 161 |
+
requestAnimationFrame(animate);
|
| 162 |
+
}
|
| 163 |
+
requestAnimationFrame(animate);
|
| 164 |
+
|
| 165 |
+
function setStatusMode(mode) {
|
| 166 |
+
|
| 167 |
+
if (statusMode === mode || !initializing)
|
| 168 |
+
return;
|
| 169 |
+
[statusProgress, statusIndeterminate, statusNotice].forEach(elem => {
|
| 170 |
+
elem.style.display = 'none';
|
| 171 |
+
});
|
| 172 |
+
animationCallbacks = animationCallbacks.filter(function(value) {
|
| 173 |
+
return (value != animateStatusIndeterminate);
|
| 174 |
+
});
|
| 175 |
+
switch (mode) {
|
| 176 |
+
case 'progress':
|
| 177 |
+
statusProgress.style.display = 'block';
|
| 178 |
+
break;
|
| 179 |
+
case 'indeterminate':
|
| 180 |
+
statusIndeterminate.style.display = 'block';
|
| 181 |
+
animationCallbacks.push(animateStatusIndeterminate);
|
| 182 |
+
break;
|
| 183 |
+
case 'notice':
|
| 184 |
+
statusNotice.style.display = 'block';
|
| 185 |
+
break;
|
| 186 |
+
case 'hidden':
|
| 187 |
+
break;
|
| 188 |
+
default:
|
| 189 |
+
throw new Error('Invalid status mode');
|
| 190 |
+
}
|
| 191 |
+
statusMode = mode;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
function animateStatusIndeterminate(ms) {
|
| 195 |
+
var i = Math.floor(ms / INDETERMINATE_STATUS_STEP_MS % 8);
|
| 196 |
+
if (statusIndeterminate.children[i].style.borderTopColor == '') {
|
| 197 |
+
Array.prototype.slice.call(statusIndeterminate.children).forEach(child => {
|
| 198 |
+
child.style.borderTopColor = '';
|
| 199 |
+
});
|
| 200 |
+
statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf';
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
function setStatusNotice(text) {
|
| 205 |
+
while (statusNotice.lastChild) {
|
| 206 |
+
statusNotice.removeChild(statusNotice.lastChild);
|
| 207 |
+
}
|
| 208 |
+
var lines = text.split('\n');
|
| 209 |
+
lines.forEach((line) => {
|
| 210 |
+
statusNotice.appendChild(document.createTextNode(line));
|
| 211 |
+
statusNotice.appendChild(document.createElement('br'));
|
| 212 |
+
});
|
| 213 |
+
};
|
| 214 |
+
|
| 215 |
+
function displayFailureNotice(err) {
|
| 216 |
+
var msg = err.message || err;
|
| 217 |
+
console.error(msg);
|
| 218 |
+
setStatusNotice(msg);
|
| 219 |
+
setStatusMode('notice');
|
| 220 |
+
initializing = false;
|
| 221 |
+
};
|
| 222 |
+
|
| 223 |
+
if (!Engine.isWebGLAvailable()) {
|
| 224 |
+
displayFailureNotice('WebGL not available');
|
| 225 |
+
} else {
|
| 226 |
+
setStatusMode('indeterminate');
|
| 227 |
+
engine.startGame({
|
| 228 |
+
'onProgress': function (current, total) {
|
| 229 |
+
if (total > 0) {
|
| 230 |
+
statusProgressInner.style.width = current/total * 100 + '%';
|
| 231 |
+
setStatusMode('progress');
|
| 232 |
+
if (current === total) {
|
| 233 |
+
// wait for progress bar animation
|
| 234 |
+
setTimeout(() => {
|
| 235 |
+
setStatusMode('indeterminate');
|
| 236 |
+
}, 500);
|
| 237 |
+
}
|
| 238 |
+
} else {
|
| 239 |
+
setStatusMode('indeterminate');
|
| 240 |
+
}
|
| 241 |
+
},
|
| 242 |
+
}).then(() => {
|
| 243 |
+
setStatusMode('hidden');
|
| 244 |
+
initializing = false;
|
| 245 |
+
}, displayFailureNotice);
|
| 246 |
+
}
|
| 247 |
+
})();
|
| 248 |
+
//]]></script>
|
| 249 |
+
</body>
|
| 250 |
+
</html>
|
| 251 |
+
|
snake/GluttonousSnake.icon.png
ADDED
|
|
snake/GluttonousSnake.icon.png.import
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[remap]
|
| 2 |
+
|
| 3 |
+
importer="texture"
|
| 4 |
+
type="StreamTexture"
|
| 5 |
+
path="res://.import/GluttonousSnake.icon.png-5d8766668697fd643f6e2ccec42b5395.stex"
|
| 6 |
+
metadata={
|
| 7 |
+
"vram_texture": false
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
[deps]
|
| 11 |
+
|
| 12 |
+
source_file="res://Package/HTML/snake/GluttonousSnake.icon.png"
|
| 13 |
+
dest_files=[ "res://.import/GluttonousSnake.icon.png-5d8766668697fd643f6e2ccec42b5395.stex" ]
|
| 14 |
+
|
| 15 |
+
[params]
|
| 16 |
+
|
| 17 |
+
compress/mode=0
|
| 18 |
+
compress/lossy_quality=0.7
|
| 19 |
+
compress/hdr_mode=0
|
| 20 |
+
compress/bptc_ldr=0
|
| 21 |
+
compress/normal_map=0
|
| 22 |
+
flags/repeat=0
|
| 23 |
+
flags/filter=true
|
| 24 |
+
flags/mipmaps=false
|
| 25 |
+
flags/anisotropic=false
|
| 26 |
+
flags/srgb=2
|
| 27 |
+
process/fix_alpha_border=true
|
| 28 |
+
process/premult_alpha=false
|
| 29 |
+
process/HDR_as_SRGB=false
|
| 30 |
+
process/invert_color=false
|
| 31 |
+
process/normal_map_invert_y=false
|
| 32 |
+
stream=false
|
| 33 |
+
size_limit=0
|
| 34 |
+
detect_3d=true
|
| 35 |
+
svg/scale=1.0
|
snake/GluttonousSnake.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
snake/GluttonousSnake.pck
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:015e0a5c1a68addaf5f0ba469019de79f6357cad2fe2c8f2b0576881040b9ff8
|
| 3 |
+
size 61951632
|
snake/GluttonousSnake.png
ADDED
|
snake/GluttonousSnake.png.import
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[remap]
|
| 2 |
+
|
| 3 |
+
importer="texture"
|
| 4 |
+
type="StreamTexture"
|
| 5 |
+
path="res://.import/GluttonousSnake.png-091dcfb9c221415206d73f92d3403b1b.stex"
|
| 6 |
+
metadata={
|
| 7 |
+
"vram_texture": false
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
[deps]
|
| 11 |
+
|
| 12 |
+
source_file="res://Package/HTML/snake/GluttonousSnake.png"
|
| 13 |
+
dest_files=[ "res://.import/GluttonousSnake.png-091dcfb9c221415206d73f92d3403b1b.stex" ]
|
| 14 |
+
|
| 15 |
+
[params]
|
| 16 |
+
|
| 17 |
+
compress/mode=0
|
| 18 |
+
compress/lossy_quality=0.7
|
| 19 |
+
compress/hdr_mode=0
|
| 20 |
+
compress/bptc_ldr=0
|
| 21 |
+
compress/normal_map=0
|
| 22 |
+
flags/repeat=0
|
| 23 |
+
flags/filter=true
|
| 24 |
+
flags/mipmaps=false
|
| 25 |
+
flags/anisotropic=false
|
| 26 |
+
flags/srgb=2
|
| 27 |
+
process/fix_alpha_border=true
|
| 28 |
+
process/premult_alpha=false
|
| 29 |
+
process/HDR_as_SRGB=false
|
| 30 |
+
process/invert_color=false
|
| 31 |
+
process/normal_map_invert_y=false
|
| 32 |
+
stream=false
|
| 33 |
+
size_limit=0
|
| 34 |
+
detect_3d=true
|
| 35 |
+
svg/scale=1.0
|
snake/GluttonousSnake.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af1e6208f15da2d5a49a6064d541ec8701351f321fff5f922a0e013d24a66bad
|
| 3 |
+
size 13790961
|
snake/anan.tool.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function() {
|
| 2 |
+
window.godotFilePath = null;
|
| 3 |
+
|
| 4 |
+
window.uploadFile = function() {
|
| 5 |
+
var input = document.createElement('input');
|
| 6 |
+
input.type = 'file';
|
| 7 |
+
input.onchange = function(event) {
|
| 8 |
+
var file = event.target.files[0];
|
| 9 |
+
if (file) {
|
| 10 |
+
var reader = new FileReader();
|
| 11 |
+
reader.onload = function(e) {
|
| 12 |
+
var fileContent = e.target.result; // 读取到的文件内容(Base64 编码)
|
| 13 |
+
window.godotFilePath = fileContent;
|
| 14 |
+
if (typeof window.fileUploaded === 'function') {
|
| 15 |
+
window.fileUploaded(fileContent); // 调用外部定义的事件触发函数
|
| 16 |
+
}
|
| 17 |
+
};
|
| 18 |
+
reader.readAsDataURL(file); // 读取文件内容为 Data URL
|
| 19 |
+
}
|
| 20 |
+
};
|
| 21 |
+
input.click();
|
| 22 |
+
};
|
| 23 |
+
window.gdjs = {
|
| 24 |
+
godotFilePath: null
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
// 虚拟键盘
|
| 28 |
+
window.showVirtualKeyboard = function() {
|
| 29 |
+
var inputField = document.createElement('input');
|
| 30 |
+
inputField.type = 'text';
|
| 31 |
+
inputField.style.position = 'absolute';
|
| 32 |
+
inputField.style.top = '-1000px';
|
| 33 |
+
document.body.appendChild(inputField);
|
| 34 |
+
setTimeout(function() {
|
| 35 |
+
inputField.focus();
|
| 36 |
+
}, 100); // 尝试调整延迟时间
|
| 37 |
+
inputField.onblur = function() {
|
| 38 |
+
document.body.removeChild(inputField);
|
| 39 |
+
};
|
| 40 |
+
inputField.addEventListener('input', function() {
|
| 41 |
+
var value = inputField.value;
|
| 42 |
+
if (typeof window.godotUserInput === 'function') {
|
| 43 |
+
window.godotUserInput(value); // 修正了传参的语法
|
| 44 |
+
}
|
| 45 |
+
});
|
| 46 |
+
};
|
| 47 |
+
window.closeVirtualKeyboard = function() {
|
| 48 |
+
document.activeElement.blur();
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
//屏幕翻转
|
| 52 |
+
window.setOrientation = function(orientation) {
|
| 53 |
+
console.log("2222")
|
| 54 |
+
console.log(orientation)
|
| 55 |
+
if (orientation === "landscape") {
|
| 56 |
+
screen.orientation.lock(orientation).catch(function(error) {
|
| 57 |
+
console.log("Orientation lock failed: " + error);
|
| 58 |
+
});
|
| 59 |
+
} else if (orientation === "portrait") {
|
| 60 |
+
screen.lockOrientation(orientation).catch(function(error) {
|
| 61 |
+
console.log("Orientation lock failed: " + error);
|
| 62 |
+
});
|
| 63 |
+
}
|
| 64 |
+
console.log(document.body)
|
| 65 |
+
};
|
| 66 |
+
window.setWindowSize = function(width, height) {
|
| 67 |
+
var canvas = document.getElementById('canvas');
|
| 68 |
+
canvas.style.width = width + 'px';
|
| 69 |
+
canvas.style.height = height + 'px';
|
| 70 |
+
};
|
| 71 |
+
window.setScreenStretch = function(mode, aspect, width, height) {
|
| 72 |
+
var canvas = document.getElementById('canvas');
|
| 73 |
+
if (mode === 'viewport') {
|
| 74 |
+
canvas.style.objectFit = 'contain'; // 等同于 Godot 的 STRETCH_MODE_VIEWPORT
|
| 75 |
+
}
|
| 76 |
+
if (aspect === 'keep') {
|
| 77 |
+
canvas.style.width = width + 'px';
|
| 78 |
+
canvas.style.height = height + 'px';
|
| 79 |
+
}
|
| 80 |
+
};
|
| 81 |
+
})();
|
snake/gameapp.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function confirmSelectFile(accept = "all") {
|
| 2 |
+
const div = document.createElement("div");
|
| 3 |
+
div.innerHTML = `<div style="margin-bottom:10px;padding:8px;">Do you allow application to access phone storage?</div>`;
|
| 4 |
+
div.setAttribute(
|
| 5 |
+
"style",
|
| 6 |
+
"width: 220px;display: flex;flex-direction: column;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%); background:white;box-shadow:0 0px 4px 4px #00000033;border-radius:5px;overflow:hidden;z-index:99;"
|
| 7 |
+
);
|
| 8 |
+
const input = document.createElement("input");
|
| 9 |
+
input.type = "file";
|
| 10 |
+
input.id = "btn";
|
| 11 |
+
if (accept !== "all") {
|
| 12 |
+
if (accept !== "video" && accept !== "audio") throw new Error("不支持文件类型");
|
| 13 |
+
input.accept = `${accept}/*`;
|
| 14 |
+
}
|
| 15 |
+
// input.multiple = true;
|
| 16 |
+
input.onchange = async function (event) {
|
| 17 |
+
div.remove();
|
| 18 |
+
uni.postMessage({
|
| 19 |
+
data: {
|
| 20 |
+
action: "show-loading", //显示加载框
|
| 21 |
+
},
|
| 22 |
+
});
|
| 23 |
+
const file = event.target.files[0];
|
| 24 |
+
if (file) {
|
| 25 |
+
const reader = new FileReader();
|
| 26 |
+
reader.onload = function (e) {
|
| 27 |
+
const fileContent = e.target.result; // 读取到的文件内容(Base64 编码)
|
| 28 |
+
if (fileContent) {
|
| 29 |
+
WebViewMessage.send(
|
| 30 |
+
"request-file-system",
|
| 31 |
+
JSON.stringify({
|
| 32 |
+
success: true,
|
| 33 |
+
file: fileContent,
|
| 34 |
+
})
|
| 35 |
+
);
|
| 36 |
+
} else {
|
| 37 |
+
WebViewMessage.send(
|
| 38 |
+
"request-file-system",
|
| 39 |
+
JSON.stringify({
|
| 40 |
+
success: false,
|
| 41 |
+
file: null,
|
| 42 |
+
})
|
| 43 |
+
);
|
| 44 |
+
}
|
| 45 |
+
uni.postMessage({
|
| 46 |
+
data: {
|
| 47 |
+
action: "hide-loading", //显示加载框
|
| 48 |
+
},
|
| 49 |
+
});
|
| 50 |
+
};
|
| 51 |
+
reader.readAsDataURL(file); // 读取文件内容为 Data URL
|
| 52 |
+
}
|
| 53 |
+
};
|
| 54 |
+
const buttonContianer = document.createElement("div");
|
| 55 |
+
buttonContianer.setAttribute("style", "display:flex;width:100%;");
|
| 56 |
+
const buttonStyle =
|
| 57 |
+
"display: block;background:white;width:50%;padding: 5px;border: 0;height: 40px;border-top:1px solid #ccc;";
|
| 58 |
+
const confirmButton = document.createElement("button");
|
| 59 |
+
confirmButton.setAttribute("style", buttonStyle + "color: #007aff;");
|
| 60 |
+
confirmButton.innerText = "Confirm";
|
| 61 |
+
confirmButton.onclick = () => {
|
| 62 |
+
input.click();
|
| 63 |
+
};
|
| 64 |
+
const cancelButton = document.createElement("button");
|
| 65 |
+
cancelButton.setAttribute("style", buttonStyle + "color: red;border-right:1px solid #ccc;");
|
| 66 |
+
cancelButton.innerText = "Cancel";
|
| 67 |
+
cancelButton.onclick = () => {
|
| 68 |
+
div.remove();
|
| 69 |
+
};
|
| 70 |
+
buttonContianer.appendChild(cancelButton);
|
| 71 |
+
buttonContianer.appendChild(confirmButton);
|
| 72 |
+
div.appendChild(buttonContianer);
|
| 73 |
+
document.querySelector("body").appendChild(div);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
function userInput() {
|
| 77 |
+
const div = document.createElement("div");
|
| 78 |
+
div.setAttribute(
|
| 79 |
+
"style",
|
| 80 |
+
"width: 240px;display: flex;flex-direction: column;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%); background:white;box-shadow:0 0px 4px 4px #00000033;border-radius:5px;overflow:hidden;z-index:99;"
|
| 81 |
+
);
|
| 82 |
+
const inputContianer = document.createElement("div");
|
| 83 |
+
inputContianer.setAttribute("style", "display:flex;width:100%;box-sizing:border-box;padding:10px 15px;");
|
| 84 |
+
const input = document.createElement("input");
|
| 85 |
+
input.type = "text";
|
| 86 |
+
input.setAttribute(
|
| 87 |
+
"style",
|
| 88 |
+
"display:block;width:100%;height:20px;border:1px solid #007aff;border-radius:2px;font-size:16px;height:28px;line-height:28px;padding:0 5px;"
|
| 89 |
+
);
|
| 90 |
+
inputContianer.appendChild(input);
|
| 91 |
+
div.append(inputContianer);
|
| 92 |
+
const buttonContianer = document.createElement("div");
|
| 93 |
+
buttonContianer.setAttribute("style", "display:flex;width:100%;");
|
| 94 |
+
const buttonStyle =
|
| 95 |
+
"display: block;background:white;width:50%;padding: 5px;border: 0;height: 40px;border-top:1px solid #ccc;";
|
| 96 |
+
const confirmButton = document.createElement("button");
|
| 97 |
+
confirmButton.setAttribute("style", buttonStyle + "color: #007aff;");
|
| 98 |
+
confirmButton.innerText = "Confirm";
|
| 99 |
+
confirmButton.onclick = () => {
|
| 100 |
+
const value = input.value;
|
| 101 |
+
if (typeof window.godotUserInput === "function") {
|
| 102 |
+
window.godotUserInput(value); // 修正了传参的语法
|
| 103 |
+
}
|
| 104 |
+
div.remove();
|
| 105 |
+
};
|
| 106 |
+
const cancelButton = document.createElement("button");
|
| 107 |
+
cancelButton.setAttribute("style", buttonStyle + "color: red;border-right:1px solid #ccc;");
|
| 108 |
+
cancelButton.innerText = "Cancel";
|
| 109 |
+
cancelButton.onclick = () => {
|
| 110 |
+
div.remove();
|
| 111 |
+
};
|
| 112 |
+
buttonContianer.appendChild(cancelButton);
|
| 113 |
+
buttonContianer.appendChild(confirmButton);
|
| 114 |
+
div.appendChild(buttonContianer);
|
| 115 |
+
document.querySelector("body").appendChild(div);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
window.WebViewMessage = {
|
| 119 |
+
actionList: {},
|
| 120 |
+
on(action, callback) {
|
| 121 |
+
if (!this.actionList[action]) this.actionList[action] = [];
|
| 122 |
+
this.actionList[action].push(callback);
|
| 123 |
+
},
|
| 124 |
+
clear(action) {
|
| 125 |
+
this.actionList[action] = [];
|
| 126 |
+
},
|
| 127 |
+
send(action, data) {
|
| 128 |
+
if (!this.actionList[action] instanceof Array) return;
|
| 129 |
+
for (let func of this.actionList[action]) {
|
| 130 |
+
func(data);
|
| 131 |
+
}
|
| 132 |
+
},
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
function adjustCanvas() {
|
| 136 |
+
const canvas = document.getElementById("canvas");
|
| 137 |
+
const deviceWidth = window.innerWidth;
|
| 138 |
+
const deviceHeight = window.innerHeight;
|
| 139 |
+
const aspect = deviceWidth / deviceHeight;
|
| 140 |
+
canvas.style = `width:${deviceWidth}px; height:${deviceHeight}px;`;
|
| 141 |
+
if (aspect >= 9 / 16) {
|
| 142 |
+
canvas.width = 1080;
|
| 143 |
+
canvas.height = 1080 / aspect;
|
| 144 |
+
} else {
|
| 145 |
+
canvas.width = 1920 * aspect;
|
| 146 |
+
canvas.height = 1920;
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
window.addEventListener("load", adjustCanvas);
|
| 151 |
+
window.addEventListener("resize", adjustCanvas);
|
snake/uni.webview.1.5.5.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).uni=n()}(this,(function(){"use strict";try{var e={};Object.defineProperty(e,"passive",{get:function(){!0}}),window.addEventListener("test-passive",null,e)}catch(e){}var n=Object.prototype.hasOwnProperty;function i(e,i){return n.call(e,i)}var t=[];function o(){return window.__dcloud_weex_postMessage||window.__dcloud_weex_}function a(){return window.__uniapp_x_postMessage||window.__uniapp_x_}var r=function(e,n){var i={options:{timestamp:+new Date},name:e,arg:n};if(a()){if("postMessage"===e){var r={data:n};return window.__uniapp_x_postMessage?window.__uniapp_x_postMessage(r):window.__uniapp_x_.postMessage(JSON.stringify(r))}var d={type:"WEB_INVOKE_APPSERVICE",args:{data:i,webviewIds:t}};window.__uniapp_x_postMessage?window.__uniapp_x_postMessageToService(d):window.__uniapp_x_.postMessageToService(JSON.stringify(d))}else if(o()){if("postMessage"===e){var s={data:[n]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(s):window.__dcloud_weex_.postMessage(JSON.stringify(s))}var w={type:"WEB_INVOKE_APPSERVICE",args:{data:i,webviewIds:t}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(w):window.__dcloud_weex_.postMessageToService(JSON.stringify(w))}else{if(!window.plus)return window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:i,pageId:""},"*");if(0===t.length){var u=plus.webview.currentWebview();if(!u)throw new Error("plus.webview.currentWebview() is undefined");var g=u.parent(),v="";v=g?g.id:u.id,t.push(v)}if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:i,webviewIds:t}},"__uniapp__service");else{var c=JSON.stringify(i);plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat("WEB_INVOKE_APPSERVICE",'",').concat(c,",").concat(JSON.stringify(t),");"))}}},d={navigateTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("navigateTo",{url:encodeURI(n)})},navigateBack:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.delta;r("navigateBack",{delta:parseInt(n)||1})},switchTab:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("switchTab",{url:encodeURI(n)})},reLaunch:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("reLaunch",{url:encodeURI(n)})},redirectTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("redirectTo",{url:encodeURI(n)})},getEnv:function(e){a()?e({uvue:!0}):o()?e({nvue:!0}):window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r("postMessage",e.data||{})}},s=/uni-app/i.test(navigator.userAgent),w=/Html5Plus/i.test(navigator.userAgent),u=/complete|loaded|interactive/;var g=window.my&&navigator.userAgent.indexOf(["t","n","e","i","l","C","y","a","p","i","l","A"].reverse().join(""))>-1;var v=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var c=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var p=window.tt&&window.tt.miniProgram&&/toutiaomicroapp/i.test(navigator.userAgent);var _=window.wx&&window.wx.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var m=window.qa&&/quickapp/i.test(navigator.userAgent);var f=window.ks&&window.ks.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var l=window.tt&&window.tt.miniProgram&&/Lark|Feishu/i.test(navigator.userAgent);var E=window.jd&&window.jd.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var x=window.xhs&&window.xhs.miniProgram&&/xhsminiapp/i.test(navigator.userAgent);for(var S,h=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},y=[function(e){if(s||w)return window.__uniapp_x_postMessage||window.__uniapp_x_||window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",e):window.plus&&u.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),d},function(e){if(_)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(c)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(g){document.addEventListener("DOMContentLoaded",e);var n=window.my;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(v)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(p)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(m){window.QaJSBridge&&window.QaJSBridge.invoke?setTimeout(e,0):document.addEventListener("QaJSBridgeReady",e);var n=window.qa;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(f)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.ks.miniProgram},function(e){if(l)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(E)return window.JDJSBridgeReady&&window.JDJSBridgeReady.invoke?setTimeout(e,0):document.addEventListener("JDJSBridgeReady",e),window.jd.miniProgram},function(e){if(x)return window.xhs.miniProgram},function(e){return document.addEventListener("DOMContentLoaded",e),d}],M=0;M<y.length&&!(S=y[M](h));M++);S||(S={});var P="undefined"!=typeof uni?uni:{};if(!P.navigateTo)for(var b in S)i(S,b)&&(P[b]=S[b]);return P.webView=S,P}));
|