CyberMax-tools commited on
Commit
c9beafa
·
verified ·
1 Parent(s): 263f240

Deploy blipwren to the hub

Browse files
Files changed (3) hide show
  1. blipwren/app.js +185 -8
  2. blipwren/index.html +35 -1
  3. blipwren/style.css +36 -3
blipwren/app.js CHANGED
@@ -7,7 +7,29 @@
7
  var ctx = null, gain = null, meta = null, cat = "all", query = "";
8
  var buffers = {}; // sprite id or "free:<id>" -> AudioBuffer
9
  var tiles = {}; // sound id -> {el, canvas, s}
10
- var current = null, playAllToken = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  function audio() {
13
  if (!ctx) {
@@ -49,7 +71,7 @@
49
  src.buffer = buf;
50
  if ($("#vary").checked) src.playbackRate.value = 1 + (Math.random() * 0.1 - 0.05);
51
  src.connect(gain);
52
- var tile = tiles[s.id].el;
53
  tile.classList.add("playing");
54
  var dur = s.free ? buf.duration : s.len;
55
  if (s.free) src.start(0); else src.start(0, s.at, s.len);
@@ -119,8 +141,13 @@
119
  el.appendChild(foot);
120
  }
121
  el.addEventListener("click", function () { playAllToken++; play(s); });
122
- tiles[s.id] = { el: el, canvas: el.querySelector("canvas"), s: s };
123
- grid.appendChild(el);
 
 
 
 
 
124
  });
125
  }
126
 
@@ -133,7 +160,7 @@
133
 
134
  function filter() {
135
  var vis = {}; shown().forEach(function (s) { vis[s.id] = 1; });
136
- Object.keys(tiles).forEach(function (id) { tiles[id].el.hidden = !vis[id]; });
137
  var n = Object.keys(vis).length;
138
  $("#status").textContent = n ? n + " sound" + (n === 1 ? "" : "s") + " · tap to play" : "No sounds match “" + query + "”.";
139
  Object.keys(vis).forEach(function (id) { drawWave(tiles[id].s); });
@@ -144,7 +171,7 @@
144
  function next() {
145
  if (token !== playAllToken || i >= list.length) return;
146
  var s = list[i++];
147
- tiles[s.id].el.scrollIntoView({ block: "nearest", behavior: "smooth" });
148
  play(s).then(function (d) { setTimeout(next, (d + 0.25) * 1000); });
149
  }
150
  next();
@@ -184,15 +211,165 @@
184
  if (/^https:\/\//.test(BUNDLE)) bundle.href = BUNDLE; else bundle.parentNode.hidden = true;
185
  }
186
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  $("#vol").addEventListener("input", function () { if (gain) gain.gain.value = this.value / 100; });
188
  $("#q").addEventListener("input", function () { query = this.value.trim().toLowerCase(); filter(); });
189
  $("#playall").addEventListener("click", playAll);
190
- document.addEventListener("keydown", function (e) { if (e.key === "Escape") { playAllToken++; if (current) try { current.src.stop(); } catch (x) {} } });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  tabs(); links();
192
  if (/[?&]thanks=1/.test(location.search)) setTimeout(function () { toast("Thanks for your order! Your download link is in the Polar receipt email."); }, 800);
193
 
194
  fetch("sounds.json").then(function (r) { return r.json(); }).then(function (m) {
195
- meta = m; buildChips(); buildGrid(); filter(); preload();
 
 
 
196
  var hash = decodeURIComponent((location.hash.match(/^#s=([\w]+)/) || [])[1] || "");
197
  if (hash && tiles[hash]) tiles[hash].el.scrollIntoView({ block: "center" });
198
  }).catch(function () { $("#status").textContent = "Couldn't load the sound list. Please reload the page."; });
 
7
  var ctx = null, gain = null, meta = null, cat = "all", query = "";
8
  var buffers = {}; // sprite id or "free:<id>" -> AudioBuffer
9
  var tiles = {}; // sound id -> {el, canvas, s}
10
+ var current = null, playAllToken = 0, last = null;
11
+ var CAT = {}; // category id -> label
12
+
13
+ function scope(s, buf) { // hero waveform of the sound playing now
14
+ var c = $("#scope"); if (!c || !buf || typeof buf.then === "function") return;
15
+ var dpr = window.devicePixelRatio || 1, w = c.clientWidth || 520, h = c.clientHeight || 70;
16
+ c.width = Math.round(w * dpr); c.height = Math.round(h * dpr);
17
+ var g = c.getContext("2d"); g.scale(dpr, dpr);
18
+ g.fillStyle = "#11141B"; g.fillRect(0, 0, w, h);
19
+ g.strokeStyle = "#2c3246"; g.beginPath(); g.moveTo(0, h / 2); g.lineTo(w, h / 2); g.stroke();
20
+ var data = buf.getChannelData(0), sr = buf.sampleRate;
21
+ var a = s.free ? 0 : Math.floor(s.at * sr), n = s.free ? data.length : Math.floor(s.len * sr);
22
+ var cols = Math.floor(w / 3), step = n / cols;
23
+ var grad = g.createLinearGradient(0, 0, w, 0); grad.addColorStop(0, "#FFB020"); grad.addColorStop(1, s.free ? "#34d399" : "#8f7bff");
24
+ g.fillStyle = grad;
25
+ for (var i = 0; i < cols; i++) {
26
+ var peak = 0, from = a + Math.floor(i * step), to = a + Math.floor((i + 1) * step);
27
+ for (var k = from; k < to; k += 2) { var v = Math.abs(data[k] || 0); if (v > peak) peak = v; }
28
+ var bh = Math.max(2, peak * (h - 6)); g.fillRect(i * 3, (h - bh) / 2, 2, bh);
29
+ }
30
+ $("#scope-name").textContent = s.name;
31
+ $("#scope-meta").textContent = (CAT[s.cat] || s.cat) + " · " + s.dur.toFixed(2) + " s · " + (s.free ? "FREE" : "in the pack");
32
+ }
33
 
34
  function audio() {
35
  if (!ctx) {
 
71
  src.buffer = buf;
72
  if ($("#vary").checked) src.playbackRate.value = 1 + (Math.random() * 0.1 - 0.05);
73
  src.connect(gain);
74
+ var tile = tiles[s.id].el; last = s; scope(s, buf);
75
  tile.classList.add("playing");
76
  var dur = s.free ? buf.duration : s.len;
77
  if (s.free) src.start(0); else src.start(0, s.at, s.len);
 
141
  el.appendChild(foot);
142
  }
143
  el.addEventListener("click", function () { playAllToken++; play(s); });
144
+ var wrap = document.createElement("div"); wrap.className = "tile";
145
+ var add = document.createElement("button"); add.type = "button"; add.className = "add"; add.textContent = "+";
146
+ add.setAttribute("aria-label", "Add " + s.name + " to your game's list");
147
+ add.addEventListener("click", function () { Plan.toggle(s.id); });
148
+ wrap.appendChild(el); wrap.appendChild(add);
149
+ tiles[s.id] = { el: el, wrap: wrap, add: add, canvas: el.querySelector("canvas"), s: s };
150
+ grid.appendChild(wrap);
151
  });
152
  }
153
 
 
160
 
161
  function filter() {
162
  var vis = {}; shown().forEach(function (s) { vis[s.id] = 1; });
163
+ Object.keys(tiles).forEach(function (id) { tiles[id].wrap.hidden = !vis[id]; });
164
  var n = Object.keys(vis).length;
165
  $("#status").textContent = n ? n + " sound" + (n === 1 ? "" : "s") + " · tap to play" : "No sounds match “" + query + "”.";
166
  Object.keys(vis).forEach(function (id) { drawWave(tiles[id].s); });
 
171
  function next() {
172
  if (token !== playAllToken || i >= list.length) return;
173
  var s = list[i++];
174
+ tiles[s.id].wrap.scrollIntoView({ block: "nearest", behavior: "smooth" });
175
  play(s).then(function (d) { setTimeout(next, (d + 0.25) * 1000); });
176
  }
177
  next();
 
211
  if (/^https:\/\//.test(BUNDLE)) bundle.href = BUNDLE; else bundle.parentNode.hidden = true;
212
  }
213
 
214
+
215
+ /* ---------- Plan your game's sounds ---------- */
216
+ var PRESETS = [
217
+ { id: "platformer", label: "Platformer", list: [["jump", "movement_jump_small"], ["double_jump", "movement_jump_double"], ["land", "movement_land_soft"], ["coin", "pickups_coin"], ["power_up", "pickups_power_up"], ["extra_life", "pickups_extra_life"], ["stomp_enemy", "combat_enemy_die"], ["player_hurt", "combat_hurt_player"], ["spring", "movement_spring_bounce"], ["checkpoint", "jingles_checkpoint"], ["level_clear", "jingles_level_complete"], ["game_over", "jingles_game_over"], ["menu_confirm", "ui_confirm"], ["pause", "jingles_pause"]] },
218
+ { id: "shooter", label: "Space shooter", list: [["shoot", "scifi_laser_shot"], ["rapid_fire", "scifi_laser_rapid"], ["charge_shot", "scifi_charge_release"], ["enemy_hit", "combat_hit_light"], ["enemy_explode", "explosions_explosion_small"], ["boss_explode", "explosions_explosion_big"], ["shield_up", "scifi_shield_up"], ["shield_down", "scifi_shield_down"], ["power_up", "pickups_power_up"], ["alarm", "scifi_alarm_alert"], ["warp_in", "scifi_warp"], ["high_score", "jingles_high_score"], ["game_over", "jingles_game_over"]] },
219
+ { id: "rpg", label: "RPG / adventure", list: [["sword_swing", "combat_sword_swing"], ["sword_hit", "combat_sword_hit"], ["block", "combat_block_clang"], ["cast_spell", "magic_spell_cast"], ["fireball", "magic_fireball"], ["heal", "magic_heal"], ["open_chest", "pickups_item_get"], ["get_key", "pickups_key"], ["footstep", "movement_footstep_stone"], ["quest_done", "jingles_quest_complete"], ["level_up", "jingles_level_up"], ["secret", "jingles_secret_found"], ["menu_open", "ui_menu_open"], ["menu_close", "ui_menu_close"]] },
220
+ { id: "puzzle", label: "Puzzle / casual", list: [["tap", "ui_click_soft"], ["select", "ui_select"], ["match", "pickups_collect_chime"], ["combo", "pickups_coin_double"], ["big_combo", "pickups_gem_big"], ["wrong_move", "ui_error_buzz"], ["hint", "ui_notify"], ["star", "pickups_star"], ["level_clear", "jingles_level_complete"], ["win", "jingles_win_fanfare"], ["out_of_moves", "jingles_lose_life"], ["toggle_sound", "ui_toggle_on"]] },
221
+ { id: "arcade", label: "Arcade / endless runner", list: [["start", "jingles_start_game"], ["countdown", "jingles_countdown_tick"], ["go", "jingles_countdown_go"], ["jump", "movement_jump_small"], ["slide", "movement_slide"], ["dash", "movement_dash"], ["coin", "pickups_coin"], ["magnet", "pickups_magnet_pull"], ["crash", "explosions_crate_break"], ["near_miss", "movement_whoosh_fast"], ["achievement", "jingles_achievement"], ["high_score", "jingles_high_score"]] }
222
+ ];
223
+ var Plan = (function () {
224
+ var KEY = "blipwren-plan-v1", items = [], hist = [], preset = "";
225
+ function byId(id) { return meta.sounds.filter(function (x) { return x.id === id; })[0]; }
226
+ function slug(t) { return (t || "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 40); }
227
+ function snap() { hist.push(JSON.stringify({ items: items, preset: preset })); if (hist.length > 60) hist.shift(); }
228
+ function save() { try { localStorage.setItem(KEY, JSON.stringify({ items: items, preset: preset })); } catch (e) {} }
229
+ function eventFor(s) { var base = slug(s.name.replace(/^(ui|pickups|movement|combat|explosions|scifi|magic|jingles)\s/, "")) || "event", n = base, k = 2;
230
+ while (items.some(function (x) { return x.event === n; })) n = base + "_" + k++; return n; }
231
+ function toggle(id) {
232
+ var s = byId(id); if (!s) return;
233
+ snap();
234
+ var i = items.map(function (x) { return x.id; }).indexOf(id);
235
+ if (i >= 0) { items.splice(i, 1); toast("Removed " + s.name + " from your list"); }
236
+ else { items.push({ event: eventFor(s), id: id }); toast("Added " + s.name + " as “" + items[items.length - 1].event + "”"); }
237
+ preset = ""; render();
238
+ }
239
+ function usePreset(p) {
240
+ if (items.length && !confirmReplace()) return;
241
+ snap(); preset = p.id;
242
+ items = p.list.filter(function (x) { return byId(x[1]); }).map(function (x) { return { event: x[0], id: x[1] }; });
243
+ render(); toast(p.label + " starter set: " + items.length + " events. Rename, swap or add sounds to fit your game.");
244
+ }
245
+ function confirmReplace() { return true; } // Undo restores the previous list, so no blocking dialog
246
+ function undo() { if (!hist.length) { toast("Nothing to undo"); return; } var st = JSON.parse(hist.pop()); items = st.items; preset = st.preset; render(); toast("Undone"); }
247
+ function render() {
248
+ var ol = $("#plan"); ol.innerHTML = "";
249
+ items.forEach(function (it, idx) {
250
+ var s = byId(it.id); if (!s) return;
251
+ var li = document.createElement("li"); li.dataset.id = it.id;
252
+ var inp = document.createElement("input"); inp.value = it.event; inp.setAttribute("aria-label", "Game event for " + s.name); inp.spellcheck = false;
253
+ inp.addEventListener("change", function () { snap(); it.event = slug(inp.value) || eventFor(s); inp.value = it.event; save(); stats(); });
254
+ var nm = document.createElement("div"); nm.className = "snm"; nm.textContent = s.name;
255
+ var sm = document.createElement("small"); sm.textContent = (CAT[s.cat] || s.cat) + " · " + s.dur.toFixed(2) + " s" + (s.free ? " · FREE" : ""); nm.appendChild(sm);
256
+ var pl = btn("▶", "Play " + s.name, "pl", function () { playAllToken++; play(s); });
257
+ var up = btn("↑", "Move " + it.event + " up", "up", function () { if (!idx) return; snap(); items.splice(idx - 1, 0, items.splice(idx, 1)[0]); render(); });
258
+ var rm = btn("✕", "Remove " + it.event, "rm", function () { toggle(it.id); });
259
+ li.appendChild(inp); li.appendChild(nm); li.appendChild(pl); li.appendChild(up); li.appendChild(rm); ol.appendChild(li);
260
+ });
261
+ $("#plan-empty").hidden = items.length > 0;
262
+ Array.prototype.forEach.call(document.querySelectorAll("#presets button"), function (b) { b.setAttribute("aria-checked", b.dataset.p === preset ? "true" : "false"); });
263
+ Object.keys(tiles).forEach(function (id) { var on = items.some(function (x) { return x.id === id; }); tiles[id].add.classList.toggle("on", on); tiles[id].add.textContent = on ? "✓" : "+"; tiles[id].add.setAttribute("aria-pressed", on ? "true" : "false"); });
264
+ stats(); save();
265
+ }
266
+ function stats() {
267
+ var box = $("#plan-stats"); if (!items.length) { box.innerHTML = ""; return; }
268
+ var free = items.filter(function (x) { var s = byId(x.id); return s && s.free; }).length, cats = {}, secs = 0;
269
+ items.forEach(function (x) { var s = byId(x.id); if (s) { cats[s.cat] = 1; secs += s.dur; } });
270
+ var nc = Object.keys(cats).length, pack = items.length - free;
271
+ box.innerHTML = "<b>" + items.length + " events</b> across " + nc + " of 8 categories · " + secs.toFixed(1) + " s of audio · " +
272
+ "<b>" + free + "</b> in the free 12" + (pack ? ", <b>" + pack + "</b> in the full pack. <a href=\"#pack\">Get all 120 for $6</a>" : ". All free: download the sampler above.") +
273
+ '<div class="bar" aria-hidden="true"><i style="width:' + Math.round(100 * free / items.length) + '%"></i></div>';
274
+ }
275
+ function btn(t, label, cls, fn) { var b = document.createElement("button"); b.type = "button"; b.className = cls; b.textContent = t; b.setAttribute("aria-label", label); b.title = label; b.addEventListener("click", fn); return b; }
276
+ function rows() { return items.map(function (x) { var s = byId(x.id); return { event: x.event, sound: x.id, category: CAT[s.cat] || s.cat, seconds: s.dur, free: !!s.free,
277
+ wav: "WAV/" + s.id + ".wav", ogg: "OGG/" + s.id + ".ogg", description: s.desc }; }); }
278
+ function file(name, text, type) {
279
+ var a = document.createElement("a"); a.href = URL.createObjectURL(new Blob([text], { type: type })); a.download = name;
280
+ document.body.appendChild(a); a.click(); setTimeout(function () { URL.revokeObjectURL(a.href); a.remove(); }, 1500);
281
+ toast("Saved " + name);
282
+ }
283
+ function exp(kind) {
284
+ if (!items.length) { toast("Your list is empty: pick a starter set or tap + on a sound first."); return; }
285
+ var r = rows(), head = "Blipwren sound map: " + r.length + " events, made with the Blipwren planner (cybermaxtools.com)";
286
+ if (kind === "csv") {
287
+ var q = function (v) { v = String(v); return /[",\n]/.test(v) ? '"' + v.replace(/"/g, '""') + '"' : v; };
288
+ file("blipwren_sound_map.csv", ["event,sound,category,seconds,free,wav,ogg,description"].concat(r.map(function (x) { return [x.event, x.sound, x.category, x.seconds, x.free ? "yes" : "no", x.wav, x.ogg, x.description].map(q).join(","); })).join("\n") + "\n", "text/csv");
289
+ } else if (kind === "json") {
290
+ file("blipwren_sound_map.json", JSON.stringify({ pack: "Blipwren SFX Vol. 1", version: meta.version, events: r }, null, 2) + "\n", "application/json");
291
+ } else if (kind === "godot") {
292
+ var w = Math.max.apply(null, r.map(function (x) { return x.event.length; })) + 3;
293
+ file("sound_map.gd", "# " + head + "\n# Needs the Blipwren Autoload \"Sfx\" (res://blipwren_sfx/blipwren_sfx.gd).\n# Add this file as a second Autoload named \"Sounds\", then call Sounds.event(\"coin\").\nextends Node\n\nconst EVENTS := {\n" +
294
+ r.map(function (x) { var k = '\t"' + x.event + '":'; return k + new Array(Math.max(1, w - k.length + 2)).join(" ") + '"' + x.sound + '",'; }).join("\n") +
295
+ "\n}\n\nfunc event(name: String, volume_db: float = 0.0, pitch_jitter: float = 0.05) -> void:\n\tif not EVENTS.has(name):\n\t\tpush_warning(\"Blipwren: no sound mapped to event '%s'\" % name)\n\t\treturn\n\tSfx.play(EVENTS[name], volume_db, pitch_jitter)\n", "text/plain");
296
+ } else if (kind === "unity") {
297
+ var pas = function (e) { return e.split("_").map(function (p) { return p.charAt(0).toUpperCase() + p.slice(1); }).join("").replace(/^(\d)/, "_$1"); };
298
+ file("SoundMap.cs", "// " + head + "\n// Needs the Blipwren Unity helper (Assets/Blipwren). Call SoundMap.Coin() or SoundMap.Play(\"coin\").\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic static class SoundMap\n{\n public static readonly Dictionary<string, string> Events = new Dictionary<string, string>\n {\n" +
299
+ r.map(function (x) { return ' { "' + x.event + '", "' + x.sound + '" },'; }).join("\n") +
300
+ "\n };\n\n public static void Play(string evt, float volume = 1f, float pitchJitter = 0.05f)\n {\n if (Events.TryGetValue(evt, out var sound)) BlipwrenSfx.Play(sound, volume, pitchJitter);\n else Debug.LogWarning(\"Blipwren: no sound mapped to event '\" + evt + \"'\");\n }\n\n" +
301
+ r.map(function (x) { return " public static void " + pas(x.event) + "() => Play(\"" + x.event + "\");"; }).join("\n") + "\n}\n", "text/plain");
302
+ }
303
+ }
304
+ function shareLink() {
305
+ var enc = items.map(function (x) { return x.event + "~" + x.id; }).join(",");
306
+ return location.href.split("#")[0] + "#plan=" + encodeURIComponent(enc);
307
+ }
308
+ function fromHash() {
309
+ var m = location.hash.match(/^#plan=(.+)$/); if (!m) return false;
310
+ var list = decodeURIComponent(m[1]).split(",").map(function (p) { var a = p.split("~"); return { event: slug(a[0]), id: a[1] }; }).filter(function (x) { return x.event && byId(x.id); });
311
+ if (!list.length) return false; items = list; preset = ""; return true;
312
+ }
313
+ function playList() {
314
+ if (!items.length) { toast("Add some sounds first."); return; }
315
+ var token = ++playAllToken, i = 0, lis = document.querySelectorAll("#plan li");
316
+ (function next() {
317
+ Array.prototype.forEach.call(lis, function (l) { l.classList.remove("playing"); });
318
+ if (token !== playAllToken || i >= items.length) return;
319
+ var s = byId(items[i].id); if (lis[i]) lis[i].classList.add("playing"); i++;
320
+ play(s).then(function (d) { setTimeout(next, (d + 0.35) * 1000); });
321
+ })();
322
+ }
323
+ function init() {
324
+ var box = $("#presets");
325
+ PRESETS.forEach(function (p) { var b = document.createElement("button"); b.type = "button"; b.className = "chip"; b.setAttribute("role", "radio"); b.dataset.p = p.id; b.textContent = p.label;
326
+ b.addEventListener("click", function () { usePreset(p); }); box.appendChild(b); });
327
+ if (!fromHash()) { try { var st = JSON.parse(localStorage.getItem(KEY) || "null"); if (st && st.items) { items = st.items.filter(function (x) { return byId(x.id); }); preset = st.preset || ""; } } catch (e) {} }
328
+ if (!items.length && !localStorageHas()) { var p0 = PRESETS[0]; preset = p0.id; items = p0.list.map(function (x) { return { event: x[0], id: x[1] }; }); }
329
+ $("#plan-play").addEventListener("click", playList);
330
+ $("#plan-undo").addEventListener("click", undo);
331
+ $("#plan-clear").addEventListener("click", function () { if (!items.length) return; snap(); items = []; preset = ""; render(); toast("Cleared. Undo brings it back."); });
332
+ $("#plan-share").addEventListener("click", function () {
333
+ var u = shareLink();
334
+ try { navigator.clipboard.writeText(u).then(function () { toast("Share link copied"); }, function () { prompt("Copy this link", u); }); } catch (e) { prompt("Copy this link", u); }
335
+ });
336
+ Array.prototype.forEach.call(document.querySelectorAll("[data-export]"), function (b) { b.addEventListener("click", function () { exp(b.dataset.export); }); });
337
+ render();
338
+ }
339
+ function localStorageHas() { try { return localStorage.getItem(KEY) !== null; } catch (e) { return false; } }
340
+ return { init: init, toggle: toggle, undo: undo, items: function () { return items; } };
341
+ })();
342
+ window.__blipwrenPlan = Plan;
343
+
344
  $("#vol").addEventListener("input", function () { if (gain) gain.gain.value = this.value / 100; });
345
  $("#q").addEventListener("input", function () { query = this.value.trim().toLowerCase(); filter(); });
346
  $("#playall").addEventListener("click", playAll);
347
+ document.addEventListener("keydown", function (e) {
348
+ var typing = /^(INPUT|TEXTAREA|SELECT)$/.test((e.target || {}).tagName || "");
349
+ if (e.key === "Escape") { playAllToken++; if (current) try { current.src.stop(); } catch (x) {} if (typing) e.target.blur(); return; }
350
+ if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z") && !typing) { e.preventDefault(); Plan.undo(); return; }
351
+ if (typing || e.ctrlKey || e.metaKey || e.altKey) return;
352
+ if (e.key === "/") { e.preventDefault(); $("#q").focus(); }
353
+ else if ((e.key === "a" || e.key === "A") && last) { Plan.toggle(last.id); }
354
+ else if (e.key === " " && last && !/^(BUTTON|A)$/.test(e.target.tagName)) { e.preventDefault(); playAllToken++; play(last); }
355
+ });
356
+ $("#demo").addEventListener("click", function () {
357
+ var ids = ["pickups_coin", "movement_jump_small", "scifi_laser_shot", "combat_hit_heavy", "jingles_level_up"], token = ++playAllToken, i = 0;
358
+ (function next() {
359
+ if (token !== playAllToken || i >= ids.length || !meta) return;
360
+ var s = meta.sounds.filter(function (x) { return x.id === ids[i]; })[0]; i++;
361
+ if (!s) return next();
362
+ play(s).then(function (d) { setTimeout(next, (d + 0.3) * 1000); });
363
+ })();
364
+ });
365
  tabs(); links();
366
  if (/[?&]thanks=1/.test(location.search)) setTimeout(function () { toast("Thanks for your order! Your download link is in the Polar receipt email."); }, 800);
367
 
368
  fetch("sounds.json").then(function (r) { return r.json(); }).then(function (m) {
369
+ meta = m; m.categories.forEach(function (c) { CAT[c.id] = c.label; });
370
+ var coin = m.sounds.filter(function (x) { return x.id === "pickups_coin"; })[0];
371
+ if (coin) load(coin).then(function (b) { last = coin; scope(coin, b); }).catch(function () {});
372
+ buildChips(); buildGrid(); filter(); Plan.init(); preload();
373
  var hash = decodeURIComponent((location.hash.match(/^#s=([\w]+)/) || [])[1] || "");
374
  if (hash && tiles[hash]) tiles[hash].el.scrollIntoView({ block: "center" });
375
  }).catch(function () { $("#status").textContent = "Couldn't load the sound list. Please reload the page."; });
blipwren/index.html CHANGED
@@ -40,6 +40,12 @@
40
  <section class="hero">
41
  <h1>120 retro game sounds. Hear every one before you buy.</h1>
42
  <p class="lede">UI clicks, coins, jumps, hits, explosions, lasers, magic and jingles, made for indie games. <b>WAV + OGG</b>, <b>Godot and Unity ready</b>, royalty-free. Tap any sound to play it; <b>12 are free</b> to download now.</p>
 
 
 
 
 
 
43
  <ul class="facts" aria-label="Pack facts">
44
  <li><b>120</b> sounds in 8 categories</li>
45
  <li><b>5¢</b> a sound ($6 one-time)</li>
@@ -60,6 +66,7 @@
60
  </div>
61
  <div class="grid" id="grid" aria-live="polite"></div>
62
  <p class="hint" id="status">Loading sounds…</p>
 
63
  <p class="hint">Previews of the 108 pack-only sounds stream at preview quality (22 kHz, 8-bit). The pack is 44.1 kHz 16-bit WAV + OGG. <span class="free-badge">FREE</span> sounds play and download at full quality.</p>
64
  <div class="free-row">
65
  <a class="btn" id="btn-free" href="blipwren-sfx-sampler-1.0.0.zip" download>Download the 12 free sounds (.zip)</a>
@@ -67,6 +74,33 @@
67
  </div>
68
  </section>
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  <section id="pack" class="pack card">
71
  <div class="pack-head">
72
  <div>
@@ -145,5 +179,5 @@ coin.play();
145
  </div></footer>
146
  <div class="toast" id="toast" role="status"></div>
147
  <script src="app.js"></script>
148
- <!-- cybermax-count:start --><script>(function(){try{var D="https://data.cybermaxtools.com",P=location.host+location.pathname,G=1;try{var T=JSON.parse(localStorage.getItem("cmx-traffic")||"null");if(T&&T.until>Date.now()&&T.mode==="surge")G=100}catch(e){}if(G>1&&Math.random()*G>=1)return;H=navigator.webdriver||!(navigator.languages&&navigator.languages.length)||!screen.width?"&h=1":"",Z=function(x){navigator.sendBeacon?navigator.sendBeacon(x):(new Image).src=x},V=null,K="cmx-visit";if(navigator.doNotTrack!=="1")try{var o=JSON.parse(sessionStorage.getItem(K)||"null"),t=Date.now();if(!o||t-o.t>18e5)o={e:P,n:0};o.n++;o.t=t;sessionStorage.setItem(K,JSON.stringify(o));V=o}catch(e){}var u=D+"/v?p="+encodeURIComponent(P)+"&r="+encodeURIComponent((function(r){var h=r.split("/")[2]||"";return h===location.host?r.split(/[?#]/)[0]:h})(document.referrer||""))+H+(function(){var q=new URLSearchParams(location.search),s=q.get("utm_source"),t=(q.get("s")||"").toLowerCase().replace(/[^a-z0-9-]/g,"-").slice(0,80);return s?"&us="+encodeURIComponent(s)+"&uc="+encodeURIComponent(q.get("utm_campaign")||""):t?"&us=s&uc="+encodeURIComponent(t):""})()+(V?"&vn="+V.n+(V.n>1?"&ve="+encodeURIComponent(V.e):""):"")+(G>1?"&w="+G:"");Z(u);if(!V)return;var B="a[data-count],a[href*=\"buy.stripe.com\"],a[href*=\"data.cybermaxtools.com/buy/\"],a[href*=\".workers.dev/buy/\"],a[href*=\"buy.polar.sh\"],a[href*=\"polar.sh/checkout\"],[data-cmx-buy]",E=function(k){try{var o=JSON.parse(sessionStorage.getItem(K)||"null");if(!o||o[k])return;o[k]=1;sessionStorage.setItem(K,JSON.stringify(o));Z(D+"/v?p="+encodeURIComponent(P)+"&ev="+k+"&ve="+encodeURIComponent(o.e)+H)}catch(e){}};document.addEventListener("click",function(x){var a=x.target&&x.target.closest&&x.target.closest(B);if(a){E("seen");E("click")}},true);var S=V.seen,C=function(){if(S)return;var l=document.querySelectorAll(B),w=innerWidth,h=innerHeight;for(var i=0;i<l.length;i++){var r=l[i].getBoundingClientRect();if(r.width>0&&r.height>0&&r.bottom>0&&r.right>0&&r.top<h&&r.left<w){S=1;E("seen");return}}},T0=Date.now(),I=setInterval(function(){C();if(S||Date.now()-T0>6e5)clearInterval(I)},1500),R=0;addEventListener("scroll",function(){if(!R&&!S){R=1;setTimeout(function(){R=0;C()},250)}},{passive:true});document.readyState=="loading"?document.addEventListener("DOMContentLoaded",C):C()}catch(e){}})()</script><!-- cybermax-count:end --></body>
149
  </html>
 
40
  <section class="hero">
41
  <h1>120 retro game sounds. Hear every one before you buy.</h1>
42
  <p class="lede">UI clicks, coins, jumps, hits, explosions, lasers, magic and jingles, made for indie games. <b>WAV + OGG</b>, <b>Godot and Unity ready</b>, royalty-free. Tap any sound to play it; <b>12 are free</b> to download now.</p>
43
+ <div class="scope-row">
44
+ <div class="scope" id="scope-box"><canvas id="scope" width="560" height="90" aria-label="Waveform of the sound playing now" role="img"></canvas>
45
+ <div class="scope-cap"><b id="scope-name">coin</b> <span id="scope-meta">Pickups · 0.40 s · FREE</span></div></div>
46
+ <div class="scope-act"><button class="btn" id="demo" type="button">▶ Hear a game in 5 sounds</button>
47
+ <span class="hint">Coin, jump, laser, hit, level up. Then build your game's list below.</span></div>
48
+ </div>
49
  <ul class="facts" aria-label="Pack facts">
50
  <li><b>120</b> sounds in 8 categories</li>
51
  <li><b>5¢</b> a sound ($6 one-time)</li>
 
66
  </div>
67
  <div class="grid" id="grid" aria-live="polite"></div>
68
  <p class="hint" id="status">Loading sounds…</p>
69
+ <p class="hint"><b>Free: 12 sounds</b> at full quality (marked FREE), yours for commercial games. The other 108 preview here and come in the $6 pack. Keys: <kbd>Space</kbd> replay · <kbd>A</kbd> add to your list · <kbd>/</kbd> search · <kbd>Esc</kbd> stop · <kbd>Ctrl</kbd>+<kbd>Z</kbd> undo.</p>
70
  <p class="hint">Previews of the 108 pack-only sounds stream at preview quality (22 kHz, 8-bit). The pack is 44.1 kHz 16-bit WAV + OGG. <span class="free-badge">FREE</span> sounds play and download at full quality.</p>
71
  <div class="free-row">
72
  <a class="btn" id="btn-free" href="blipwren-sfx-sampler-1.0.0.zip" download>Download the 12 free sounds (.zip)</a>
 
74
  </div>
75
  </section>
76
 
77
+ <section class="card planner" id="planner" aria-labelledby="h-plan">
78
+ <div class="plan-head">
79
+ <div><h2 id="h-plan">Plan your game's sounds</h2>
80
+ <p class="hint">Map every game event to a sound, hear the whole set in order, then export a ready sound map for Godot, Unity, a spreadsheet or JSON. Your list saves in this browser and can be shared as a link.</p></div>
81
+ </div>
82
+ <div class="presets" role="radiogroup" aria-label="Starter sets" id="presets"></div>
83
+ <div class="plan-body">
84
+ <ol class="plan-list" id="plan" aria-live="polite"></ol>
85
+ <div class="plan-empty" id="plan-empty">Your list is empty. Pick a starter set above, or tap <b>+</b> on any sound in the player (or press <kbd>A</kbd> after playing one).</div>
86
+ </div>
87
+ <div class="plan-stats" id="plan-stats"></div>
88
+ <div class="plan-tools">
89
+ <button class="btn ghost small" id="plan-play" type="button">▶ Play my list</button>
90
+ <button class="btn ghost small" id="plan-undo" type="button">↶ Undo</button>
91
+ <button class="btn ghost small" id="plan-clear" type="button">Clear</button>
92
+ <button class="btn ghost small" id="plan-share" type="button">Copy share link</button>
93
+ </div>
94
+ <div class="plan-export" role="group" aria-label="Export your sound map">
95
+ <span class="hint">Export:</span>
96
+ <button class="chip" type="button" data-export="godot">Godot 4 (.gd)</button>
97
+ <button class="chip" type="button" data-export="unity">Unity (C#)</button>
98
+ <button class="chip" type="button" data-export="csv">Spreadsheet (.csv)</button>
99
+ <button class="chip" type="button" data-export="json">JSON</button>
100
+ </div>
101
+ <p class="hint">The exported map calls the pack's own helpers (<code>Sfx.play()</code> in Godot, <code>BlipwrenSfx.Play()</code> in Unity), so wiring a whole game's audio is one file. Sounds marked FREE work with the free sampler today.</p>
102
+ </section>
103
+
104
  <section id="pack" class="pack card">
105
  <div class="pack-head">
106
  <div>
 
179
  </div></footer>
180
  <div class="toast" id="toast" role="status"></div>
181
  <script src="app.js"></script>
182
+ </body>
183
  </html>
blipwren/style.css CHANGED
@@ -11,7 +11,7 @@ h3{font-size:17px;margin:18px 0 4px}
11
  .top .btn{white-space:nowrap}
12
  .top .wrap{display:flex;align-items:center;justify-content:space-between;height:56px;gap:12px}
13
  .brand{display:flex;align-items:center;gap:8px;color:#fff;text-decoration:none;font-weight:800;font-size:19px}
14
- .brand small{font-weight:500;opacity:.7;font-size:13px}
15
  .btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;background:var(--acc);color:var(--ink);border:0;border-radius:10px;padding:10px 16px;font:inherit;font-weight:700;text-decoration:none;cursor:pointer;min-height:44px}
16
  .btn:hover{filter:brightness(1.05)}
17
  .btn.ghost{background:transparent;color:var(--ink);box-shadow:inset 0 0 0 2px var(--ink)}
@@ -33,7 +33,7 @@ h3{font-size:17px;margin:18px 0 4px}
33
  .chip{background:#fff;color:var(--ink);border:1px solid var(--line);border-radius:999px;padding:6px 12px;font:inherit;font-size:14px;cursor:pointer;min-height:36px}
34
  .player .chip{background:#1d2130;color:#dfe2ea;border-color:#333a4f}
35
  .chip.on,.player .chip.on{background:var(--acc);color:var(--ink);border-color:var(--acc);font-weight:700}
36
- .chip .n{opacity:.65;font-weight:500;margin-left:4px}
37
  .grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:10px}
38
  .snd{position:relative;display:flex;flex-direction:column;align-items:stretch;text-align:left;background:#1a1e2b;color:#fff;border:1px solid #2c3246;border-radius:12px;padding:10px 10px 8px;font:inherit;cursor:pointer;min-height:92px;transition:border-color .12s,transform .08s}
39
  .snd:hover{border-color:var(--acc)}
@@ -61,10 +61,43 @@ h3{font-size:17px;margin:18px 0 4px}
61
  .more a{color:#fff;margin-right:16px}
62
  .more-title{font-weight:800;color:#fff;margin-bottom:6px}
63
  .more-links{display:flex;flex-wrap:wrap;gap:6px 0}
64
- .copy{font-size:12.5px;margin-top:10px;opacity:.75}
65
  .toast{position:fixed;left:50%;bottom:20px;transform:translateX(-50%);background:var(--ink);color:#fff;padding:10px 16px;border-radius:10px;opacity:0;pointer-events:none;transition:opacity .2s;max-width:90vw}
66
  .toast.on{opacity:1}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  @media (max-width:760px){
 
 
 
68
  .pack-head{grid-template-columns:1fr}
69
  .grid{grid-template-columns:repeat(2,minmax(0,1fr))}
70
  .snd .ds{display:none}
 
11
  .top .btn{white-space:nowrap}
12
  .top .wrap{display:flex;align-items:center;justify-content:space-between;height:56px;gap:12px}
13
  .brand{display:flex;align-items:center;gap:8px;color:#fff;text-decoration:none;font-weight:800;font-size:19px}
14
+ .brand small{font-weight:500;color:#c9cdd8;font-size:13px}
15
  .btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;background:var(--acc);color:var(--ink);border:0;border-radius:10px;padding:10px 16px;font:inherit;font-weight:700;text-decoration:none;cursor:pointer;min-height:44px}
16
  .btn:hover{filter:brightness(1.05)}
17
  .btn.ghost{background:transparent;color:var(--ink);box-shadow:inset 0 0 0 2px var(--ink)}
 
33
  .chip{background:#fff;color:var(--ink);border:1px solid var(--line);border-radius:999px;padding:6px 12px;font:inherit;font-size:14px;cursor:pointer;min-height:36px}
34
  .player .chip{background:#1d2130;color:#dfe2ea;border-color:#333a4f}
35
  .chip.on,.player .chip.on{background:var(--acc);color:var(--ink);border-color:var(--acc);font-weight:700}
36
+ .chip .n{color:inherit;font-weight:500;margin-left:4px}
37
  .grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:10px}
38
  .snd{position:relative;display:flex;flex-direction:column;align-items:stretch;text-align:left;background:#1a1e2b;color:#fff;border:1px solid #2c3246;border-radius:12px;padding:10px 10px 8px;font:inherit;cursor:pointer;min-height:92px;transition:border-color .12s,transform .08s}
39
  .snd:hover{border-color:var(--acc)}
 
61
  .more a{color:#fff;margin-right:16px}
62
  .more-title{font-weight:800;color:#fff;margin-bottom:6px}
63
  .more-links{display:flex;flex-wrap:wrap;gap:6px 0}
64
+ .copy{font-size:12.5px;margin-top:10px;color:#c9cdd8}
65
  .toast{position:fixed;left:50%;bottom:20px;transform:translateX(-50%);background:var(--ink);color:#fff;padding:10px 16px;border-radius:10px;opacity:0;pointer-events:none;transition:opacity .2s;max-width:90vw}
66
  .toast.on{opacity:1}
67
+ .scope-row{display:flex;flex-wrap:wrap;gap:12px 18px;align-items:center;margin:14px 0 4px}
68
+ .scope{flex:1 1 320px;max-width:580px;background:var(--ink);border-radius:14px;padding:10px 12px 8px;color:#fff}
69
+ .scope canvas{width:100%;height:70px;display:block}
70
+ .scope-cap{font-size:13.5px;color:#c9cdd8;margin-top:4px}.scope-cap b{color:#fff;text-transform:capitalize}
71
+ .scope-act{display:flex;flex-direction:column;gap:6px;flex:0 1 300px}
72
+ .tile{position:relative;display:flex}.tile[hidden]{display:none}.tile .snd{flex:1;min-width:0}
73
+ .tile .add{position:absolute;right:8px;bottom:8px;width:32px;height:32px;border-radius:8px;border:1px solid #3a4260;background:#232840;color:#fff;font:700 18px/1 system-ui;cursor:pointer;transition:background .12s}
74
+ .tile .add:hover,.tile .add.on{background:var(--acc);color:var(--ink);border-color:var(--acc)}
75
+ .tile .snd .foot{padding-right:40px}
76
+ kbd{font:12px ui-monospace,Menlo,Consolas,monospace;background:#2c3246;color:#fff;border-radius:4px;padding:1px 5px}
77
+ .planner kbd{background:#e9e4d8;color:var(--ink)}
78
+ .presets{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
79
+ .presets button{min-height:40px}
80
+ .presets button[aria-checked=true]{background:var(--acc);border-color:var(--acc);font-weight:700}
81
+ .plan-list{list-style:none;padding:0;margin:0;display:grid;gap:6px}
82
+ .plan-list li{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,1.2fr) auto auto auto;gap:8px;align-items:center;background:var(--paper);border:1px solid var(--line);border-radius:10px;padding:6px 8px}
83
+ .plan-list input{font:inherit;font-size:14.5px;border:1px solid var(--line);border-radius:8px;padding:6px 8px;min-height:36px;width:100%;background:#fff;color:var(--ink)}
84
+ .plan-list .snm{font-weight:600;text-transform:capitalize;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
85
+ .plan-list .snm small{display:block;font-weight:400;color:var(--muted);text-transform:none;white-space:normal}
86
+ .plan-list button{min-width:36px;min-height:36px;border-radius:8px;border:1px solid var(--line);background:#fff;color:var(--ink);cursor:pointer;font:inherit}
87
+ .plan-list li.playing{border-color:var(--acc);box-shadow:0 0 0 2px var(--acc) inset}
88
+ .plan-empty{background:var(--paper);border:1px dashed #c9c2b1;border-radius:10px;padding:16px;color:#3d4250}
89
+ .plan-stats{margin:10px 0;font-size:14.5px}
90
+ .plan-stats .bar{height:8px;background:#e9e4d8;border-radius:99px;overflow:hidden;margin-top:6px}.plan-stats .bar i{display:block;height:100%;background:var(--ok)}
91
+ .plan-tools,.plan-export{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:8px 0}
92
+ .planner .chip{min-height:40px}
93
+ .btn.small.on{background:var(--ink);color:#fff}
94
+ :focus-visible{outline:3px solid var(--acc2);outline-offset:2px}
95
+ .player :focus-visible{outline-color:var(--acc)}
96
+ @media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important;scroll-behavior:auto!important}}
97
  @media (max-width:760px){
98
+ .plan-list li{grid-template-columns:minmax(0,1fr) auto auto auto;grid-template-areas:"ev ev ev ev" "nm pl up rm"}
99
+ .plan-list li input{grid-area:ev}.plan-list li .snm{grid-area:nm}.plan-list li .pl{grid-area:pl}.plan-list li .up{grid-area:up}.plan-list li .rm{grid-area:rm}
100
+ .scope-act{flex-basis:100%}
101
  .pack-head{grid-template-columns:1fr}
102
  .grid{grid-template-columns:repeat(2,minmax(0,1fr))}
103
  .snd .ds{display:none}