| @@ -93,11 +93,14 @@ function stopClassTimers(timerClass, state, inverse) { | |||||
| matches.forEach(timer => clearTimeout(timer.timeout)); | matches.forEach(timer => clearTimeout(timer.timeout)); | ||||
| state.timers = others; | state.timers = others; | ||||
| } | } | ||||
| } | } | ||||
| function stopAllTimers(state) { | function stopAllTimers(state) { | ||||
| state.timers.forEach(x => clearTimeout(x.timeout)); | state.timers.forEach(x => clearTimeout(x.timeout)); | ||||
| state.timers = []; | state.timers = []; | ||||
| } | } | ||||
| function setBackgroundColor(r, g, b) { | |||||
| document.querySelector(".scene").style["background-color"] = "rgb(" + r + "," + g + "," + b + ")"; | |||||
| } | |||||
| @@ -7,6 +7,8 @@ const version = "pre-alpha"; | |||||
| let state; | let state; | ||||
| let refreshHook; | |||||
| function print(lines) { | function print(lines) { | ||||
| (lines.concat([newline])).forEach(line => { | (lines.concat([newline])).forEach(line => { | ||||
| const log = document.querySelector("#log"); | const log = document.querySelector("#log"); | ||||
| @@ -24,6 +26,10 @@ function refresh() { | |||||
| updateRoom(state); | updateRoom(state); | ||||
| updateWorldInfo(state); | updateWorldInfo(state); | ||||
| updatePlayerInfo(state); | updatePlayerInfo(state); | ||||
| if (refreshHook) { | |||||
| refreshHook(state) | |||||
| } | |||||
| } | } | ||||
| function switchModal(to) { | function switchModal(to) { | ||||
| @@ -77,6 +83,8 @@ function init(story) { | |||||
| story.intro.setup(state); | story.intro.setup(state); | ||||
| refreshHook = story.refresh; | |||||
| goToRoom(story.intro.start, state); | goToRoom(story.intro.start, state); | ||||
| } | } | ||||
| @@ -29,6 +29,9 @@ stories.push({ | |||||
| }, state); | }, state); | ||||
| } | } | ||||
| }, | }, | ||||
| refresh: state => { | |||||
| setBackgroundColor(50 - state.player.stats.health/2, 0, 0) | |||||
| }, | |||||
| world: { | world: { | ||||
| stomach: { | stomach: { | ||||
| id: "stomach", | id: "stomach", | ||||