From 0c59fdefab86e99129476b84b8ee7224b29e3d34 Mon Sep 17 00:00:00 2001 From: Lun Ivanov <166240201+LunIvanov@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:31:14 +0100 Subject: [PATCH] [Sprig App] Advanced Clicking Simulator (#2641) * Add files via upload * Add files via upload * fix metadata --------- Co-authored-by: Mare Cosmin <147330889+Cosmin-Mare@users.noreply.github.com> --- games/Advanced-Clicking-Simulator.js | 196 ++++++++++++++++++++++ games/img/Advanced-Clicking-Simulator.png | Bin 0 -> 6967 bytes 2 files changed, 196 insertions(+) create mode 100644 games/Advanced-Clicking-Simulator.js create mode 100644 games/img/Advanced-Clicking-Simulator.png diff --git a/games/Advanced-Clicking-Simulator.js b/games/Advanced-Clicking-Simulator.js new file mode 100644 index 0000000000..85045be206 --- /dev/null +++ b/games/Advanced-Clicking-Simulator.js @@ -0,0 +1,196 @@ +/* +@title: Advanced Clicking Simulator +@author: Lun Ivanov +@tags: [] +@addedOn: 2024-11-26 +*/ + +const player = "p"; +const upgrade = "u"; +const downgrade = "d"; +const wall = "w"; + +setLegend( + [ player, bitmap` +......444....... +......4.4....... +......444....... +.....LLLLL...... +....LLLLLLL..... +....L.LLL.L..... +....L.LLL.L..... +....L.LLL.L..... +....4.LLL.4..... +......111....... +......111....... +......1.1....... +......1.1....... +......1.1....... +......3.3....... +................` ], + [ upgrade, bitmap` +................ +......4444...... +......4224...... +......4224...... +......4444...... +......4444...... +.44444444444444. +.42244422444224. +.42244422444224. +.44444444444444. +......4444...... +......4444...... +......4224...... +......4224...... +......4444...... +................` ], + [ downgrade, bitmap` +................ +................ +................ +................ +................ +................ +.33333333333333. +.30033300333003. +.30033300333003. +.33333333333333. +................ +................ +................ +................ +................ +................` ], + [ wall, bitmap` +00LLLLL00LLLLL00 +0LLLLLLLLLLLLLL0 +LLLLLLLLLLLLLLLL +LLLLLLLLLLLLLLLL +LLLLLLLLLLLLLLLL +LLLLLL0000LLLLLL +LLLLL000000LLLLL +0LLLL000000LLLL0 +0LLLL000000LLLL0 +LLLLL000000LLLLL +LLLLLL0000LLLLLL +LLLLLLLLLLLLLLLL +LLLLLLLLLLLLLLLL +LLLLLLLLLLLLLLLL +0LLLLLLLLLLLLLL0 +00LLLLL00LLLLL00` ] +); + +setSolids([ player, wall ]); + +const levels = [ + map` +....... +....... +....... +....... +....... +p......` +]; +setMap(levels[0]); + + +let currency = 0; +let clickValue = 1; +let upgradeCost = 5; +let downgradePenalty = 1; + +updateDisplay(); + +setInterval(spawnItem, 3000); +setInterval(spawnWalls, 5000); + + +onInput("w", () => { getFirst(player).y -= 1; }); +onInput("a", () => { getFirst(player).x -= 1; }); +onInput("s", () => { getFirst(player).y += 1; }); +onInput("d", () => { getFirst(player).x += 1; }); + +onInput("i", () => { + const playerTile = getTile(getFirst(player).x, getFirst(player).y); + playerTile.forEach(sprite => { + if (sprite.type === upgrade && currency >= upgradeCost) { + clickValue += 1; + currency -= upgradeCost; + upgradeCost += 15; + + sprite.remove(); + addText("Upgrade Collected!", { x: 1, y: 2, color: color`2` }); + setTimeout(() => clearText(), 1000); + } + else if (sprite.type === downgrade) { + clickValue = Math.max(1, clickValue - downgradePenalty); // prevent softlock (hopefully?) + + sprite.remove(); + addText("Downgrade Hit!", { x: 1, y: 2, color: color`4` }); + setTimeout(() => clearText(), 1000); + } + }); + updateDisplay(); +}); + + +onInput("j", () => { + currency += clickValue; + updateDisplay(); +}); + + +function updateDisplay() { + clearText(); + addText(`Currency: ${currency}`, { x: 1, y: 1, color: color`3` }); + addText(`Click Value: ${clickValue}`, { x: 1, y: 2, color: color`3` }); + addText(`Upgrade Cost: ${upgradeCost}`, { x: 1, y: 3, color: color`6` }); + if (clickValue >= 15) { + addText('you won, congrats!', { x: 1, y: 4, color: color`D` }); + } +} + +function spawnItem() { + const x = Math.floor(Math.random() * width()); + const y = Math.floor(Math.random() * height()); + + const itemType = Math.random() < 0.7 ? upgrade : downgrade; + + if (getTile(x, y).length === 0) { + addSprite(x, y, itemType); + + setTimeout(() => { + if (getTile(x, y).some(sprite => sprite.type === itemType)) { + clearTile(x, y); + } + }, 5000); + + } +} + + +function spawnWalls() { + const wallCount = Math.floor(Math.random() * 5) + 1; + + for (let i = 0; i < wallCount; i++) { + const x = Math.floor(Math.random() * width()); + const y = Math.floor(Math.random() * height()); + + if (getTile(x, y).length === 0) { + addSprite(x, y, wall); + + setTimeout(() => { + if (getTile(x, y).some(sprite => sprite.type === wall)) { + clearTile(x, y); + } + }, 8000); + + } + } +} + + +afterInput(() => { + clickValue = Math.max(1, clickValue); +}); diff --git a/games/img/Advanced-Clicking-Simulator.png b/games/img/Advanced-Clicking-Simulator.png new file mode 100644 index 0000000000000000000000000000000000000000..3f837c2191c7ca44fa020e878676aeee9f219420 GIT binary patch literal 6967 zcmeHLdpJ~E|KF3MbP`25y3J9FG*=^La?PztQ*x`6YR}A;$=u8g#w|+eirmtTNGhb# zK}o126-A^eLP|L*926n-TQh@n-uHQaPtWtd&-+i~S$nU&*7y5a-}U)k*539zthSq? ztfdS=&=l$lYext|9Rkf{q9Pcn=?OOnw<=^k)q_f13{3)U%sO#dfK-Hb+$~Pvizw-!BGkns5*Yw`zTW;ClL3z0L%;kML`&7}Xk;)mD)lyv+ zl`aqOjWzqKCc(wnFI+c4nLNWGO!5Awu%TO>+$?%fwY~D9osBcg`ZX1n7g%IA8#k3j z)=*HpDsRR&c1e!ktXR|*5jn$jTzKBjgYP33cA^rNS+v|gyy|}ZE>b>SO>CaZd!SHq z)#BT6$;QBW=cZa5xxTUqQrde{y#IQZfFQ14GKQ$i_M}z42oIK>qYBn zt0)W}2MaTKbObBr@TCreOw7f6nBj$p&~#)Qi)*UgSx~HvW-(2**BR3AG`LW0hTA&h9i*4WE`G| zBN8z{0weV2ieNE@E1WNdkYiXQLWY3F7qNI;v=kGj^L#|6+S*_qJz^h+Pos^(bA`h! z06uVHn2#f1@i-0#H&#O^vhf8V!v_6Z4WY9?AHg{yLY|L+f!O#WT+#fo5KP9XKHo>c zmTia0z#(je14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