From 9a61042d588db960459920d154e0c84efc6fe1a9 Mon Sep 17 00:00:00 2001 From: Nicky Case Date: Fri, 6 Sep 2019 13:34:09 -0400 Subject: [PATCH] chapter select and save and load --- scenes/act1.md | 4 +- scenes/act3.md | 2 +- scenes/act4.md | 5 +- scenes/credits.md | 4 +- scenes/intro.md | 66 ++++++++++++++++++- scripts/game/Game.js | 59 ++++++++++------- .../intermission/Intermission_SceneSetup.js | 7 ++ scripts/intro/Intro_BG.js | 10 ++- scripts/intro/Intro_SceneSetup.js | 9 ++- scripts/main.js | 16 ++++- styles/game.css | 8 +++ 11 files changed, 153 insertions(+), 37 deletions(-) diff --git a/scenes/act1.md b/scenes/act1.md index 8a64d2a..63916be 100644 --- a/scenes/act1.md +++ b/scenes/act1.md @@ -28,7 +28,7 @@ n: QUICK, WARN THEM! b: Human! Listen, we're in danger! The danger is... -n4: (LET *YOUR* ANXIETY COME OUT TO PLAY! PICK WHAT'S MOST SIMILAR TO WHAT *YOUR* FEAR TELLS YOU:) +n4: (LET _YOUR_ ANXIETY COME OUT TO PLAY! PICK WHAT'S MOST SIMILAR TO WHAT _YOUR_ FEAR TELLS YOU) [We're eating alone for lunch! Again!](#act1a_alone) @@ -412,7 +412,7 @@ h: What's new on Twitter? [Oh no, is that tweet secretly about *us?*](#act1d_subtweet) -[Hey, a GIF of a cat drinking milk.](#act1d_milk) +[Hey, a GIF of a cat drinking milk](#act1d_milk) # act1d_news diff --git a/scenes/act3.md b/scenes/act3.md index afcc4a2..8927fbe 100644 --- a/scenes/act3.md +++ b/scenes/act3.md @@ -606,7 +606,7 @@ h: *"Don't worry, be happy!"* `hong({ body:"normal", mouth:"normal", eyes:"normal" });` -h: All the wise folk of our time agree: negative emotions are *bad!* +h: The sages all knew that simple Stoic truth: negative emotions are *bad!* `hong({ eyes:"less_angry" });` diff --git a/scenes/act4.md b/scenes/act4.md index b69ad3d..69dad38 100644 --- a/scenes/act4.md +++ b/scenes/act4.md @@ -2,7 +2,8 @@ ``` SceneSetup.act4(); -/*Game.FORCE_CANT_SKIP = true;*/ +publish("SAVE_GAME", ["act4"]); +Game.FORCE_CANT_SKIP = true; ``` (...5001) @@ -203,7 +204,7 @@ h: So what the hell was the moral of this story? `hong({body:"one_up", eyes:"annoyed"})` -h: What did we even *learn*? I *was* being stupid, my "friends" *were* using me, and we almost goddamn *died*. +h: What did we even *learn*? I *was* being stupid, my "friends" *were* using me, and we almost frickin' *died*. `hong({body:"normal", eyes:"normal"})` diff --git a/scenes/credits.md b/scenes/credits.md index 0ded20e..c2e3732 100644 --- a/scenes/credits.md +++ b/scenes/credits.md @@ -2,7 +2,9 @@ ``` Game.FORCE_CANT_SKIP = true; -music('credits', {NO_LOOP:true, volume:0.45}); +music('credits', {NO_LOOP:true, volume:0.43}); +window.localStorage.setItem("continueChapter", "replay"); /* to Continue */ +window.localStorage.setItem("credits", "YUP!"); /* for chapter select */ ``` (...1901) diff --git a/scenes/intro.md b/scenes/intro.md index 0623020..1364896 100644 --- a/scenes/intro.md +++ b/scenes/intro.md @@ -4,9 +4,71 @@ # intro-play-button -`Game.OVERRIDE_FONT_SIZE=30;` +``` +_.PLAYED_BEFORE = !!window.localStorage.continueChapter; +``` -[
PLAY!
](#intro-start) `publish("intro-to-game-1"); Game.OVERRIDE_CHOICE_LINE=true;` +{{if !_.PLAYED_BEFORE}} +`Game.OVERRIDE_FONT_SIZE=30;` +{{/if}} + +{{if !_.PLAYED_BEFORE}} +[PLAY!](#intro-start) `publish("intro-to-game-1"); Game.OVERRIDE_CHOICE_LINE=true;` +{{/if}} + +{{if _.PLAYED_BEFORE && window.localStorage.continueChapter=="act2"}} +[CONTINUE: The Party](#act2) `publish("LOAD_GAME", ["act2"]); Game.OVERRIDE_CHOICE_LINE=true;` +{{/if}} + +{{if _.PLAYED_BEFORE && window.localStorage.continueChapter=="act3"}} +[CONTINUE: The Other Party](#act3) `publish("LOAD_GAME", ["act3"]); Game.OVERRIDE_CHOICE_LINE=true;` +{{/if}} + +{{if _.PLAYED_BEFORE && window.localStorage.continueChapter=="act4"}} +[CONTINUE: The Other Sandwich](#act4) `publish("LOAD_GAME", ["act4"]); Game.OVERRIDE_CHOICE_LINE=true;` +{{/if}} + +{{if _.PLAYED_BEFORE && window.localStorage.continueChapter=="replay"}} +`Game.OVERRIDE_FONT_SIZE=30;` +{{/if}} + +{{if _.PLAYED_BEFORE && window.localStorage.continueChapter=="replay"}} +[REPLAY!](#intro-start) `publish("intro-to-game-1"); Game.OVERRIDE_CHOICE_LINE=true;` +{{/if}} + +{{if _.PLAYED_BEFORE}} +[Chapter Select](#chapter-select) `Game.OVERRIDE_CHOICE_LINE=true;` +{{/if}} + +[(content notes)](#content-notes) `Game.OVERRIDE_CHOICE_LINE=true;` + +# chapter-select + +`publish("HACK_chselect");` + +[I. The Sandwich](#intro-start) `publish("HACK_chselect_end"); publish("intro-to-game-1"); Game.OVERRIDE_CHOICE_LINE=true;` + +[II. The Party](#act2) `publish("HACK_chselect_end"); publish("LOAD_GAME", ["act2"]); Game.OVERRIDE_CHOICE_LINE=true;` + +{{if window.localStorage.act3}} +[III. The Other Party](#act3) `publish("HACK_chselect_end"); publish("LOAD_GAME", ["act3"]); Game.OVERRIDE_CHOICE_LINE=true;` +{{/if}} + +{{if !window.localStorage.act3}} +[III. The Other Party]() +{{/if}} + +{{if window.localStorage.act4}} +[IV. The Other Sandwich](#act4) `publish("HACK_chselect_end"); publish("LOAD_GAME", ["act4"]); Game.OVERRIDE_CHOICE_LINE=true;` +{{/if}} + +{{if !window.localStorage.act4}} +[III. The Other Sandwich]() +{{/if}} + +[V. Credits](#credits) `publish("HACK_chselect_end"); stopAllSounds(); Game.OVERRIDE_CHOICE_LINE=true;` + +[(main menu)](#intro-play-button) `publish("HACK_chselect_end"); Game.OVERRIDE_CHOICE_LINE=true;` # intro-start diff --git a/scripts/game/Game.js b/scripts/game/Game.js index 2c969e9..69069a5 100644 --- a/scripts/game/Game.js +++ b/scripts/game/Game.js @@ -146,6 +146,7 @@ var _unpauseOrSkip = function(){ Game.onUnpause(); }else{ Game.clearAllTimeouts(); + publish("super_hack_skip_intro"); } }; window.addEventListener("click", _unpauseOrSkip); @@ -650,7 +651,13 @@ Game.OVERRIDE_FONT_SIZE = false; Game.executeChoice = function(line){ var choiceText = line.match(/\[([^\]]*)\]/)[1].trim(); - var choiceID = line.match(/\(\#([^\)]*)\)/)[1].trim().toLocaleLowerCase(); + var choiceID = line.match(/\(\#([^\)]*)\)/); + var THERE_IS_NO_CHOICE; + if(!choiceID){ + THERE_IS_NO_CHOICE = true; + }else{ + choiceID = choiceID[1].trim().toLocaleLowerCase(); + } var preChoiceCodeIfAny = null; if(/\`(.*)\`/.test(line)){ @@ -671,35 +678,39 @@ Game.executeChoice = function(line){ var div = document.createElement("div"); div.innerHTML = choiceText; div.setAttribute("speaker", Game.OVERRIDE_CHOICE_SPEAKER ? Game.OVERRIDE_CHOICE_SPEAKER : "b"); - div.onclick = function(event){ + if(!THERE_IS_NO_CHOICE){ + div.onclick = function(event){ - // Any pre-choice code? - if(preChoiceCodeIfAny) Game.executeCode(preChoiceCodeIfAny); + // Any pre-choice code? + if(preChoiceCodeIfAny) Game.executeCode(preChoiceCodeIfAny); - // Override line... ONCE - if(!Game.OVERRIDE_CHOICE_LINE){ - if(Game.OVERRIDE_CHOICE_SPEAKER){ - Game.addToQueue(Game.OVERRIDE_CHOICE_SPEAKER+": "+originalChoiceText); - }else{ - Game.addToQueue("b: "+originalChoiceText); + // Override line... ONCE + if(!Game.OVERRIDE_CHOICE_LINE){ + if(Game.OVERRIDE_CHOICE_SPEAKER){ + Game.addToQueue(Game.OVERRIDE_CHOICE_SPEAKER+": "+originalChoiceText); + }else{ + Game.addToQueue("b: "+originalChoiceText); + } } - } - Game.OVERRIDE_CHOICE_SPEAKER = null; - Game.OVERRIDE_CHOICE_LINE = false; + Game.OVERRIDE_CHOICE_SPEAKER = null; + Game.OVERRIDE_CHOICE_LINE = false; - // Play sound - sfx("ui_click"); + // Play sound + sfx("ui_click"); - // Goto that choice, now! - Game.goto(choiceID); + // Goto that choice, now! + Game.goto(choiceID); - // STOP THE PROP - event.stopPropagation(); + // STOP THE PROP + event.stopPropagation(); - }; - div.onmouseover = function(){ - sfx("ui_hover"); - }; + }; + div.onmouseover = function(){ + sfx("ui_hover"); + }; + }else{ + div.setAttribute("speaker", Game.OVERRIDE_CHOICE_SPEAKER ? Game.OVERRIDE_CHOICE_SPEAKER : "none"); + } // Add choice, animated! div.style.top = "150px"; @@ -807,7 +818,7 @@ Game.executeGoto = function(line){ Game.getLineType = function(line){ // Is it a choice? - var isChoice = /\[.*\]\(\#.*\)/.test(line); + var isChoice = /\[.*\]\(.*\)/.test(line); if(isChoice) return "choice"; // Is it a goto? diff --git a/scripts/intermission/Intermission_SceneSetup.js b/scripts/intermission/Intermission_SceneSetup.js index 2fda3b1..9b171bd 100644 --- a/scripts/intermission/Intermission_SceneSetup.js +++ b/scripts/intermission/Intermission_SceneSetup.js @@ -22,6 +22,13 @@ SceneSetup.intermission = function(STAGE){ Game.FORCE_CANT_SKIP = true; Game.NO_NARRATOR_SOUNDS = true; $("#click_to_advance").style.color = "#000"; + + // SAVE + if(_.INTERMISSION_STAGE==1){ // between Act I and II + publish("SAVE_GAME", ["act2"]); + }else if(_.INTERMISSION_STAGE==2){ // between Act II and III + publish("SAVE_GAME", ["act3"]); + } // KILL Game.scene.kill = function(){ diff --git a/scripts/intro/Intro_BG.js b/scripts/intro/Intro_BG.js index b49eee8..2f45d4a 100644 --- a/scripts/intro/Intro_BG.js +++ b/scripts/intro/Intro_BG.js @@ -20,8 +20,7 @@ Loader.addSounds([ function BG_Intro(){ - var ticker = 0; //18;//0; - + var ticker = 0; // 18; // SKIP var self = this; @@ -203,6 +202,13 @@ function BG_Intro(){ }) ); + _subscriptions.push( + subscribe("super_hack_skip_intro", function(){ + if(ticker>0.1 && ticker<18){ + frameTicker = ticker = 18; + } + }) + ); ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/intro/Intro_SceneSetup.js b/scripts/intro/Intro_SceneSetup.js index 5fe9e25..0a7f35b 100644 --- a/scripts/intro/Intro_SceneSetup.js +++ b/scripts/intro/Intro_SceneSetup.js @@ -18,4 +18,11 @@ SceneSetup.intro = function(){ $("#gear").style.display = "none"; $("#about").style.display = "none"; -}; \ No newline at end of file +}; + +subscribe("HACK_chselect", function(){ + Game.choicesDOM.style.height = "250px"; +}); +subscribe("HACK_chselect_end", function(){ + Game.choicesDOM.style.height = "130px"; +}); \ No newline at end of file diff --git a/scripts/main.js b/scripts/main.js index ea9a011..dbcf6e7 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -35,7 +35,7 @@ subscribe("START_GAME", function(){ $("#about").style.display = "block"; // Intro - //Game.goto("intro"); + Game.goto("intro"); //Game.TEXT_SPEED = 5; @@ -52,10 +52,22 @@ subscribe("START_GAME", function(){ //Game.goto("act4"); // Credits - Game.goto("credits"); + //Game.goto("credits"); }); +subscribe("SAVE_GAME", function(nextChapter){ + var json = JSON.stringify(_); + window.localStorage.setItem("continueChapter", nextChapter); // to Continue + window.localStorage.setItem(nextChapter, json); // for chapter select +}); + +subscribe("LOAD_GAME", function(fromNextChapter){ + _ = JSON.parse(window.localStorage.getItem(fromNextChapter)); // LOAD IT! +}); + +// TODO: also save Sound options??? + window._SAVE = function(){ copy(JSON.stringify(_)); }; diff --git a/styles/game.css b/styles/game.css index f9f482b..41cc1f9 100644 --- a/styles/game.css +++ b/styles/game.css @@ -929,6 +929,14 @@ DIALOGUEZ -o-transition-timing-function: cubic-bezier(0.350, 0.005, 0.370, 1.390); transition-timing-function: cubic-bezier(0.350, 0.005, 0.370, 1.390); /* custom */ } +#game_choices > div[speaker=none]{ + background: #000; + color: #fff; + font-weight: lighter; + opacity: 0.5; + text-decoration: line-through; + cursor: default; +} #game_choices > div[speaker=b]{ background: #000; color: #fff;