v0.2.0: item pickups hold their toast for 5.5s
Toast durations are now per-toast (addToast third arg); passive item and active item pickups display for 5.5s instead of the default 2.5s. Cache v=43.
This commit is contained in:
1 parent
64ac53434b
commit
7d33e36c1e
8 files changed
+31
-31
No files matched your search
@@ -198,7 +198,7 @@ function drawHUD(ctx) {
|
||||
ctx.textAlign = 'center';
|
||||
for (let i = 0; i < G.toasts.length; i++) {
|
||||
const t = G.toasts[i];
|
||||
const a = clamp(2.5 - t.t, 0, 1);
|
||||
const a = clamp((t.dur || 2.5) - t.t, 0, 1);
|
||||
const y = 22 + i * 48;
|
||||
ctx.globalAlpha = a;
|
||||
ctx.font = 'bold 13px monospace';
|
||||
@@ -271,5 +271,5 @@ function drawMinimap(ctx) {
|
||||
|
||||
function drawToastsUpdate(dt) {
|
||||
for (const t of G.toasts) t.t += dt;
|
||||
while (G.toasts.length && G.toasts[0].t > 2.5) G.toasts.shift();
|
||||
while (G.toasts.length && G.toasts[0].t > (G.toasts[0].dur || 2.5)) G.toasts.shift();
|
||||
}
|
||||
+2
-2
@@ -172,10 +172,10 @@ function giveItem(iid) {
|
||||
item.apply(p.stats, p);
|
||||
p.items[iid] = lvl + 1;
|
||||
if (lvl > 0) {
|
||||
addToast(item.name + ' ' + romanNum(lvl + 1), 'UPGRADED — ' + item.desc);
|
||||
addToast(item.name + ' ' + romanNum(lvl + 1), 'UPGRADED — ' + item.desc, 5.5);
|
||||
spawnText(p.x, p.y - 14, 'UPGRADED!', '#ffd060');
|
||||
} else {
|
||||
addToast(item.name, item.desc);
|
||||
addToast(item.name, item.desc, 5.5);
|
||||
spawnText(p.x, p.y - 14, item.name.toUpperCase(), ITEM_RARITY[item.rarity].color);
|
||||
}
|
||||
if (item.rarity === 'legendary') Sfx.curse(); else Sfx.item();
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ function collectPickup(k) {
|
||||
}
|
||||
const def = ACTIVES[k.aid];
|
||||
p.active = { iid: k.aid, charges: k.charges !== undefined ? k.charges : def.cost };
|
||||
addToast(def.name, def.desc + ' — [SPACE] when charged');
|
||||
addToast(def.name, def.desc + ' — [SPACE] when charged', 5.5);
|
||||
spawnText(p.x, p.y - 14, def.name.toUpperCase(), '#55f5dc');
|
||||
Sfx.item();
|
||||
for (const q of G.pickups) if (q.type === 'itemspot') q.dead = true; // remove pedestal base
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ const SfxBank = {
|
||||
if (this.buffers.has(name) || this.pending.has(name) || this.failed.has(name)) return;
|
||||
const file = this.FILES[name];
|
||||
if (!file || !this.ctx || typeof fetch !== 'function') return;
|
||||
const job = fetch('/assets/sfx/' + encodeURIComponent(file) + '?v=42')
|
||||
const job = fetch('/assets/sfx/' + encodeURIComponent(file) + '?v=43')
|
||||
.then(r => { if (!r.ok) throw new Error('HTTP ' + r.status); return r.arrayBuffer(); })
|
||||
.then(bytes => this.ctx.decodeAudioData(bytes))
|
||||
.then(buffer => this.buffers.set(name, this.trim(buffer)))
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ const Sprites = {
|
||||
const img = new Image();
|
||||
img.onload = () => { this.imgs[name] = img; if (--pending === 0) G.imagesLoaded = true; };
|
||||
img.onerror = () => { if (--pending === 0) G.imagesLoaded = true; };
|
||||
img.src = 'assets/' + name + '.png?v=42';
|
||||
img.src = 'assets/' + name + '.png?v=43';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
+2
-2
@@ -73,8 +73,8 @@ function powerScore() {
|
||||
}
|
||||
|
||||
function addShake(n) { G.shake = Math.min(G.shake + n, 18); }
|
||||
function addToast(text, sub) {
|
||||
G.toasts.push({ text, sub: sub || '', t: 0 });
|
||||
function addToast(text, sub, dur) {
|
||||
G.toasts.push({ text, sub: sub || '', t: 0, dur: dur || 2.5 });
|
||||
if (G.toasts.length > 3) G.toasts.shift();
|
||||
}
|
||||
function addScore(n) {
|
||||
|
||||
Reference in new issue
Block a user