spriteforge 0.1.1__py3-none-any.whl
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.
- spriteforge/__init__.py +1 -0
- spriteforge/__main__.py +3 -0
- spriteforge/agents/__init__.py +0 -0
- spriteforge/agents/assets.py +109 -0
- spriteforge/agents/cancellation.py +12 -0
- spriteforge/agents/director.py +50 -0
- spriteforge/agents/models.py +63 -0
- spriteforge/agents/roles/art-director.md +15 -0
- spriteforge/agents/roles/art-reviewer.md +14 -0
- spriteforge/agents/roles/director.md +14 -0
- spriteforge/agents/roles/game-designer.md +15 -0
- spriteforge/agents/roles/level-tile-designer.md +16 -0
- spriteforge/agents/roles/librarian.md +13 -0
- spriteforge/agents/roles/menu-designer.md +15 -0
- spriteforge/agents/roles/pixel-artist.md +14 -0
- spriteforge/agents/roles/programmer.md +14 -0
- spriteforge/agents/roles/qa-playtester.md +13 -0
- spriteforge/agents/roles/sound-director.md +14 -0
- spriteforge/agents/roles.py +39 -0
- spriteforge/agents/router.py +233 -0
- spriteforge/agents/router_eval.py +145 -0
- spriteforge/agents/routing_state.py +133 -0
- spriteforge/agents/runtime.py +430 -0
- spriteforge/agents/workflow.py +389 -0
- spriteforge/app/__init__.py +0 -0
- spriteforge/app/agents_view.py +248 -0
- spriteforge/app/chat.py +114 -0
- spriteforge/app/extensions.py +115 -0
- spriteforge/app/index.html +279 -0
- spriteforge/app/local_only.py +49 -0
- spriteforge/app/server.py +358 -0
- spriteforge/app/static/assets/index-L2s1wlcp.css +1 -0
- spriteforge/app/static/assets/index-aBfzgLQl.js +71 -0
- spriteforge/app/static/assets/press-start-2p-latin-400-normal-BKfmdmKK.woff +0 -0
- spriteforge/app/static/assets/press-start-2p-latin-400-normal-xj9lRvVs.woff2 +0 -0
- spriteforge/app/static/index.html +13 -0
- spriteforge/app/static/press-start-2p-LICENSE.txt +93 -0
- spriteforge/app/studio.py +278 -0
- spriteforge/app/workers.py +73 -0
- spriteforge/cli.py +241 -0
- spriteforge/config.py +193 -0
- spriteforge/config.yaml +157 -0
- spriteforge/core/__init__.py +0 -0
- spriteforge/core/acting.py +16 -0
- spriteforge/core/cost.py +236 -0
- spriteforge/core/credentials.py +24 -0
- spriteforge/core/demo.py +79 -0
- spriteforge/core/forms.py +20 -0
- spriteforge/core/gates.py +175 -0
- spriteforge/core/security.py +42 -0
- spriteforge/core/state.py +222 -0
- spriteforge/core/team.py +15 -0
- spriteforge/core/usage.py +68 -0
- spriteforge/game/__init__.py +0 -0
- spriteforge/game/actors.py +377 -0
- spriteforge/game/agent_tools.py +178 -0
- spriteforge/game/art.py +2097 -0
- spriteforge/game/art_checks.py +190 -0
- spriteforge/game/art_review.py +518 -0
- spriteforge/game/build.py +134 -0
- spriteforge/game/bundle.py +1178 -0
- spriteforge/game/cli.py +119 -0
- spriteforge/game/codegen.py +433 -0
- spriteforge/game/codeinfo.py +154 -0
- spriteforge/game/dbsource.py +137 -0
- spriteforge/game/design.py +342 -0
- spriteforge/game/export.py +62 -0
- spriteforge/game/gamedb.py +191 -0
- spriteforge/game/image_cache.py +61 -0
- spriteforge/game/lessons.py +259 -0
- spriteforge/game/level_gen.py +118 -0
- spriteforge/game/level_preview.py +97 -0
- spriteforge/game/levels.py +934 -0
- spriteforge/game/loops.py +38 -0
- spriteforge/game/menus.py +712 -0
- spriteforge/game/mock_game.js +109 -0
- spriteforge/game/mock_platformer.js +58 -0
- spriteforge/game/motion.py +881 -0
- spriteforge/game/pipeline.py +1768 -0
- spriteforge/game/plan.py +502 -0
- spriteforge/game/playtest.py +318 -0
- spriteforge/game/qa.py +664 -0
- spriteforge/game/qa_checks.py +223 -0
- spriteforge/game/qa_runtime.py +565 -0
- spriteforge/game/reach.py +807 -0
- spriteforge/game/record.py +138 -0
- spriteforge/game/research.py +262 -0
- spriteforge/game/revision.py +225 -0
- spriteforge/game/sdk/API.md +104 -0
- spriteforge/game/sdk/FLOW.md +19 -0
- spriteforge/game/sdk/LEVELS.md +65 -0
- spriteforge/game/sdk/sf.js +418 -0
- spriteforge/game/sdk/sfflow.js +442 -0
- spriteforge/game/sdk/sflevel.js +683 -0
- spriteforge/game/sdk/sfsound-editor.js +225 -0
- spriteforge/game/sdk/sfsound.js +260 -0
- spriteforge/game/sdk/sounds.html +67 -0
- spriteforge/game/sounds.py +793 -0
- spriteforge/game/story.py +188 -0
- spriteforge/game/structure.py +98 -0
- spriteforge/game/team_reports.py +394 -0
- spriteforge/game/tilesets.py +70 -0
- spriteforge/game/title_art.py +186 -0
- spriteforge/genres/__init__.py +0 -0
- spriteforge/library/__init__.py +15 -0
- spriteforge/library/cli.py +126 -0
- spriteforge/library/describe.py +242 -0
- spriteforge/library/looks.py +154 -0
- spriteforge/library/models.py +79 -0
- spriteforge/library/store.py +422 -0
- spriteforge/library/tilesets/README.md +32 -0
- spriteforge/library/tilesets/gandalf-seasons.json +111 -0
- spriteforge/library/tilesets/pixel-crawler-dungeon.json +66 -0
- spriteforge/mcp/__init__.py +0 -0
- spriteforge/mcp/cli.py +58 -0
- spriteforge/mcp/client.py +57 -0
- spriteforge/mcp/filesystem_read.py +32 -0
- spriteforge/mcp/gamedb.py +56 -0
- spriteforge/mcp/library.py +179 -0
- spriteforge/mcp/memory.py +37 -0
- spriteforge/mcp/pixel_tools.py +145 -0
- spriteforge/mcp/registry.py +145 -0
- spriteforge/mcp/service.py +224 -0
- spriteforge/mcp/templates/context7.json +6 -0
- spriteforge/mcp/templates/fetch.json +6 -0
- spriteforge/mcp/templates/filesystem-read.json +6 -0
- spriteforge/mcp/templates/pixel-tools.json +6 -0
- spriteforge/memory/README.md +10 -0
- spriteforge/memory/__init__.py +0 -0
- spriteforge/memory/cli.py +131 -0
- spriteforge/memory/okf/__init__.py +1 -0
- spriteforge/memory/okf/catalog.py +331 -0
- spriteforge/memory/okf/codec.py +63 -0
- spriteforge/memory/okf/git.py +104 -0
- spriteforge/memory/okf/indexes.py +50 -0
- spriteforge/memory/okf/models.py +114 -0
- spriteforge/memory/okf/search.py +53 -0
- spriteforge/memory/okf/seed.py +81 -0
- spriteforge/memory/okf/seeds/genres.yaml +121 -0
- spriteforge/memory/okf/seeds/other.yaml +150 -0
- spriteforge/memory/okf/store.py +402 -0
- spriteforge/memory/okf/validate.py +115 -0
- spriteforge/pixel/__init__.py +17 -0
- spriteforge/pixel/atlas.py +110 -0
- spriteforge/pixel/grid.py +174 -0
- spriteforge/pixel/palette.py +156 -0
- spriteforge/pixel/palettes/dungeon.json +9 -0
- spriteforge/pixel/postprocess.py +170 -0
- spriteforge/pixel/preview.py +40 -0
- spriteforge/pixel/schemas.py +139 -0
- spriteforge/pixel/source.py +237 -0
- spriteforge/pixel/terrain.py +48 -0
- spriteforge/pixel/validate.py +138 -0
- spriteforge/prompts/anim_frame.txt +1 -0
- spriteforge/prompts/character.txt +1 -0
- spriteforge/prompts/item.txt +1 -0
- spriteforge/prompts/tile.txt +1 -0
- spriteforge/prompts/ui.txt +1 -0
- spriteforge/providers/__init__.py +0 -0
- spriteforge/providers/base.py +97 -0
- spriteforge/providers/http.py +38 -0
- spriteforge/providers/mock.py +111 -0
- spriteforge/providers/muse_image.py +60 -0
- spriteforge/providers/muse_search.py +91 -0
- spriteforge/providers/muse_spark.py +66 -0
- spriteforge/skills/__init__.py +0 -0
- spriteforge/skills/builtin/LICENSE-awesome-gamedev-agent-skills.txt +201 -0
- spriteforge/skills/builtin/NOTICE-awesome-gamedev-agent-skills.txt +15 -0
- spriteforge/skills/builtin/THIRD_PARTY.md +21 -0
- spriteforge/skills/builtin/audio-design/SKILL.md +190 -0
- spriteforge/skills/builtin/game-feel/SKILL.md +174 -0
- spriteforge/skills/builtin/game-ui-ux/SKILL.md +167 -0
- spriteforge/skills/builtin/level-design/SKILL.md +169 -0
- spriteforge/skills/builtin/phaser-arcade-physics/SKILL.md +17 -0
- spriteforge/skills/builtin/physics-tuning/SKILL.md +164 -0
- spriteforge/skills/builtin/pixel-art-prompting/SKILL.md +12 -0
- spriteforge/skills/builtin/platformer/SKILL.md +153 -0
- spriteforge/skills/builtin/puzzle/SKILL.md +143 -0
- spriteforge/skills/builtin/sprite-animation-frames/SKILL.md +11 -0
- spriteforge/skills/builtin/tileset-design/SKILL.md +10 -0
- spriteforge/skills/catalog.py +200 -0
- spriteforge/skills/cli.py +41 -0
- spriteforge/stages/__init__.py +0 -0
- spriteforge/stages/asset_context.py +301 -0
- spriteforge/stages/asset_models.py +192 -0
- spriteforge/stages/asset_render.py +366 -0
- spriteforge/stages/asset_review.py +140 -0
- spriteforge/stages/asset_store.py +94 -0
- spriteforge/stages/chat_changes.py +236 -0
- spriteforge/stages/concept.py +42 -0
- spriteforge/stages/game.py +1699 -0
- spriteforge/stages/game_confirm.py +112 -0
- spriteforge/stages/game_final.py +220 -0
- spriteforge/stages/game_record.py +246 -0
- spriteforge/stages/gameplay.py +218 -0
- spriteforge/stages/intake.py +372 -0
- spriteforge/stages/preview_assets.py +212 -0
- spriteforge/stages/preview_models.py +167 -0
- spriteforge/stages/preview_render.py +169 -0
- spriteforge/stages/preview_repair.py +61 -0
- spriteforge/stages/preview_review.py +169 -0
- spriteforge/stages/production.py +170 -0
- spriteforge/stages/references.py +105 -0
- spriteforge/stages/rewind.py +128 -0
- spriteforge/stages/workflow.py +440 -0
- spriteforge/templates/phaser/audit.js +45 -0
- spriteforge/templates/phaser/font.png +0 -0
- spriteforge/templates/phaser/font.xml +1 -0
- spriteforge/templates/phaser/preview.html +9 -0
- spriteforge/templates/phaser/room.js +49 -0
- spriteforge/templates/phaser/vendor/LICENSE.md +20 -0
- spriteforge/templates/phaser/vendor/phaser.min.js +1 -0
- spriteforge-0.1.1.dist-info/METADATA +364 -0
- spriteforge-0.1.1.dist-info/RECORD +218 -0
- spriteforge-0.1.1.dist-info/WHEEL +5 -0
- spriteforge-0.1.1.dist-info/entry_points.txt +2 -0
- spriteforge-0.1.1.dist-info/licenses/LICENSE +27 -0
- spriteforge-0.1.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/* The sound editor (sounds.html): every cue of window.SF_SOUNDS, playable and editable.
|
|
2
|
+
|
|
3
|
+
Served by the local app (/api/runs/<id>/play/v<N>/sounds.html) it saves to the run: POST
|
|
4
|
+
/api/runs/<id>/sounds/v<N> makes a new locked sounds version and rewrites this build's
|
|
5
|
+
sounds.js. Opened from a folder it downloads the edited sounds.js to put in its place. */
|
|
6
|
+
(function () {
|
|
7
|
+
'use strict';
|
|
8
|
+
const data = window.SF_SOUNDS || {cues: [], presets: {}, moments: {}, volume: 0.8, style: ''};
|
|
9
|
+
const presets = data.presets || {};
|
|
10
|
+
const moments = data.moments || {};
|
|
11
|
+
const $ = id => document.getElementById(id);
|
|
12
|
+
const clone = o => JSON.parse(JSON.stringify(o));
|
|
13
|
+
const saved = () => clone({style: data.style || '', volume: data.volume, cues: data.cues || []});
|
|
14
|
+
let state = saved(), base = saved();
|
|
15
|
+
|
|
16
|
+
const run = location.pathname.match(/\/api\/runs\/([^/]+)\/play\/v(\d+)\//);
|
|
17
|
+
const saveUrl = run ? '/api/runs/' + run[1] + '/sounds/v' + run[2] : null;
|
|
18
|
+
$('save').hidden = !saveUrl;
|
|
19
|
+
$('title').textContent = (data.title ? data.title + ' · ' : '') + 'Sounds';
|
|
20
|
+
document.title = $('title').textContent;
|
|
21
|
+
|
|
22
|
+
const FIELDS = [ // [key, label, min, max, step]
|
|
23
|
+
['freq', 'pitch start (Hz)', 20, 12000, 1], ['freq_end', 'pitch end (Hz)', 20, 12000, 1],
|
|
24
|
+
['attack', 'attack (s)', 0, 1, 0.005], ['hold', 'hold (s)', 0, 2, 0.01],
|
|
25
|
+
['release', 'release (s)', 0.005, 2, 0.01], ['delay', 'delay (s)', 0, 2, 0.01],
|
|
26
|
+
['volume', 'volume', 0, 1, 0.05], ['cutoff', 'filter start (Hz)', 40, 16000, 10],
|
|
27
|
+
['cutoff_end', 'filter end (Hz)', 40, 16000, 10], ['q', 'filter Q', 0.1, 20, 0.1],
|
|
28
|
+
['wobble', 'wobble (Hz)', 0, 60, 0.5], ['wobble_depth', 'wobble depth', 0, 1, 0.01],
|
|
29
|
+
];
|
|
30
|
+
const WAVES = ['square', 'triangle', 'sine', 'sawtooth', 'noise'];
|
|
31
|
+
const FILTERS = ['none', 'lowpass', 'highpass', 'bandpass'];
|
|
32
|
+
|
|
33
|
+
function status(text, bad) {
|
|
34
|
+
$('status').textContent = text;
|
|
35
|
+
$('status').className = 'status' + (bad ? ' bad' : '');
|
|
36
|
+
}
|
|
37
|
+
const el = (tag, props, ...kids) => {
|
|
38
|
+
const e = Object.assign(document.createElement(tag), props || {});
|
|
39
|
+
for (const k of kids) if (k != null) e.append(k);
|
|
40
|
+
return e;
|
|
41
|
+
};
|
|
42
|
+
function select(options, value, onChange) {
|
|
43
|
+
const s = el('select');
|
|
44
|
+
for (const o of options) s.add(new Option(o.label || o, o.value == null ? o : o.value));
|
|
45
|
+
s.value = value;
|
|
46
|
+
s.onchange = () => onChange(s.value);
|
|
47
|
+
return s;
|
|
48
|
+
}
|
|
49
|
+
function number(value, min, max, step, onChange) {
|
|
50
|
+
const i = el('input', {type: 'number', min, max, step, value});
|
|
51
|
+
i.oninput = () => { const v = parseFloat(i.value); if (isFinite(v)) onChange(Math.max(min, Math.min(max, v))); };
|
|
52
|
+
return i;
|
|
53
|
+
}
|
|
54
|
+
function slider(value, onChange, min, max, step) {
|
|
55
|
+
const i = el('input', {type: 'range', min: min == null ? 0 : min, max: max == null ? 1 : max,
|
|
56
|
+
step: step || 0.05, value}); // fmt: skip
|
|
57
|
+
i.oninput = () => onChange(parseFloat(i.value));
|
|
58
|
+
return i;
|
|
59
|
+
}
|
|
60
|
+
const play = cue => {
|
|
61
|
+
if (!window.SFSynth.audio()) return status('This browser has no Web Audio', true);
|
|
62
|
+
window.SFSynth.play(cue, state.volume);
|
|
63
|
+
};
|
|
64
|
+
const layersOf = (name, pitch, length) => clone((presets[name] || {}).layers || []).map(Ly => {
|
|
65
|
+
for (const k of ['freq', 'freq_end', 'cutoff', 'cutoff_end']) Ly[k] *= pitch || 1;
|
|
66
|
+
for (const k of ['attack', 'hold', 'release', 'delay']) Ly[k] *= length || 1;
|
|
67
|
+
return Ly;
|
|
68
|
+
});
|
|
69
|
+
function changed(i) {
|
|
70
|
+
const card = $('cues').children[i];
|
|
71
|
+
if (card) card.classList.toggle('dirty', JSON.stringify(state.cues[i]) !== JSON.stringify(base.cues[i]));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function card(cue, i) {
|
|
75
|
+
const set = (k, v, redraw) => { cue[k] = v; changed(i); if (redraw) render(); };
|
|
76
|
+
const box = el('section', {className: 'cue', ariaLabel: 'Sound ' + cue.name});
|
|
77
|
+
const name = el('input', {type: 'text', className: 'name', value: cue.name, ariaLabel: 'Name'});
|
|
78
|
+
name.oninput = () => set('name', name.value.trim().toLowerCase().replace(/[^a-z0-9]+/g, '_'));
|
|
79
|
+
const on = el('input', {type: 'text', className: 'on', value: (cue.on || []).join(', ')});
|
|
80
|
+
on.setAttribute('list', 'moment-list');
|
|
81
|
+
on.oninput = () => {
|
|
82
|
+
const list = on.value.split(',').map(s => s.trim().toLowerCase().replace(/[^a-z0-9]+/g, '_')).filter(Boolean);
|
|
83
|
+
cue.on = list;
|
|
84
|
+
cue.loop = list.includes('move');
|
|
85
|
+
changed(i);
|
|
86
|
+
loopBox.hidden = !cue.loop;
|
|
87
|
+
};
|
|
88
|
+
const presetPick = select([{label: '— custom —', value: ''}, ...Object.keys(presets)], cue.preset || '', v => {
|
|
89
|
+
if (!v) return;
|
|
90
|
+
cue.layers = layersOf(v);
|
|
91
|
+
cue.preset = v;
|
|
92
|
+
if (presets[v].every) cue.every = presets[v].every;
|
|
93
|
+
changed(i);
|
|
94
|
+
render();
|
|
95
|
+
play(cue);
|
|
96
|
+
});
|
|
97
|
+
const tweak = (label, fn) => el('button', {type: 'button', textContent: label, onclick: () => {
|
|
98
|
+
cue.layers.forEach(fn);
|
|
99
|
+
changed(i);
|
|
100
|
+
render();
|
|
101
|
+
play(cue);
|
|
102
|
+
}}); // fmt: skip
|
|
103
|
+
const pitch = f => Ly => { Ly.freq *= f; Ly.freq_end *= f; Ly.cutoff *= f; Ly.cutoff_end *= f; };
|
|
104
|
+
const stretch = f => Ly => { for (const k of ['attack', 'hold', 'release', 'delay']) Ly[k] *= f; };
|
|
105
|
+
const loopBox = el('label', {hidden: !cue.loop}, 'repeat every (s) ',
|
|
106
|
+
number(cue.every || 0.3, 0.08, 2, 0.01, v => set('every', v))); // fmt: skip
|
|
107
|
+
box.append(
|
|
108
|
+
el('div', {className: 'row'},
|
|
109
|
+
el('button', {type: 'button', className: 'play', textContent: '▶', title: 'Play', onclick: () => play(cue)}),
|
|
110
|
+
name,
|
|
111
|
+
el('label', null, 'plays on ', on),
|
|
112
|
+
loopBox,
|
|
113
|
+
el('label', null, 'preset ', presetPick)),
|
|
114
|
+
el('div', {className: 'row'},
|
|
115
|
+
el('input', {type: 'text', className: 'what', value: cue.what || '', placeholder: 'what it sounds like',
|
|
116
|
+
oninput: e => set('what', e.target.value)}),
|
|
117
|
+
el('label', null, 'volume ', slider(cue.volume == null ? 1 : cue.volume, v => set('volume', v))),
|
|
118
|
+
el('label', null, 'variation ', slider(cue.jitter || 0, v => set('jitter', v), 0, 0.3, 0.01))),
|
|
119
|
+
el('div', {className: 'row tweaks'},
|
|
120
|
+
tweak('Higher', pitch(1.25)), tweak('Lower', pitch(0.8)), tweak('Shorter', stretch(0.8)),
|
|
121
|
+
tweak('Longer', stretch(1.25)),
|
|
122
|
+
el('button', {type: 'button', textContent: 'Duplicate', onclick: () => {
|
|
123
|
+
const copy = clone(cue);
|
|
124
|
+
copy.name = cue.name + '_copy';
|
|
125
|
+
state.cues.splice(i + 1, 0, copy);
|
|
126
|
+
render();
|
|
127
|
+
}}),
|
|
128
|
+
el('button', {type: 'button', textContent: 'Delete', onclick: () => {
|
|
129
|
+
if (!confirm('Delete the sound "' + cue.name + '"?')) return;
|
|
130
|
+
state.cues.splice(i, 1);
|
|
131
|
+
render();
|
|
132
|
+
}})),
|
|
133
|
+
layerEditor(cue, i));
|
|
134
|
+
return box;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function layerEditor(cue, i) {
|
|
138
|
+
const box = el('div', {className: 'layers'});
|
|
139
|
+
cue.layers.forEach((Ly, j) => {
|
|
140
|
+
const row = el('div', {className: 'layer'});
|
|
141
|
+
const custom = () => changed(i); // the preset stays what it started from
|
|
142
|
+
row.append(
|
|
143
|
+
el('label', null, 'wave', select(WAVES, Ly.wave, v => { Ly.wave = v; custom(); })),
|
|
144
|
+
el('label', null, 'filter', select(FILTERS, Ly.filter || 'none', v => { Ly.filter = v; custom(); })));
|
|
145
|
+
for (const [k, label, min, max, step] of FIELDS) {
|
|
146
|
+
row.append(el('label', null, label, number(Ly[k] == null ? 0 : Ly[k], min, max, step, v => { Ly[k] = v; custom(); })));
|
|
147
|
+
}
|
|
148
|
+
row.append(el('div', {className: 'tools'},
|
|
149
|
+
el('button', {type: 'button', textContent: '▶ this layer', onclick: () => play(Object.assign({}, cue, {layers: [Ly]}))}),
|
|
150
|
+
el('button', {type: 'button', textContent: 'Remove layer', disabled: cue.layers.length <= 1, onclick: () => {
|
|
151
|
+
cue.layers.splice(j, 1); custom(); render();
|
|
152
|
+
}})));
|
|
153
|
+
box.append(row);
|
|
154
|
+
});
|
|
155
|
+
const add = el('button', {type: 'button', textContent: '+ Add a layer', disabled: cue.layers.length >= 4, onclick: () => {
|
|
156
|
+
cue.layers.push(clone(cue.layers[cue.layers.length - 1] || layersOf('blip')[0]));
|
|
157
|
+
changed(i);
|
|
158
|
+
render();
|
|
159
|
+
}});
|
|
160
|
+
return el('details', {open: !!openLayers[cue.name], ontoggle: e => { openLayers[cue.name] = e.target.open; }},
|
|
161
|
+
el('summary', null, 'Layers (' + cue.layers.length + ')'), box, add); // fmt: skip
|
|
162
|
+
}
|
|
163
|
+
const openLayers = {};
|
|
164
|
+
|
|
165
|
+
function render() {
|
|
166
|
+
$('master').value = state.volume;
|
|
167
|
+
$('style').value = state.style || '';
|
|
168
|
+
const list = $('cues');
|
|
169
|
+
list.replaceChildren(...state.cues.map(card));
|
|
170
|
+
state.cues.forEach((_, i) => changed(i));
|
|
171
|
+
}
|
|
172
|
+
function payload() { return {style: state.style, volume: state.volume, cues: state.cues}; }
|
|
173
|
+
|
|
174
|
+
$('master').oninput = e => { state.volume = parseFloat(e.target.value); };
|
|
175
|
+
$('style').oninput = e => { state.style = e.target.value; };
|
|
176
|
+
$('play-all').onclick = () => {
|
|
177
|
+
state.cues.forEach((c, i) => setTimeout(() => play(c), i * 650));
|
|
178
|
+
};
|
|
179
|
+
$('reset').onclick = () => { state = clone(base); render(); status('Back to the saved sounds'); };
|
|
180
|
+
$('add').onclick = () => {
|
|
181
|
+
const names = new Set(state.cues.map(c => c.name));
|
|
182
|
+
let n = 1;
|
|
183
|
+
while (names.has('new_sound_' + n)) n++;
|
|
184
|
+
state.cues.push({name: 'new_sound_' + n, on: ['menu_select'], what: '', preset: 'blip',
|
|
185
|
+
layers: layersOf('blip'), volume: 1, loop: false, every: 0.3, jitter: 0.04, match: []}); // fmt: skip
|
|
186
|
+
render();
|
|
187
|
+
};
|
|
188
|
+
$('download').onclick = () => {
|
|
189
|
+
const out = Object.assign({}, data, payload());
|
|
190
|
+
const blob = new Blob(['window.SF_SOUNDS = ' + JSON.stringify(out, null, 1) + ';\n'], {type: 'text/javascript'});
|
|
191
|
+
const a = el('a', {href: URL.createObjectURL(blob), download: 'sounds.js'});
|
|
192
|
+
document.body.append(a);
|
|
193
|
+
a.click();
|
|
194
|
+
a.remove();
|
|
195
|
+
status('Downloaded: put sounds.js next to index.html (replacing the old one) and reload the game');
|
|
196
|
+
};
|
|
197
|
+
$('save').onclick = async () => {
|
|
198
|
+
$('save').disabled = true;
|
|
199
|
+
status('Saving…');
|
|
200
|
+
try {
|
|
201
|
+
const r = await fetch(saveUrl, {method: 'POST', headers: {'Content-Type': 'application/json'},
|
|
202
|
+
body: JSON.stringify({sounds: payload()})}); // fmt: skip
|
|
203
|
+
const answer = await r.json();
|
|
204
|
+
if (!r.ok) throw new Error(typeof answer.detail === 'string' ? answer.detail : JSON.stringify(answer.detail));
|
|
205
|
+
Object.assign(data, answer.script);
|
|
206
|
+
state = saved();
|
|
207
|
+
base = saved();
|
|
208
|
+
render();
|
|
209
|
+
const extra = (answer.notes || []).concat(answer.problems || []);
|
|
210
|
+
status('Saved as sounds v' + answer.version + '. Reload the game to hear it.' + (extra.length ? ' Code: ' + extra.join('; ') : ''));
|
|
211
|
+
} catch (e) {
|
|
212
|
+
status('Not saved: ' + e.message, true);
|
|
213
|
+
} finally {
|
|
214
|
+
$('save').disabled = false;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const ml = $('moment-list'), mb = $('moments');
|
|
219
|
+
for (const [m, what] of Object.entries(moments)) {
|
|
220
|
+
ml.append(el('option', {value: m}));
|
|
221
|
+
mb.append(el('div', null, el('code', null, m), ' ', what));
|
|
222
|
+
}
|
|
223
|
+
render();
|
|
224
|
+
window.sfEditor = {state: () => state, payload, render};
|
|
225
|
+
})();
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/* SpriteForge sound (L2.7): the Sound Director's cues, synthesised in the browser with Web Audio.
|
|
2
|
+
|
|
3
|
+
A build with sounds loads sounds.js (window.SF_SOUNDS: cues, the preset library, the moments)
|
|
4
|
+
and this file right after sf.js. No audio files: every cue is one to four synth layers (a
|
|
5
|
+
square, triangle, sine or sawtooth tone, or noise) with a pitch slide, an envelope (attack,
|
|
6
|
+
hold, release), an optional filter sweep and a wobble.
|
|
7
|
+
|
|
8
|
+
window.SFSynth.play(cue, volume) / SFSynth.render(cue) work without the game (the sound
|
|
9
|
+
editor, sounds.html, uses them). With the game (window.sf):
|
|
10
|
+
* every sf.event(name) and sf.fx(name, x, y, target, hint) is a moment; the cue whose `on`
|
|
11
|
+
names it plays. Several cues on one moment: the one whose name or `match` shares a word
|
|
12
|
+
with what happened (the thing's entity, the form) plays, as sf.fx picks its effect.
|
|
13
|
+
* loops (`on: ['move']`) repeat every `every` seconds while the player moves on the ground
|
|
14
|
+
(levels as data) or moves at all (other games, from sf.state.x/y).
|
|
15
|
+
* sf.sound.play(name) plays a cue by its name; sf.sound.moment(name, hint) a moment.
|
|
16
|
+
* sf.settings.sound (on/off) and sf.settings.volume; M toggles the sound (saved with the
|
|
17
|
+
menus' settings). Browsers start audio only after a key press or a click.
|
|
18
|
+
* Playtests and recordings (?headless, ?capture) make no sound but count every cue that
|
|
19
|
+
would have played in sf.soundCount, so the harness can tell which sounds were heard. */
|
|
20
|
+
(function () {
|
|
21
|
+
'use strict';
|
|
22
|
+
|
|
23
|
+
/* ---------- the synth (no game needed) ----------------------------------------------------- */
|
|
24
|
+
const MAX_VOICES = 14;
|
|
25
|
+
let live = 0;
|
|
26
|
+
const noiseBuffers = new WeakMap();
|
|
27
|
+
function noise(ac) {
|
|
28
|
+
let b = noiseBuffers.get(ac);
|
|
29
|
+
if (!b) {
|
|
30
|
+
b = ac.createBuffer(1, ac.sampleRate, ac.sampleRate);
|
|
31
|
+
const d = b.getChannelData(0);
|
|
32
|
+
let s = 22222; // fixed noise: the same cue sounds the same every time
|
|
33
|
+
for (let i = 0; i < d.length; i++) { s = (Math.imul(s, 1103515245) + 12345) >>> 0; d[i] = s / 2147483648 - 1; }
|
|
34
|
+
noiseBuffers.set(ac, b);
|
|
35
|
+
}
|
|
36
|
+
return b;
|
|
37
|
+
}
|
|
38
|
+
const num = (v, lo, hi, dflt) => { v = Number(v); return isFinite(v) ? Math.max(lo, Math.min(hi, v)) : dflt; };
|
|
39
|
+
|
|
40
|
+
// One layer into `out`, starting at t0; returns when it ends. `rate` scales pitch and cutoff.
|
|
41
|
+
function layer(ac, Ly, t0, rate, out) {
|
|
42
|
+
const start = t0 + num(Ly.delay, 0, 2, 0);
|
|
43
|
+
const a = num(Ly.attack, 0.001, 1, 0.005), h = num(Ly.hold, 0, 2, 0.03), r = num(Ly.release, 0.005, 2, 0.1);
|
|
44
|
+
const end = start + a + h + r;
|
|
45
|
+
const isNoise = Ly.wave === 'noise';
|
|
46
|
+
let src;
|
|
47
|
+
if (isNoise) {
|
|
48
|
+
src = ac.createBufferSource();
|
|
49
|
+
src.buffer = noise(ac);
|
|
50
|
+
src.loop = true;
|
|
51
|
+
} else {
|
|
52
|
+
src = ac.createOscillator();
|
|
53
|
+
src.type = ['square', 'triangle', 'sine', 'sawtooth'].includes(Ly.wave) ? Ly.wave : 'square';
|
|
54
|
+
const f0 = num(Ly.freq, 20, 12000, 440) * rate, f1 = num(Ly.freq_end, 20, 12000, f0) * rate;
|
|
55
|
+
src.frequency.setValueAtTime(f0, start);
|
|
56
|
+
src.frequency.exponentialRampToValueAtTime(Math.max(20, f1), end);
|
|
57
|
+
}
|
|
58
|
+
let node = src, filter = null;
|
|
59
|
+
if (['lowpass', 'highpass', 'bandpass'].includes(Ly.filter)) {
|
|
60
|
+
filter = ac.createBiquadFilter();
|
|
61
|
+
filter.type = Ly.filter;
|
|
62
|
+
filter.Q.value = num(Ly.q, 0.1, 20, 1);
|
|
63
|
+
const c0 = num(Ly.cutoff, 40, 16000, 2000) * rate, c1 = num(Ly.cutoff_end, 40, 16000, c0) * rate;
|
|
64
|
+
filter.frequency.setValueAtTime(Math.min(c0, ac.sampleRate / 2 - 1), start);
|
|
65
|
+
filter.frequency.exponentialRampToValueAtTime(Math.max(40, Math.min(c1, ac.sampleRate / 2 - 1)), end);
|
|
66
|
+
node.connect(filter);
|
|
67
|
+
node = filter;
|
|
68
|
+
}
|
|
69
|
+
const env = ac.createGain();
|
|
70
|
+
const vol = num(Ly.volume, 0, 1, 0.3);
|
|
71
|
+
env.gain.setValueAtTime(0, start);
|
|
72
|
+
env.gain.linearRampToValueAtTime(vol, start + a);
|
|
73
|
+
env.gain.setValueAtTime(vol, start + a + h);
|
|
74
|
+
env.gain.exponentialRampToValueAtTime(0.0001, end);
|
|
75
|
+
node.connect(env);
|
|
76
|
+
let tail = env;
|
|
77
|
+
const wob = num(Ly.wobble, 0, 60, 0), depth = num(Ly.wobble_depth, 0, 1, 0);
|
|
78
|
+
let lfo = null;
|
|
79
|
+
if (wob > 0 && depth > 0) {
|
|
80
|
+
lfo = ac.createOscillator();
|
|
81
|
+
lfo.frequency.value = wob;
|
|
82
|
+
const amount = ac.createGain();
|
|
83
|
+
if (!isNoise) { amount.gain.value = depth * num(Ly.freq, 20, 12000, 440) * rate; lfo.connect(amount).connect(src.frequency); }
|
|
84
|
+
else if (filter) { amount.gain.value = depth * num(Ly.cutoff, 40, 16000, 2000) * rate; lfo.connect(amount).connect(filter.frequency); }
|
|
85
|
+
else { // noise with no filter: a tremolo
|
|
86
|
+
const trem = ac.createGain();
|
|
87
|
+
trem.gain.value = 1 - depth / 2;
|
|
88
|
+
amount.gain.value = depth / 2;
|
|
89
|
+
lfo.connect(amount).connect(trem.gain);
|
|
90
|
+
env.connect(trem);
|
|
91
|
+
tail = trem;
|
|
92
|
+
}
|
|
93
|
+
lfo.start(start);
|
|
94
|
+
lfo.stop(end);
|
|
95
|
+
}
|
|
96
|
+
tail.connect(out);
|
|
97
|
+
src.start(start);
|
|
98
|
+
src.stop(end + 0.02);
|
|
99
|
+
return end;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const SFSynth = (window.SFSynth = {
|
|
103
|
+
ctx: null,
|
|
104
|
+
// The cue now, at `volume` (0-1, times the cue's own); `rate` shifts its pitch (1 = as is).
|
|
105
|
+
play(cue, volume, rate, ac) {
|
|
106
|
+
ac = ac || SFSynth.audio();
|
|
107
|
+
if (!ac || !cue || !cue.layers || !cue.layers.length || live >= MAX_VOICES) return 0;
|
|
108
|
+
const out = ac.createGain();
|
|
109
|
+
out.gain.value = num(volume == null ? 1 : volume, 0, 1, 1) * num(cue.volume, 0, 1, 1);
|
|
110
|
+
out.connect(ac.destination);
|
|
111
|
+
const t0 = ac.currentTime + 0.005;
|
|
112
|
+
let end = t0;
|
|
113
|
+
for (const Ly of cue.layers.slice(0, 4)) end = Math.max(end, layer(ac, Ly, t0, rate || 1, out));
|
|
114
|
+
live++;
|
|
115
|
+
setTimeout(() => { live--; try { out.disconnect(); } catch (e) { /* already gone */ } },
|
|
116
|
+
Math.max(50, (end - ac.currentTime) * 1000 + 60)); // fmt: skip
|
|
117
|
+
return end - t0;
|
|
118
|
+
},
|
|
119
|
+
audio() {
|
|
120
|
+
if (!SFSynth.ctx) {
|
|
121
|
+
const AC = window.AudioContext || window.webkitAudioContext;
|
|
122
|
+
if (!AC) return null;
|
|
123
|
+
try { SFSynth.ctx = new AC(); } catch (e) { return null; }
|
|
124
|
+
}
|
|
125
|
+
if (SFSynth.ctx.state === 'suspended') SFSynth.ctx.resume().catch(() => {});
|
|
126
|
+
return SFSynth.ctx;
|
|
127
|
+
},
|
|
128
|
+
// Offline: the cue rendered to samples -> {seconds, peak, rms} (tests, the editor's meter).
|
|
129
|
+
render(cue, rate) {
|
|
130
|
+
const OAC = window.OfflineAudioContext || window.webkitOfflineAudioContext;
|
|
131
|
+
const seconds = Math.min(4, 0.1 + Math.max(...(cue.layers || []).map(Ly =>
|
|
132
|
+
num(Ly.delay, 0, 2, 0) + num(Ly.attack, 0.001, 1, 0.005) + num(Ly.hold, 0, 2, 0) + num(Ly.release, 0.005, 2, 0.1)), 0));
|
|
133
|
+
const ac = new OAC(1, Math.ceil(22050 * seconds), 22050);
|
|
134
|
+
const out = ac.createGain();
|
|
135
|
+
out.gain.value = num(cue.volume, 0, 1, 1);
|
|
136
|
+
out.connect(ac.destination);
|
|
137
|
+
for (const Ly of (cue.layers || []).slice(0, 4)) layer(ac, Ly, 0, rate || 1, out);
|
|
138
|
+
return ac.startRendering().then(buf => {
|
|
139
|
+
const d = buf.getChannelData(0);
|
|
140
|
+
let peak = 0, sum = 0;
|
|
141
|
+
for (let i = 0; i < d.length; i++) { const v = Math.abs(d[i]); if (v > peak) peak = v; sum += d[i] * d[i]; }
|
|
142
|
+
return {seconds, peak, rms: Math.sqrt(sum / Math.max(1, d.length))};
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
/* ---------- the game's sounds -------------------------------------------------------------- */
|
|
148
|
+
const sf = window.sf;
|
|
149
|
+
const S = window.SF_SOUNDS || null;
|
|
150
|
+
if (!sf) return; // the sound editor: the synth only
|
|
151
|
+
const sound = (sf.sound = {active: !!S, data: S, count: {}, last: {}});
|
|
152
|
+
sf.soundCount = sound.count;
|
|
153
|
+
if (sf.settings.sound == null) sf.settings.sound = true;
|
|
154
|
+
if (sf.settings.volume == null) sf.settings.volume = 1;
|
|
155
|
+
if (!S) { sound.play = sound.moment = () => null; return; }
|
|
156
|
+
|
|
157
|
+
const silent = sf.flags.headless || sf.flags.capture; // tests and recordings: count only
|
|
158
|
+
const cues = () => (sf.sound.data && sf.sound.data.cues) || [];
|
|
159
|
+
const words = s => String(s || '').toLowerCase().split(/[^a-z0-9]+/).filter(w => w.length > 2);
|
|
160
|
+
let jitterSeed = 777;
|
|
161
|
+
const jitterRand = () => ((jitterSeed = (Math.imul(jitterSeed, 1103515245) + 12345) >>> 0) / 4294967296);
|
|
162
|
+
let frame = 0;
|
|
163
|
+
|
|
164
|
+
function fire(cue) {
|
|
165
|
+
// One cue at most every 3 steps: a moment the SDK sees twice (sf.event('jump') and
|
|
166
|
+
// sf.fx('jump') in the same step) plays once.
|
|
167
|
+
if (sound.last[cue.name] != null && frame - sound.last[cue.name] < 3) return null;
|
|
168
|
+
sound.last[cue.name] = frame;
|
|
169
|
+
sound.count[cue.name] = (sound.count[cue.name] || 0) + 1;
|
|
170
|
+
if (silent || !sf.settings.sound) return cue.name;
|
|
171
|
+
const rate = 1 + (jitterRand() * 2 - 1) * (+cue.jitter || 0);
|
|
172
|
+
SFSynth.play(cue, (+sf.sound.data.volume || 0) * num(sf.settings.volume, 0, 1, 1), rate);
|
|
173
|
+
return cue.name;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// The cue for a moment: among those whose `on` names it (loops excluded), the one sharing a
|
|
177
|
+
// word with what happened, else the one named after the moment, else the first.
|
|
178
|
+
sound.pick = function (moment, hint) {
|
|
179
|
+
const list = cues().filter(c => !c.loop && (c.on || []).includes(moment));
|
|
180
|
+
if (list.length <= 1) return list[0] || null;
|
|
181
|
+
const want = new Set(words(hint));
|
|
182
|
+
if (want.size) {
|
|
183
|
+
const hit = list.find(c => words(c.name).concat(...(c.match || []).map(words)).some(w => want.has(w)));
|
|
184
|
+
if (hit) return hit;
|
|
185
|
+
}
|
|
186
|
+
return list.find(c => c.name === moment) || list[0];
|
|
187
|
+
};
|
|
188
|
+
sound.moment = function (moment, hint) {
|
|
189
|
+
const cue = sound.pick(String(moment), hint);
|
|
190
|
+
return cue ? fire(cue) : null;
|
|
191
|
+
};
|
|
192
|
+
sound.play = function (name) {
|
|
193
|
+
const cue = cues().find(c => c.name === name);
|
|
194
|
+
return cue ? fire(cue) : null;
|
|
195
|
+
};
|
|
196
|
+
sound.toggle = function () {
|
|
197
|
+
const on = !sf.settings.sound;
|
|
198
|
+
if (sf.flow && sf.flow.setSound) sf.flow.setSound(on); else sf.settings.sound = on;
|
|
199
|
+
if (on) SFSynth.audio();
|
|
200
|
+
return on;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// Moments: every event and every effect the game or the SDK plays.
|
|
204
|
+
const hintOf = data => (data && typeof data === 'object')
|
|
205
|
+
? Object.values(data).filter(v => typeof v === 'string').join(' ') : '';
|
|
206
|
+
const event = sf.event;
|
|
207
|
+
sf.event = function (name, data) {
|
|
208
|
+
event(name, data);
|
|
209
|
+
try { sound.moment(name, hintOf(data)); } catch (e) { sf.errors.push('sound: ' + e.message); }
|
|
210
|
+
};
|
|
211
|
+
const fx = sf.fx;
|
|
212
|
+
sf.fx = function (name, x, y, target, hint) {
|
|
213
|
+
const n = fx.apply(this, arguments);
|
|
214
|
+
try { sound.moment(name, hint); } catch (e) { sf.errors.push('sound: ' + e.message); }
|
|
215
|
+
return n;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// Loops: `move` while the player moves (on the ground, for levels as data).
|
|
219
|
+
let lastX = null, lastY = null;
|
|
220
|
+
function moving() {
|
|
221
|
+
const lv = sf.level && sf.level.current;
|
|
222
|
+
if (lv && lv.player && lv.player.body) {
|
|
223
|
+
return !!lv.grounded && Math.abs(lv.player.body.velocity.x) > 10 && !lv.over;
|
|
224
|
+
}
|
|
225
|
+
const st = sf.state || {};
|
|
226
|
+
if (typeof st.x !== 'number' || typeof st.y !== 'number') return false;
|
|
227
|
+
const moved = lastX != null && Math.hypot(st.x - lastX, st.y - lastY) > 0.3;
|
|
228
|
+
lastX = st.x; lastY = st.y;
|
|
229
|
+
return moved;
|
|
230
|
+
}
|
|
231
|
+
const loopAt = {};
|
|
232
|
+
function step() {
|
|
233
|
+
frame++;
|
|
234
|
+
if (sf.paused || !sf.ready) return;
|
|
235
|
+
const loops = cues().filter(c => c.loop);
|
|
236
|
+
if (!loops.length) return;
|
|
237
|
+
const now = sf.clock.now, on = moving();
|
|
238
|
+
for (const c of loops) {
|
|
239
|
+
if ((c.on || []).includes('move') && on) {
|
|
240
|
+
if (loopAt[c.name] == null || now - loopAt[c.name] >= Math.max(0.08, +c.every || 0.3)) {
|
|
241
|
+
loopAt[c.name] = now;
|
|
242
|
+
fire(c);
|
|
243
|
+
}
|
|
244
|
+
} else loopAt[c.name] = null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const start = sf.start;
|
|
248
|
+
sf.start = function (opts) {
|
|
249
|
+
start(opts);
|
|
250
|
+
if (sf.game) sf.game.events.on('poststep', step);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// Browsers allow audio after a gesture; M toggles the sound.
|
|
254
|
+
const wake = () => { if (!silent && sf.settings.sound) SFSynth.audio(); };
|
|
255
|
+
window.addEventListener('pointerdown', wake, true);
|
|
256
|
+
window.addEventListener('keydown', e => {
|
|
257
|
+
if (e.key === 'm' || e.key === 'M') { if (!e.repeat) sound.toggle(); return; }
|
|
258
|
+
wake();
|
|
259
|
+
}, true);
|
|
260
|
+
})();
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en"><head><meta charset="utf-8">
|
|
3
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
4
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; connect-src 'self'">
|
|
5
|
+
<title>Sound editor</title>
|
|
6
|
+
<style>
|
|
7
|
+
:root{--bg:#10121c;--panel:#1a1d2b;--line:#33384d;--text:#e8e8f0;--muted:#94a0b8;--accent:#9ae6b4;--warn:#ffb4b4;--gold:#f4d35e}
|
|
8
|
+
*{box-sizing:border-box}
|
|
9
|
+
body{margin:0;background:var(--bg);color:var(--text);font:14px/1.45 system-ui,sans-serif}
|
|
10
|
+
header{position:sticky;top:0;z-index:2;background:var(--bg);border-bottom:1px solid var(--line);padding:12px 16px;display:flex;flex-wrap:wrap;gap:10px 16px;align-items:center}
|
|
11
|
+
h1{font-size:18px;margin:0 12px 0 0}
|
|
12
|
+
main{max-width:1100px;margin:0 auto;padding:16px}
|
|
13
|
+
button,select,input{font:inherit;color:var(--text);background:#232739;border:1px solid var(--line);border-radius:6px}
|
|
14
|
+
button{padding:6px 12px;cursor:pointer}button:hover{border-color:var(--accent)}
|
|
15
|
+
button.primary{background:#2c5a3f;border-color:var(--accent)}
|
|
16
|
+
button.play{min-width:44px;font-size:16px}
|
|
17
|
+
input[type=text]{padding:5px 8px}input[type=number]{width:84px;padding:4px 6px}
|
|
18
|
+
input[type=range]{accent-color:var(--accent);vertical-align:middle}
|
|
19
|
+
label{color:var(--muted);font-size:12px}
|
|
20
|
+
.status{color:var(--accent);min-height:1.4em}.status.bad{color:var(--warn)}
|
|
21
|
+
.cue{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:12px;margin:0 0 12px}
|
|
22
|
+
.cue.dirty{border-color:var(--gold)}
|
|
23
|
+
.row{display:flex;flex-wrap:wrap;gap:8px 14px;align-items:center}
|
|
24
|
+
.row+.row{margin-top:8px}
|
|
25
|
+
.name{font-weight:600;width:220px}
|
|
26
|
+
.what{flex:1 1 320px}
|
|
27
|
+
.on{width:240px}
|
|
28
|
+
.tweaks button{padding:4px 8px;font-size:12px}
|
|
29
|
+
details{margin-top:8px}summary{cursor:pointer;color:var(--muted)}
|
|
30
|
+
.layers{display:grid;gap:8px;margin-top:8px}
|
|
31
|
+
.layer{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:6px 10px;padding:8px;border:1px dashed var(--line);border-radius:8px}
|
|
32
|
+
.layer label{display:flex;flex-direction:column;gap:2px}
|
|
33
|
+
.layer .tools{grid-column:1/-1;display:flex;gap:8px;justify-content:flex-end}
|
|
34
|
+
.muted{color:var(--muted)}
|
|
35
|
+
.moments{columns:2 280px;font-size:13px}
|
|
36
|
+
.moments div{break-inside:avoid;margin:0 0 4px}
|
|
37
|
+
code{color:var(--gold)}
|
|
38
|
+
a{color:var(--accent)}
|
|
39
|
+
@media (max-width:600px){.name,.on{width:100%}}
|
|
40
|
+
</style>
|
|
41
|
+
</head><body>
|
|
42
|
+
<header>
|
|
43
|
+
<h1 id="title">Sound editor</h1>
|
|
44
|
+
<label>Master volume <input id="master" type="range" min="0" max="1" step="0.05"></label>
|
|
45
|
+
<label>Style <input id="style" type="text" size="28"></label>
|
|
46
|
+
<button id="play-all" type="button">▶ Play all</button>
|
|
47
|
+
<button id="save" type="button" class="primary" hidden>Save to the game</button>
|
|
48
|
+
<button id="download" type="button">⬇ Download sounds.js</button>
|
|
49
|
+
<button id="reset" type="button">Undo all changes</button>
|
|
50
|
+
<a id="game" href="index.html" target="_blank" rel="noopener">Open the game</a>
|
|
51
|
+
<span id="status" class="status" role="status"></span>
|
|
52
|
+
</header>
|
|
53
|
+
<main>
|
|
54
|
+
<p class="muted">Every sound is synthesised by the game itself (no audio files). Press ▶ to hear a
|
|
55
|
+
sound, change its preset or the quick tweaks, or open its layers to shape it. A sound plays on
|
|
56
|
+
the moments in <em>plays on</em> (comma separated); a <em>loop</em> repeats while its moment
|
|
57
|
+
lasts (<code>move</code>: while the player moves). Saving here makes a new locked version of the
|
|
58
|
+
sounds; reload the game to hear it. In the game, <b>M</b> turns the sound on or off.</p>
|
|
59
|
+
<div id="cues"></div>
|
|
60
|
+
<button id="add" type="button">+ Add a sound</button>
|
|
61
|
+
<details><summary>Moments the game plays sounds on</summary><div id="moments" class="moments"></div></details>
|
|
62
|
+
</main>
|
|
63
|
+
<datalist id="moment-list"></datalist>
|
|
64
|
+
<script src="sounds.js"></script>
|
|
65
|
+
<script src="sfsound.js"></script>
|
|
66
|
+
<script src="sfsound-editor.js"></script>
|
|
67
|
+
</body></html>
|