Add Do Otboy Godot apartment time-loop prototype
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""Original synthesized ambience. No external audio assets or dependencies."""
|
||||
import math
|
||||
import random
|
||||
import struct
|
||||
import wave
|
||||
from pathlib import Path
|
||||
|
||||
OUT = Path(__file__).resolve().parents[1] / "do-otboy" / "assets" / "audio"
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
RATE = 22050
|
||||
random.seed(17)
|
||||
|
||||
def write(name, seconds, sample):
|
||||
frames = bytearray()
|
||||
previous = 0.0
|
||||
for i in range(int(seconds * RATE)):
|
||||
t = i / RATE
|
||||
previous = 0.985 * previous + 0.015 * random.uniform(-1, 1)
|
||||
edge = min(1, t * 8, (seconds-t) * 8)
|
||||
value = max(-1, min(1, sample(t, previous) * edge))
|
||||
frames.extend(struct.pack("<h", int(value * 26000)))
|
||||
with wave.open(str(OUT / (name + ".wav")), "wb") as wav:
|
||||
wav.setnchannels(1)
|
||||
wav.setsampwidth(2)
|
||||
wav.setframerate(RATE)
|
||||
wav.writeframes(frames)
|
||||
|
||||
write("room", 14, lambda t, n: n * 0.7 + math.sin(t*math.tau*48)*0.018 + math.sin(t*math.tau*62)*0.009)
|
||||
write("phone", 2.4, lambda t,n: (math.sin(t*math.tau*660)*0.15 + math.sin(t*math.tau*880)*0.08) * (1 if t%0.8<0.27 else 0))
|
||||
write("siren", 7, lambda t,n: math.sin(math.tau*(360*t-110*math.cos(t*1.3)/1.3))*0.12 + n*0.06)
|
||||
write("impact", 4, lambda t,n: (random.uniform(-1,1)*0.45 + math.sin(math.tau*(55*t-5*t*t))*0.4 + n*2) * math.exp(-t*1.6))
|
||||
write("knock", 1.6, lambda t,n: sum(math.sin(math.tau*130*(t-k))*0.6*math.exp(-(t-k)*45) for k in (0.05,0.50,0.95) if t>=k))
|
||||
write("click", 0.13, lambda t,n: math.sin(t*math.tau*740)*0.11*math.exp(-t*40))
|
||||
print("Generated six original sound files")
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Package only distributable files; exclude editor caches and player saves."""
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import zipfile
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
builds = root / "builds"
|
||||
windows = builds / "Windows"
|
||||
with zipfile.ZipFile(builds / "DoOtboy_v0.1_Windows.zip", "w", zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
||||
for name in ("DoOtboy.exe", "README_RU.md", "GODOT_LICENSE.txt"):
|
||||
archive.write(windows / name, "DoOtboy/" + name)
|
||||
|
||||
with zipfile.ZipFile(builds / "DoOtboy_v0.1_Source.zip", "w", zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
||||
for name in ("README_RU.md", "GODOT_LICENSE.txt", "build.ps1", ".gitignore"):
|
||||
archive.write(root / name, "DoOtboy/" + name)
|
||||
for name in ("make_audio.py", "package.py"):
|
||||
archive.write(root / "tools" / name, "DoOtboy/tools/" + name)
|
||||
for path in (root / "do-otboy").rglob("*"):
|
||||
if not path.is_file() or ".godot" in path.parts or path.suffix == ".import":
|
||||
continue
|
||||
archive_name = "DoOtboy/" + path.relative_to(root).as_posix()
|
||||
if path.name == "export_presets.cfg":
|
||||
portable = path.read_text(encoding="utf-8").replace(
|
||||
'custom_template/release="../tools/templates/windows_release_x86_64.exe"',
|
||||
'custom_template/release=""',
|
||||
)
|
||||
archive.writestr(archive_name, portable)
|
||||
else:
|
||||
archive.write(path, archive_name)
|
||||
|
||||
for name in ("DoOtboy_v0.1_Windows.zip", "DoOtboy_v0.1_Source.zip"):
|
||||
path = builds / name
|
||||
digest = hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
print(f"{name}: {path.stat().st_size:,} bytes; SHA256 {digest}")
|
||||
|
||||
with zipfile.ZipFile(builds / "DoOtboy_v0.1_Windows.zip") as archive:
|
||||
assert archive.testzip() is None
|
||||
with zipfile.ZipFile(builds / "DoOtboy_v0.1_Source.zip") as archive:
|
||||
assert archive.testzip() is None
|
||||
print("Both ZIP archives verified")
|
||||
Reference in New Issue
Block a user