瀏覽代碼

Switch colors from anonymous functions to getters

tags/v0.1.3
Fen Dweller 5 年之前
父節點
當前提交
7b59b7919a
共有 3 個檔案被更改,包括 6 行新增6 行删除
  1. +2
    -2
      game.js
  2. +2
    -2
      stories/demo.js
  3. +2
    -2
      stories/fen-snack.js

+ 2
- 2
game.js 查看文件

@@ -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(val);
bar.style["background-color"] = val.color;


field.appendChild(label); field.appendChild(label);
field.appendChild(bar); field.appendChild(bar);
@@ -96,7 +96,7 @@ function updateStatDisplay(stats, statType) {


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




+ 2
- 2
stories/demo.js 查看文件

@@ -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: (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)"};
state.player.stats.oofs = {name: "Oofs", type: "meter", value: 0, max: 10, get color() { return "rgb(" + (155 + this.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 查看文件

@@ -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: (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)"};
state.player.stats.health = {name: "Health", type: "meter", value: 100, min: 0, max: 100, get color() {return "rgb(" + (155+this.value) + ",0,0)"}};
state.player.stats.stamina = {name: "Stamina", type: "meter", value: 100, min: 0, max: 100, get color() {return "rgb(100," + (155+this.value) + ",0)"}};


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


Loading…
取消
儲存