Browse Source

Added background color control.

tags/v0.1.0
Fen Dweller 6 years ago
parent
commit
4d1208af7d
3 changed files with 16 additions and 2 deletions
  1. +5
    -2
      game.js
  2. +8
    -0
      satiate.js
  3. +3
    -0
      stories/fen-snack.js

+ 5
- 2
game.js View File

@@ -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 + ")";

}

+ 8
- 0
satiate.js View File

@@ -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);
} }




+ 3
- 0
stories/fen-snack.js View File

@@ -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",


Loading…
Cancel
Save