diff --git a/constants.js b/constants.js index 4d98c9c..b69f1ee 100644 --- a/constants.js +++ b/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]); + } } } \ No newline at end of file diff --git a/gorge.js b/gorge.js index 3dda89d..b6d0d89 100644 --- a/gorge.js +++ b/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); }