Browse Source

Allow for stat bar colors to change

tags/v0.1.3
Fen Dweller 5 years ago
parent
commit
251c2fa7a2
3 changed files with 11 additions and 6 deletions
  1. +7
    -2
      game.js
  2. +2
    -2
      stories/demo.js
  3. +2
    -2
      stories/fen-snack.js

+ 7
- 2
game.js View File

@@ -36,7 +36,7 @@ function createStatDisplays(stats, statType) {


const bar = document.createElement("div"); const bar = document.createElement("div");
bar.classList.add("stat-bar"); bar.classList.add("stat-bar");
bar.style["background-color"] = val.color;
bar.style["background-color"] = val.color(val);


field.appendChild(label); field.appendChild(label);
field.appendChild(bar); field.appendChild(bar);
@@ -90,9 +90,14 @@ function updateStatDisplay(stats, statType) {
if (val.hidden === true) { if (val.hidden === true) {
const field = document.querySelector("#" + statType + "-info-" + key); const field = document.querySelector("#" + statType + "-info-" + key);
field.style.display = "none"; field.style.display = "none";
} else if (val.hidden === false) {
} else {
const field = document.querySelector("#" + statType + "-info-" + key); const field = document.querySelector("#" + statType + "-info-" + key);
field.style.display = "block"; field.style.display = "block";

if (val.type == "meter") {
const bar = document.querySelector("#" + statType + "-info-" + key + " > .stat-bar");
bar.style["background-color"] = val.color(val);
}
} }


if (val.type == "meter") { if (val.type == "meter") {


+ 2
- 2
stories/demo.js View File

@@ -9,8 +9,8 @@ stories.push({
"start": "Home", "start": "Home",
"setup": () => { "setup": () => {
state.info.time.value = 3600; state.info.time.value = 3600;
state.player.stats.oofs = {name: "Oofs", type: "meter", value: 0, max: 10, color: "rgb(255,0,0)"};
state.player.stats.number = {name: "Number", type: "counter", value: 0, max: 10, color: "rgb(255,255,255)"};
state.player.stats.oofs = {name: "Oofs", type: "meter", value: 0, max: 10, color: (self) => { console.log('hi'); return "rgb(" + (155 + self.value*10) + ",0,0)"}};
state.player.stats.number = {name: "Number", type: "counter", value: 0, max: 10, color: () => "rgb(255,255,255)"};
}, },
"intro": () => { "intro": () => {
print(["don't fall down the stairs ok"]); print(["don't fall down the stairs ok"]);


+ 2
- 2
stories/fen-snack.js View File

@@ -33,8 +33,8 @@ stories.push({
start: "stomach", start: "stomach",
setup: () => { setup: () => {
state.info.time.value = 86400 - 60 * 25 - 25; state.info.time.value = 86400 - 60 * 25 - 25;
state.player.stats.health = {name: "Health", type: "meter", value: 100, min: 0, max: 100, color: "rgb(255,0,0)"};
state.player.stats.stamina = {name: "Stamina", type: "meter", value: 100, min: 0, max: 100, color: "rgb(100,255,0)"};
state.player.stats.health = {name: "Health", type: "meter", value: 100, min: 0, max: 100, color: (self) => "rgb(" + (155+self.value) + ",0,0)"};
state.player.stats.stamina = {name: "Stamina", type: "meter", value: 100, min: 0, max: 100, color: (self) => "rgb(100," + (155+self.value) + ",0)"};


startTimer({ startTimer({
id: "taunting", id: "taunting",


Loading…
Cancel
Save