diff --git a/bgs/tutorial.js b/bgs/tutorial.js index 5a936bf..47e311d 100644 --- a/bgs/tutorial.js +++ b/bgs/tutorial.js @@ -248,7 +248,8 @@ export async function mountLesson( if (s.step !== lastStep) { ui.resetTutorial(); - if (s.completed && lastStep >= 0 && s.step > lastStep) + if (s.completed && lastStep >= 0 && s.step > lastStep && + !s.state.game.resolution?.outcome?.survived) sound.cue("complete"); lastStep = s.step; } diff --git a/preview/app.js b/preview/app.js index e62396d..443464e 100644 --- a/preview/app.js +++ b/preview/app.js @@ -476,7 +476,7 @@ export function mountConsole(root, host = null) { .join("")}${Object.entries(th.effects) .map( ([mark, es]) => - `
${mark} ${es.map((e) => esc(effectDescription(e, locale))).join(" · ") || "—"}
`, + `${mark} ${es.map((e) => esc(effectDescription(e, locale))).join(" · ") || "-"}
`, ) .join( "", @@ -745,7 +745,7 @@ export function mountConsole(root, host = null) { .join("")}${Object.entries(c.effects) .map( ([mark, es]) => - `${mark} ${es.map((e) => esc(effectDescription(e, locale))).join(" · ") || "—"}
`, + `${mark} ${es.map((e) => esc(effectDescription(e, locale))).join(" · ") || "-"}
`, ) .join("")}${calledHtml(data.calledCard)}`; } diff --git a/preview/locales/en.json b/preview/locales/en.json index 6861b14..983bb12 100644 --- a/preview/locales/en.json +++ b/preview/locales/en.json @@ -4,10 +4,10 @@ "lesson.first-shot.instruction.0": "Destroy the target with the highlighted laser.", "lesson.energy.title": "Energy and coordination", "lesson.energy.instruction.0": "Power the central laser for four shots.", - "lesson.energy.instruction.1": "Android 1: weapons on turns 1–4. Android 3: lift, then energy to refill the reactor.", + "lesson.energy.instruction.1": "Android 1: weapons on turns 1-4. Android 3: lift, then energy to refill the reactor.", "lesson.repairs.title": "Repairing a malfunction", "lesson.repairs.instruction.0": "Repair the highlighted malfunction.", - "lesson.repairs.instruction.1": "→ on turn 1, then energy on turns 2–4.", + "lesson.repairs.instruction.1": "→ on turn 1, then energy on turns 2-4.", "lesson.battlebots.title": "Battlebots and interceptors", "lesson.battlebots.instruction.0": "Collect the battlebots, then reach the interceptors.", "lesson.battlebots.instruction.1": "→ · systems · ← · ← · systems. In flight, play battlebots to fire; leave a slot empty to return.", @@ -16,7 +16,7 @@ "lesson.double-actions.instruction.1": "Compare → + weapons with weapons + →: the order determines which laser fires.", "lesson.phasing.title": "Expansion threats", "lesson.phasing.instruction.0": "Hit the fighter while it is visible.", - "lesson.phasing.instruction.1": "Weapons on turns 1–3. Watch the missed shot while it is phased out.", + "lesson.phasing.instruction.1": "Weapons on turns 1-3. Watch the missed shot while it is phased out.", "lesson.specializations.title": "Specializations", "lesson.specializations.instruction.0": "Launch a rocket remotely with the Rocketeer.", "lesson.specializations.instruction.1": "Program the basic ability on turn 1. The rocket hits next turn.", @@ -186,7 +186,7 @@ "app.rocket": "Rocket", "app.hit_points": "Hit points", "app.left_center_and_right_correspond_to_red_white": "Left, center and right correspond to red, white and blue in the original announcements. Each threat’s miniature map shows its trajectory or affected rooms.", - "app.plan_choose_a_card_then_a_turn_click": "Plan. Choose a card then a turn; click a filled turn to retrieve its card. A operates a weapon, B transfers energy, C uses the station system. Arrows move your crew member. Planning does not move the real ship pieces; programs execute during resolution.
Coordinate. Each weapon fires once per turn. Heavy lasers and pulse draw from the zone reactor; light lasers have their own battery. A second crew member using the same lift is delayed.
Computer. Someone must perform C on the bridge within the first two turns of each phase (1–2, 4–5, 8–9), or the next actions are delayed.
Threats. Combine fire before subtracting enemy shields. Rockets hit on the following turn. Threats move after crew actions and execute X, Y and Z as they cross them.
Remote cooperation. Use external voice chat. Stay silent during communications blackouts; this page cannot mute your call.
", + "app.plan_choose_a_card_then_a_turn_click": "Plan. Choose a card then a turn; click a filled turn to retrieve its card. A operates a weapon, B transfers energy, C uses the station system. Arrows move your crew member. Planning does not move the real ship pieces; programs execute during resolution.
Coordinate. Each weapon fires once per turn. Heavy lasers and pulse draw from the zone reactor; light lasers have their own battery. A second crew member using the same lift is delayed.
Computer. Someone must perform C on the bridge within the first two turns of each phase (1-2, 4-5, 8-9), or the next actions are delayed.
Threats. Combine fire before subtracting enemy shields. Rockets hit on the following turn. Threats move after crew actions and execute X, Y and Z as they cross them.
Remote cooperation. Use external voice chat. Stay silent during communications blackouts; this page cannot mute your call.
", "app.reinforcement": "Reinforcement", "app.speed": "Speed", "app.forecast_without_crew_intervention_includes_the_threat_s": "Forecast without crew intervention; includes the threat’s own speed changes.", @@ -497,7 +497,7 @@ "tactical.one_fuel_capsule_fills_the_central_reactor_to": "One fuel capsule fills the central reactor to capacity.", "tactical.b_transfers_energy_from_this_zone_s_reactor": "B transfers energy from this zone’s reactor into its shield, up to capacity. That energy absorbs incoming attacks.", "tactical.b_transfers_energy_from_the_central_reactor_into": "B transfers energy from the central reactor into this reactor, up to capacity.", - "tactical.perform_c_here_on_turns_1_2_4": "Perform C here on turns 1–2, 4–5 and 8–9 to maintain the computer each phase and avoid delaying programs.", + "tactical.perform_c_here_on_turns_1_2_4": "Perform C here on turns 1-2, 4-5 and 8-9 to maintain the computer each phase and avoid delaying programs.", "tactical.c_takes_this_room_s_battlebots_or_reactivates": "C takes this room’s battlebots, or reactivates the team you already carry.", "tactical.with_active_battlebots_c_launches_you_in_an": "With active battlebots, C launches you in an interceptor. Only one crew member can be in space at a time.", "tactical.c_performs_visual_confirmation_which_can_earn_points": "C performs visual confirmation, which can earn points at the end of the mission.", @@ -564,19 +564,19 @@ "timing.next_scenario": "Next: time runs out", "timing.exercise": "Exercise: {turns} turns", "timing.full_mission": "Full mission", - "timing.phase_group": "Phase {phase}: plan turns {first}–{last}", + "timing.phase_group": "Phase {phase}: plan turns {first}-{last}", "timing.mission_execution": "All turns execute after planning", "timing.phase_one": "Plan the first three shots, then advance the clock to phase 2. The ship waits.", - "timing.phase_two": "Turns 1–3 are locked. Add the fourth shot, then run the whole mission.", + "timing.phase_two": "Turns 1-3 are locked. Add the fourth shot, then run the whole mission.", "lesson.planning-phases.title": "The clock and planning phases", - "lesson.planning-phases.instruction.0": "This training mission has 7 turns: plan 1–3, then 4–7. They all execute at the end.", - "phases.first": "Phase 1 · Turns 1–3", - "phases.second": "Phase 2 · Turns 4–7", + "lesson.planning-phases.instruction.0": "This training mission has 7 turns: plan 1-3, then 4-7. They all execute at the end.", + "phases.first": "Phase 1 · Turns 1-3", + "phases.second": "Phase 2 · Turns 4-7", "phases.execute": "Execute the whole mission", "phases.start": "Start the clock and place → in turn 1. Listen for the next announcement.", "phases.listen": "The clock advances; the ship waits. Threats are announced during planning.", "phases.revealed": "Threat revealed: it will arrive on execution turn 6. Place → in turn 1, then jump to the last 5 seconds of this phase.", - "phases.locked": "Turns 1–3 are locked; the ship still waits. Place a deck change in turn 4, then ↵.", + "phases.locked": "Turns 1-3 are locked; the ship still waits. Place a deck change in turn 4, then ↵.", "phases.all_turns": "Seven crew turns, then a final threat movement before the jump. The meteoroid arrives on turn 6.", "phases.skip": "Jump to the last 5 seconds of phase 1", "phases.full_program": "Complete program", diff --git a/preview/locales/fr.json b/preview/locales/fr.json index cb133ce..d2339d4 100644 --- a/preview/locales/fr.json +++ b/preview/locales/fr.json @@ -4,10 +4,10 @@ "lesson.first-shot.instruction.0": "Détruisez la cible avec le laser surligné.", "lesson.energy.title": "Énergie et coordination", "lesson.energy.instruction.0": "Alimentez le laser central pour tirer quatre fois.", - "lesson.energy.instruction.1": "Androïde 1 : armes aux tours 1–4. Androïde 3 : ascenseur, puis énergie pour ravitailler le réacteur.", + "lesson.energy.instruction.1": "Androïde 1 : armes aux tours 1-4. Androïde 3 : ascenseur, puis énergie pour ravitailler le réacteur.", "lesson.repairs.title": "Réparer une panne", "lesson.repairs.instruction.0": "Réparez la panne surlignée.", - "lesson.repairs.instruction.1": "→ au tour 1, puis énergie aux tours 2–4.", + "lesson.repairs.instruction.1": "→ au tour 1, puis énergie aux tours 2-4.", "lesson.battlebots.title": "Robots et intercepteurs", "lesson.battlebots.instruction.0": "Prenez les robots, puis rejoignez les intercepteurs.", "lesson.battlebots.instruction.1": "→ · systèmes · ← · ← · systèmes. En vol, jouez robots pour tirer ; laissez vide pour rentrer.", @@ -16,7 +16,7 @@ "lesson.double-actions.instruction.1": "Comparez → + armes et armes + → : l’ordre choisit le laser utilisé.", "lesson.phasing.title": "Menaces de l’extension", "lesson.phasing.instruction.0": "Touchez le chasseur lorsqu’il est visible.", - "lesson.phasing.instruction.1": "Armes aux tours 1–3. Observez le tir ignoré pendant son déphasage.", + "lesson.phasing.instruction.1": "Armes aux tours 1-3. Observez le tir ignoré pendant son déphasage.", "lesson.specializations.title": "Spécialisations", "lesson.specializations.instruction.0": "Lancez une roquette à distance avec l’Artilleur.", "lesson.specializations.instruction.1": "Programmez sa capacité basique au tour 1. La roquette frappe au tour suivant.", @@ -186,7 +186,7 @@ "app.rocket": "Roquette", "app.hit_points": "Points de vie", "app.left_center_and_right_correspond_to_red_white": "Les zones gauche, centre et droite correspondent aux zones rouge, blanche et bleue des annonces originales. Le petit plan sur chaque menace indique sa trajectoire ou les salles touchées.", - "app.plan_choose_a_card_then_a_turn_click": "Planifier. Choisissez une carte puis un tour ; cliquez sur un tour rempli pour reprendre la carte. A utilise l’arme, B l’énergie, C le système indiqué dans la station. Les flèches déplacent votre équipier. Les déplacements planifiés ne déplacent pas encore les pions : tout sera exécuté pendant la résolution.
Coordonner. Chaque arme ne tire qu’une fois par tour. Le réacteur de la zone alimente le laser lourd et l’impulsion ; les petits lasers ont leur propre batterie. Deux équipiers prenant le même ascenseur retardent le second.
Ordinateur. Quelqu’un doit faire C sur la passerelle pendant les deux premiers tours de chaque phase (1–2, 4–5, 8–9), sinon les actions suivantes sont retardées.
Menaces. Les tirs se combinent avant de retirer le bouclier adverse. Une roquette touche au tour suivant. Les ennemis avancent après les actions et exécutent X, Y, Z en les franchissant.
Coopérer à distance. Utilisez une conversation vocale externe. Pendant une panne de communication, gardez le silence : cette page ne peut pas couper votre appel.
", + "app.plan_choose_a_card_then_a_turn_click": "Planifier. Choisissez une carte puis un tour ; cliquez sur un tour rempli pour reprendre la carte. A utilise l’arme, B l’énergie, C le système indiqué dans la station. Les flèches déplacent votre équipier. Les déplacements planifiés ne déplacent pas encore les pions : tout sera exécuté pendant la résolution.
Coordonner. Chaque arme ne tire qu’une fois par tour. Le réacteur de la zone alimente le laser lourd et l’impulsion ; les petits lasers ont leur propre batterie. Deux équipiers prenant le même ascenseur retardent le second.
Ordinateur. Quelqu’un doit faire C sur la passerelle pendant les deux premiers tours de chaque phase (1-2, 4-5, 8-9), sinon les actions suivantes sont retardées.
Menaces. Les tirs se combinent avant de retirer le bouclier adverse. Une roquette touche au tour suivant. Les ennemis avancent après les actions et exécutent X, Y, Z en les franchissant.
Coopérer à distance. Utilisez une conversation vocale externe. Pendant une panne de communication, gardez le silence : cette page ne peut pas couper votre appel.
", "app.reinforcement": "Renfort", "app.speed": "Vitesse", "app.forecast_without_crew_intervention_includes_the_threat_s": "Prévision sans intervention de l’équipage ; changements de vitesse propres à la menace inclus.", @@ -497,7 +497,7 @@ "tactical.one_fuel_capsule_fills_the_central_reactor_to": "Une capsule de combustible remplit le réacteur central jusqu’à sa capacité.", "tactical.b_transfers_energy_from_this_zone_s_reactor": "B transfère l’énergie du réacteur de cette zone vers son bouclier, jusqu’à sa capacité. Cette énergie absorbera les prochaines attaques.", "tactical.b_transfers_energy_from_the_central_reactor_into": "B transfère l’énergie du réacteur central vers ce réacteur, jusqu’à sa capacité.", - "tactical.perform_c_here_on_turns_1_2_4": "Faites C ici aux tours 1–2, 4–5 et 8–9 pour entretenir l’ordinateur à chaque phase et éviter de retarder les programmes.", + "tactical.perform_c_here_on_turns_1_2_4": "Faites C ici aux tours 1-2, 4-5 et 8-9 pour entretenir l’ordinateur à chaque phase et éviter de retarder les programmes.", "tactical.c_takes_this_room_s_battlebots_or_reactivates": "C prend les robots de combat de cette salle, ou réactive ceux que vous portez déjà.", "tactical.with_active_battlebots_c_launches_you_in_an": "Avec des robots de combat actifs, C vous fait décoller en intercepteur. Un seul équipier peut être dans l’espace à la fois.", "tactical.c_performs_visual_confirmation_which_can_earn_points": "C effectue une observation visuelle, qui peut rapporter des points à la fin de la mission.", @@ -567,16 +567,16 @@ "timing.phase_group": "Phase {phase} : programmer les tours {first} à {last}", "timing.mission_execution": "Tous les tours s’exécutent après la préparation", "timing.phase_one": "Programmez les trois premiers tirs, puis avancez le chrono à la phase 2. Le vaisseau attend.", - "timing.phase_two": "Les tours 1–3 sont verrouillés. Ajoutez le quatrième tir, puis lancez toute la mission.", + "timing.phase_two": "Les tours 1-3 sont verrouillés. Ajoutez le quatrième tir, puis lancez toute la mission.", "lesson.planning-phases.title": "Le chrono et les phases", - "lesson.planning-phases.instruction.0": "Cette mission d’entraînement a 7 tours : préparez 1–3, puis 4–7. Ils s’exécutent tous à la fin.", - "phases.first": "Phase 1 · Tours 1–3", - "phases.second": "Phase 2 · Tours 4–7", + "lesson.planning-phases.instruction.0": "Cette mission d’entraînement a 7 tours : préparez 1-3, puis 4-7. Ils s’exécutent tous à la fin.", + "phases.first": "Phase 1 · Tours 1-3", + "phases.second": "Phase 2 · Tours 4-7", "phases.execute": "Exécuter toute la mission", "phases.start": "Lancez le chrono et placez → au tour 1. Écoutez la prochaine annonce.", "phases.listen": "Le chrono avance ; le vaisseau attend. Les menaces sont annoncées pendant la préparation.", "phases.revealed": "Menace révélée : elle arrivera au tour 6 de l’exécution. Placez → au tour 1, puis avancez aux 5 dernières secondes de cette phase.", - "phases.locked": "Les tours 1–3 sont verrouillés ; le vaisseau attend toujours. Placez le changement de pont au tour 4, puis ↵.", + "phases.locked": "Les tours 1-3 sont verrouillés ; le vaisseau attend toujours. Placez le changement de pont au tour 4, puis ↵.", "phases.all_turns": "Sept tours d’équipage, puis un dernier mouvement des menaces avant le saut. La météorite arrive au tour 6.", "phases.skip": "Avancer aux 5 dernières secondes de la phase 1", "phases.full_program": "Programme complet", diff --git a/preview/navigation.js b/preview/navigation.js index cae4bff..b442ad6 100644 --- a/preview/navigation.js +++ b/preview/navigation.js @@ -144,7 +144,7 @@ export function mountNavigation(root, { locale, hosted }) { `${text} : ${select.selectedOptions[0]?.textContent ?? ""}`, ); const value = document.createElement("span"); - value.textContent = select.selectedOptions[0]?.textContent ?? "—"; + value.textContent = select.selectedOptions[0]?.textContent ?? "-"; trigger.append(value); const symbol = document.createElement("span"); symbol.className = "choice-symbol"; diff --git a/preview/resolution-effects.js b/preview/resolution-effects.js index 702a008..c8c6e21 100644 --- a/preview/resolution-effects.js +++ b/preview/resolution-effects.js @@ -1,6 +1,8 @@ +import { pictogram } from "./icons.js"; + // Presentation only: consume resolved events, never predict damage or change game state. export function resolutionEffects(resolution, before, after) { - if (!before || !after || after.logEnd < before.logEnd) return []; + if (!before || !after || before === after || after.logEnd < before.logEnd) return []; const events = resolution.log.slice(before.logEnd, after.logEnd); const fires = resolution.log.filter(e => e.turn === after.turn && e.type === "fire"); const effects = []; @@ -48,6 +50,11 @@ export function resolutionEffects(resolution, before, after) { if (!effects.some(e => e.kind === "hit" && e.sources.some(s => s.station === f.station))) effects.push({ kind: "miss", station: f.station }); } + // Survival is only confirmed after the final threat movement. A completed + // three-turn exercise, an old replay frame or a destroyed ship is not a jump. + if (resolution.outcome?.survived && after === resolution.frames.at(-1) && + before.step === "computer" && after.step === "appear") + effects.push({ kind: "jump" }); return effects; } @@ -59,7 +66,7 @@ export function createResolutionEffects(root, cue) { layer.className = "resolution-effects"; layer.setAttribute("aria-hidden", "true"); root.append(layer); - let previous = null, previousIndex = -1, busyUntil = 0; + let previous = null, previousIndex = -1, busyUntil = 0, jumping = false; let oldPawns = new Map(); const animations = new Set(), timers = new Set(), restores = []; const q = selector => root.querySelector(selector); @@ -76,9 +83,9 @@ export function createResolutionEffects(root, cue) { const id = win.setTimeout(() => { timers.delete(id); callback(); }, ms); timers.add(id); } - function animate(element, frames, duration, delay = 0) { + function animate(element, frames, duration, delay = 0, easing = "ease-out") { if (!element?.animate) return; - const animation = element.animate(frames, { duration, delay, easing: "ease-out", fill: "both" }); + const animation = element.animate(frames, { duration, delay, easing, fill: "both" }); animations.add(animation); animation.finished.then(() => { animations.delete(animation); animation.cancel(); }, () => {}); busyUntil = Math.max(busyUntil, performance.now() + duration + delay); @@ -91,12 +98,13 @@ export function createResolutionEffects(root, cue) { for (const restore of restores.splice(0)) restore(); layer.replaceChildren(); busyUntil = 0; + jumping = false; } - function node(name, p, color) { + function node(name, p, color, parent = layer) { const element = doc.createElement("span"); element.className = name; element.style.cssText = `left:${p.x}px;top:${p.y}px;--fx-color:${color}`; - layer.append(element); + parent.append(element); return element; } function burst(p, color, large = false) { @@ -145,6 +153,74 @@ export function createResolutionEffects(root, cue) { restores.push(restore); later(restore, delay); } + function jump(sound) { + const vessel = q(".ship-vessel"), position = point(vessel); + if (!position) return; + // Keep the jump attached to the ship even if completion text changes the + // page's scroll position. Combat projectiles use viewport coordinates. + const stage = doc.createElement("div"); + stage.className = "ship-jump-effects"; + stage.setAttribute("aria-hidden", "true"); + vessel.parentElement.append(stage); + restores.push(() => stage.remove()); + const bounds = vessel.getBoundingClientRect(), base = stage.getBoundingClientRect(); + const p = { x: bounds.left - base.left + bounds.width / 2, + y: bounds.top - base.top + bounds.height / 2, width: bounds.width, height: bounds.height }; + const jumpSound = kind => sound(kind, position); + jumping = true; + const duration = reduced.matches ? 900 : 2800; + const departure = reduced.matches ? 0 : 1100; + const arrival = reduced.matches ? 0 : 1500; + if (!reduced.matches) { + jumpSound("thruster"); + for (const nozzle of vessel.querySelectorAll(".ship-stern i")) { + animate(nozzle, [ + { transform: "translateY(12px) scaleY(1)", filter: "brightness(1)" }, + { transform: "translateY(12px) scaleY(2.5)", filter: "brightness(1.6)", offset: .5 }, + { transform: "translateY(12px) scaleY(5)", filter: "brightness(2.3)", offset: .76 }, + { transform: "translateY(12px) scaleY(5)", filter: "brightness(2.3)" }, + ], 1450, 0, "linear"); + } + animate(vessel, [ + { transform: "translateY(0) scale(1)", opacity: 1 }, + { transform: "translateY(-5px) scale(1)", opacity: 1, offset: departure / duration }, + { transform: `translateY(${-p.height * .3}px) scale(.08,.6)`, opacity: 0, offset: .52 }, + { transform: "translateY(0) scale(1)", opacity: 0, offset: .78 }, + { transform: "translateY(0) scale(1)", opacity: 1 }, + ], duration, 0, "linear"); + later(() => { + jumpSound("jump"); + // Streaks stay around the ship instead of flashing the whole screen. + for (let i = 0; i < 22; i++) { + const star = node("fx-jump-star", { + x: p.x + ((i * .618034) % 1 - .5) * p.width, + y: p.y + ((i * .381966) % 1 - .5) * p.height, + }, "#a1f4ef", stage); + animate(star, [ + { transform: "scaleY(.2)", opacity: 0 }, + { transform: "translateY(20px) scaleY(1)", opacity: .8, offset: .3 }, + { transform: "translateY(90px) scaleY(2)", opacity: 0 }, + ], 550); + later(() => star.remove(), 560); + } + }, departure); + } else { + animate(vessel, [{ filter: "brightness(1.15)" }, { filter: "brightness(1)" }], 500); + } + later(() => { + jumpSound("victory"); + const seal = node("fx-jump-success", p, "#76e5c6", stage); + seal.innerHTML = pictogram("check"); + animate(seal, [ + { transform: `translate(-50%,-50%) scale(${reduced.matches ? 1 : .85})`, opacity: 0 }, + { transform: "translate(-50%,-50%) scale(1)", opacity: 1, offset: .2 }, + { transform: "translate(-50%,-50%) scale(1)", opacity: 1, offset: .7 }, + { transform: "translate(-50%,-50%) scale(1)", opacity: 0 }, + ], duration - arrival); + later(() => { stage.remove(); jumping = false; }, duration - arrival); + }, arrival); + busyUntil = Math.max(busyUntil, performance.now() + duration); + } function play(events, before, after, oldMeters) { const delay = reduced.matches ? 0 : 310; const spoken = new Set(); @@ -155,6 +231,7 @@ export function createResolutionEffects(root, cue) { }; const moved = new Set(); for (const e of events) { + if (e.kind === "jump") jump(sound); if (e.kind === "move" && !moved.has(e.crew)) { moved.add(e.crew); const pawn = q(`[data-crew="${e.crew}"]`), from = oldPawns.get(String(e.crew)), to = point(pawn); @@ -248,7 +325,8 @@ export function createResolutionEffects(root, cue) { } // Moving/resizing the viewport invalidates projectile coordinates. win.addEventListener("resize", clear); - doc.addEventListener("scroll", clear, true); + const scroll = () => { if (!jumping) clear(); }; + doc.addEventListener("scroll", scroll, true); const visibility = () => { if (doc.hidden) clear(); }; doc.addEventListener("visibilitychange", visibility); return { @@ -258,7 +336,7 @@ export function createResolutionEffects(root, cue) { destroy() { clear(); layer.remove(); win.removeEventListener("resize", clear); - doc.removeEventListener("scroll", clear, true); + doc.removeEventListener("scroll", scroll, true); doc.removeEventListener("visibilitychange", visibility); }, }; diff --git a/preview/sound.js b/preview/sound.js index 5487809..85b6605 100644 --- a/preview/sound.js +++ b/preview/sound.js @@ -17,7 +17,7 @@ export function createSoundDesign() { void context.suspend().catch(() => {}); } } - function voice({ from = 440, to = from, duration = .2, volume = .035, delay = 0, type = "sine", cutoff = 1400 }, pan) { + function voice({ from = 440, to = from, duration = .2, volume = .035, delay = 0, type = "sine", cutoff = 1400, cutoffTo = cutoff * .2, attack = .008 }, pan) { const source = type === "noise" ? context.createBufferSource() : context.createOscillator(); if (type === "noise") { if (!noise) { @@ -35,10 +35,10 @@ export function createSoundDesign() { const at = context.currentTime + delay; filter.type = "lowpass"; filter.frequency.setValueAtTime(cutoff, at); - filter.frequency.exponentialRampToValueAtTime(Math.max(80, cutoff * .2), at + duration); + filter.frequency.exponentialRampToValueAtTime(Math.max(80, cutoffTo), at + duration); stereo.pan.value = Math.max(-1, Math.min(1, pan)); gain.gain.setValueAtTime(.0001, at); - gain.gain.exponentialRampToValueAtTime(volume, at + .008); + gain.gain.exponentialRampToValueAtTime(volume, at + Math.min(attack, duration * .95)); gain.gain.exponentialRampToValueAtTime(.0001, at + duration); source.connect(filter).connect(gain).connect(stereo).connect(context.destination); voices.add(source); @@ -73,6 +73,20 @@ export function createSoundDesign() { { from: 110, to: 25, duration: .65, volume: .12 }, { type: "noise", cutoff: 600, delay: .12, duration: .55, volume: .06 }, ], + thruster: [ + { from: 65, to: 420, type: "triangle", duration: 1.2, attack: 1.05, volume: .075, cutoff: 450, cutoffTo: 2200 }, + { type: "noise", duration: 1.2, attack: 1.05, volume: .06, cutoff: 200, cutoffTo: 3200 }, + ], + jump: [ + { from: 420, to: 1800, duration: .35, volume: .05, cutoff: 3000, cutoffTo: 4000 }, + { type: "noise", cutoff: 4500, duration: .65, volume: .09 }, + { from: 80, to: 30, duration: .5, volume: .07 }, + ], + victory: [ + { from: 523.25, duration: .55, volume: .025 }, + { from: 659.25, delay: .12, duration: .55, volume: .025 }, + { from: 783.99, delay: .24, duration: .65, volume: .03 }, + ], }[kind]; if (layers) { for (const layer of layers) voice(layer, pan); return; } const notes = diff --git a/preview/style.css b/preview/style.css index e3126bd..d5ed3c4 100644 --- a/preview/style.css +++ b/preview/style.css @@ -1145,6 +1145,7 @@ input:not([type="checkbox"]):not([type="range"]) { position: relative; padding: 0 14px 12px; } +.ship-vessel { position: relative; transform-origin: 50% 30%; } .ship-hull::before { content: ""; position: absolute; @@ -1535,6 +1536,7 @@ input:not([type="checkbox"]):not([type="range"]) { width: 12px; height: 14px; transform: translateY(12px); + transform-origin: 50% 0; background: #95dfe7; border-radius: 0 0 6px 6px; box-shadow: 0 3px 7px #82eff04a; @@ -2640,3 +2642,8 @@ input:not([type="checkbox"]):not([type="range"]) { .fx-ring { width: 52px; height: 52px; border: 2px solid var(--fx-color); border-radius: 50%; box-shadow: inset 0 0 20px var(--fx-color),0 0 12px var(--fx-color); } .fx-spark { width: 5px; height: 5px; border-radius: 50%; background: var(--fx-color); box-shadow: 0 0 7px var(--fx-color); } .fx-delta { color: var(--fx-color); font-size: 24px; font-weight: 800; text-shadow: 0 2px 4px #020a10,0 0 8px #020a10; white-space: nowrap; } +.fx-jump-star { width: 2px; height: 45px; border-radius: 50%; background: linear-gradient(transparent,var(--fx-color),transparent); box-shadow: 0 0 6px #8eeaff70; } +.ship-jump-effects { position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; } +.ship-jump-effects > span { position: absolute; } +.fx-jump-success { display: grid; place-items: center; width: 80px; height: 80px; border: 2px solid var(--fx-color); border-radius: 50%; background: #102b32ee; color: var(--fx-color); box-shadow: 0 0 30px #76e5c650,inset 0 0 20px #76e5c620; } +.fx-jump-success .pictogram { width: 44px; height: 44px; } diff --git a/preview/tactical.js b/preview/tactical.js index 7aa912a..0b88e5b 100644 --- a/preview/tactical.js +++ b/preview/tactical.js @@ -130,7 +130,7 @@ export function createTacticalView({ .join( "", )}${[1, 2].map((i) => `