From 6f641eac69f696d98b0cbf5a5f18d2911893a9cd Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Mon, 7 Jan 2019 22:31:42 -0500 Subject: [PATCH] Worked on the Fen story. Moves have descriptions. Added exit function equivalents for exits themselves --- satiate.js | 5 ++- stories/fen-snack.js | 100 +++++++++++++++++++++++++++++++++++++++++++ world.js | 19 ++++++-- 3 files changed, 118 insertions(+), 6 deletions(-) diff --git a/satiate.js b/satiate.js index 9d97f6d..cedda58 100644 --- a/satiate.js +++ b/satiate.js @@ -2,12 +2,13 @@ let activeModal = null; +const newline = String.fromCharCode(160); const version = "pre-alpha"; let state; function print(lines) { - (lines.concat([String.fromCharCode(160)])).forEach(line => { + (lines.concat([newline])).forEach(line => { const log = document.querySelector("#log"); const div = document.createElement("div"); @@ -69,7 +70,7 @@ function init(story) { } } }; - + initWorld(story, state); initAudio(story, state); initGame(story, state); diff --git a/stories/fen-snack.js b/stories/fen-snack.js index 1f59092..fbbcdf6 100644 --- a/stories/fen-snack.js +++ b/stories/fen-snack.js @@ -2,6 +2,7 @@ stories.push({ id: "fen-snack", name: "Fen's Food", sounds: [ + "sfx/digested-test.ogg", "loop/fen-stomach.ogg", "loop/fen-intestines.ogg", "loop/fen-bowels.ogg" @@ -25,7 +26,106 @@ stories.push({ }, hooks: [ + ], + actions: [ + { + name: "Rub", + desc: "Knead on the muscular folds that surround your tasty little body", + execute: (room, state) => { + print(["You rub all over your prison's walls. Fen's stomach doesn't respond."]); + } + }, + { + name: "Submit", + desc: "Let Fen digest you", + execute: (room, state) => { + print(["You slump down in the acidic pit, curling up as it begins to churn you down to chyme. Fen's stomach snarls and bubbles for the next few minutes...and then you're gone~",newline,"Nothing's left but a bit of padding on your predator's hips..."]); + + goToRoom("digested", state); + } + } + ], + exits: { + "down": { + "target": "intestines", + "desc": "Push yourself deeper into the crux", + move: (room, state) => { + print(["You manage to push yourself down through the valve at the base of the crux's fetid stomach."]); + }, + hooks: [ + (room, exit, state) => { + if (Math.random() < 0.5) { + print(["Fen's stomach clenches and ripples, smothering your face in wet flesh and keeping you nice and trapped."]); + return false; + } else { + return true; + } + } + ] + } + } + }, + intestines: { + id: "intestines", + name: "Intestines", + desc: "Labyrinthine guts, winding on and on...", + move: (room, state) => { + print(["Your squirming body glides into the crux's tight, snaking guts."]); + }, + enter: (room, state) => { + playLoop("loop/fen-intestines.ogg"); + }, + exit: (room, state) => { + stopLoop("loop/fen-intestines.ogg"); + }, + exits: { + "up": { + target: "stomach", + desc: "Writhe back into Fen's roiling stomach" + }, + "down": { + target: "bowels", + desc: "Push yourself even deeper into your predator's body" + } + }, + hooks: [ + + ] + }, + bowels: { + id: "bowels", + name: "Bowels", + desc: "Cavernous bowels, rippling and squeezing over your bare skin", + move: (room, state) => { + print(["You enter the beast's humid bowels, taking shallow, stifled breaths of the musky air."]); + }, + enter: (room, state) => { + playLoop("loop/fen-bowels.ogg"); + }, + exit: (room, state) => { + stopLoop("loop/fen-bowels.ogg"); + }, + exits: { + "up": { + target: "intestines", + desc: "Squirm up higher" + } + }, + hooks: [ + ] + }, + digested: { + id: "digested", + name: "Fen's Hips", + desc: "You look good on him, at least~", + enter: (room, state) => { + playLoop("loop/fen-intestines.ogg"); + playSfx("sfx/digested-test.ogg"); + }, + exit: (room, state) => { + stopLoop("loop/fen-intestines.ogg"); + }, } } }); diff --git a/world.js b/world.js index c1efd05..a21c180 100644 --- a/world.js +++ b/world.js @@ -55,14 +55,17 @@ function moveToRoom(src, exit, dest, state) { } } + if (exit.move) + exit.move(from, state); + if (from && from.exit) - from.exit(state.world[dest], state); + from.exit(from, state); if (room.move) - room.move(state.world[dest], state); + room.move(room, state); if (room.enter) - room.enter(state.world[dest], state); + room.enter(room, state); state.player.location = dest; @@ -83,7 +86,7 @@ function goToRoom(dest, state) { if (from && from.exit) from.exit(state.world[dest], state); - + if (room.enter) room.enter(state.world[dest], state); @@ -149,6 +152,14 @@ function updateRoom(state) { // todo: log moveToRoom(room, exit, exit.target, state); }) + + button.addEventListener("mouseenter", () => { + showActionDescription(exit.desc); + }); + + button.addEventListener("mouseleave", () => { + removeActionDescription(); + }); }); }