diff --git a/engine/player.js b/engine/player.js index bb2d74c..50c6f7d 100644 --- a/engine/player.js +++ b/engine/player.js @@ -29,6 +29,7 @@ async function boot() { if (G.debug) { initDebug(); window.RSG = { G, input, vid }; } preload(G.data.scenes[G.data.start].clip); preload(G.data.scenes[G.data.start].death); + attractPlay(); addEventListener("keydown", onKey); initTouch(); requestAnimationFrame(tick); @@ -64,10 +65,17 @@ function playClip(url, onEnded) { const vid = () => vids[cur]; // ---------- scene flow ---------- +function attractPlay() { // looping mood video behind the title screen + const v = playClip("clips/attract.mp4", null); + v.loop = true; + v.muted = true; +} + function startGame() { G.lives = G.data.meta.lives; G.score = 0; G.checkpoint = G.data.start; + vids.forEach((v) => { v.muted = false; v.loop = false; }); $("attract").classList.add("hidden"); playScene(G.data.start); } @@ -134,7 +142,7 @@ function toAttract() { $("msg").classList.add("hidden"); $("hiscore").textContent = "HI-SCORE " + (localStorage.rsg_hiscore || 0); $("attract").classList.remove("hidden"); - vid().pause(); + attractPlay(); G.state = "ATTRACT"; } function saveHi() { diff --git a/engine/scenes.json b/engine/scenes.json index f9a41a4..e0d75fd 100644 --- a/engine/scenes.json +++ b/engine/scenes.json @@ -2,9 +2,9 @@ "meta": { "title": "RECORD STORE GUY", "lives": 5, - "version": 2 + "version": 3 }, - "start": "s01", + "start": "s00", "scenes": { "s01": { "clip": "clips/s01_action.mp4", @@ -59,6 +59,29 @@ "cue": true } ], + "onSuccess": "s04", + "checkpoint": false + }, + "s00": { + "clip": "clips/intro.mp4", + "death": "clips/s01_death.mp4", + "windows": [], + "onSuccess": "s01", + "checkpoint": false + }, + "s04": { + "clip": "clips/s04_action.mp4", + "death": "clips/s04_death.mp4", + "windows": [ + { + "t": [ + 6.0, + 7.2 + ], + "input": "left", + "cue": true + } + ], "onSuccess": "WIN", "checkpoint": false }