浏览代码

Add mechanics for powerups with a duration

tags/v0.0.4
Fen Dweller 5 年前
父节点
当前提交
89e0f6b167
共有 2 个文件被更改,包括 29 次插入0 次删除
  1. +11
    -0
      constants.js
  2. +18
    -0
      gorge.js

+ 11
- 0
constants.js 查看文件

@@ -1067,5 +1067,16 @@ const powerups = {
clickPopup("CAR!", "gulp", [e.clientX, e.clientY]);
clickPopup("+1 car", "food", [e.clientX, e.clientY]);
}
},
"nothing": {
name: "Nothing",
description: "Does nothing for 10 seconds",
icon: "fa-car",
duration: 10000,
effect: state => state.belongings.car.count += 1,
popup: (self, e) => {
clickPopup("CAR!", "gulp", [e.clientX, e.clientY]);
clickPopup("+1 car", "food", [e.clientX, e.clientY]);
}
}
}

+ 18
- 0
gorge.js 查看文件

@@ -19,6 +19,23 @@ let clickVictim = "micro";

let lastTime = 0;

const activePowerups = [];

function tickPowerups(delta) {
// I love mutating arrays as I traverse them.
for (let i = activePowerups.length-1; i >= 0; i--) {
activePowerups[i].lifetime -= delta;
if (activePowerups[i].lifetime <= 0) {
clickPopup("OOF", "info", [500, 500]);
activePowerups.splice(i, 1);
}
}
}

function addPowerup(powerup) {
activePowerups.push({powerup: powerup, lifetime: powerup.duration});
}

function applyGlobalProdBonuses(productivity) {
for (let effect of effects["prod-all"]) {

@@ -109,6 +126,7 @@ function updateDisplay() {
displayResources();
displayBuildings();
displayUpgrades(showOwnedUpgrades);
tickPowerups(delta);

setTimeout(updateDisplay, 1000/updateRate);
}


正在加载...
取消
保存