Code edit (1 edits merged)
Please save this source code
User prompt
Every time you get a coin can the coin jump out from the bottom and then bounces up to the coin counter and then the counter updates βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Now make the store button under the tab section
User prompt
It is still very crowded and also in the store and the cards tab the things are on the coin counter
User prompt
Still very crowded
User prompt
The cards section is very crowded can you spread thing out a bit
User prompt
Can you move the coin and click counter down
User prompt
Make the buttons more detailed with shadow
User prompt
Can you refresh the colour scheme
User prompt
Can you make the button a bit bigger and the text on the button a bit smaller
User prompt
Can you make the text on the button smaller so you can fit the longer text
User prompt
Can you now make the whole thing much bigger
User prompt
In the cards tab can you keep the store button but instead of a card slots button can you make the card slots in the cards tab
User prompt
Now can you make the cards tab a menu in infinity and the store in a menu in cards
User prompt
Can you remove the timed section
User prompt
Can you make coins have a specific chance to come every time you click the button
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.ownedCards = ownedCards;' Line Number: 362 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.ownedCards = ownedCards;' Line Number: 361
User prompt
Can you remove the booster and make a tab called cards where you can buy cards in a tab called store and you can use the cards by putting them i a slot in the cards tab where you can buy more slots the cards will be things like "15% chance to get a critical hit" or "one click per second automatically" βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
Can you add boosters like 3x click for 3 min or auto clicker for 10 sec βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Could we make a login system to save your progress βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Can you havea random jumscare every hundred βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Can you add jumscares at every hundred on infinity βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Could we now ad some background music
User prompt
I can't hear anything
/**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var gameContainer = document.getElementById("game-container"); var clicker = document.getElementById("clicker"); var scoreDisplay = document.getElementById("score"); var coinDisplay = document.getElementById("coin-display"); var upgradeButton = document.getElementById("upgrade-button"); var upgradeCostDisplay = document.getElementById("upgrade-cost"); var cardSlotsContainer = document.getElementById("card-slots"); var buySlotButton = document.getElementById("buy-slot-button"); // Modal for card selection var cardModal = document.createElement("div"); cardModal.style.display = "none"; cardModal.style.position = "fixed"; cardModal.style.top = "50%"; cardModal.style.left = "50%"; cardModal.style.transform = "translate(-50%, -50%)"; cardModal.style.backgroundColor = "white"; cardModal.style.border = "1px solid black"; cardModal.style.padding = "20px"; cardModal.style.zIndex = "1000"; cardModal.innerHTML = "<h3>Select a Card</h3><div id=\"card-list\"></div><button id=\"cancel-select\">Cancel</button>"; document.body.appendChild(cardModal); document.getElementById("cancel-select").onclick = function () { cardModal.style.display = "none"; }; var gameState = { score: 0, coins: 0, upgradeLevel: 1, upgradeCost: 50, clickValue: 1, ownedCards: [{ name: "Fire Boost", effect: "+2 per click" }, { name: "Golden Touch", effect: "+10% coins" }, { name: "Double Strike", effect: "x2 click every 5s" }], equippedCards: [], cardSlots: 1 }; function loadGame() { var savedState = localStorage.getItem("clickerGame"); if (savedState) { gameState = JSON.parse(savedState); } updateDisplay(); renderCardSlots(); } function saveGame() { localStorage.setItem("clickerGame", JSON.stringify(gameState)); } function updateDisplay() { scoreDisplay.textContent = "Score: ".concat(gameState.score); coinDisplay.textContent = "Coins: ".concat(gameState.coins); upgradeCostDisplay.textContent = "Upgrade Cost: ".concat(gameState.upgradeCost); } function renderCardSlots() { cardSlotsContainer.innerHTML = ""; for (var i = 0; i < gameState.cardSlots; i++) { var slot = document.createElement("div"); slot.className = "card-slot"; slot.dataset.index = i; slot.style.border = "1px solid gray"; slot.style.padding = "10px"; slot.style.margin = "5px"; slot.style.cursor = "pointer"; slot.style.backgroundColor = "#f0f0f0"; var equipped = gameState.equippedCards[i]; slot.textContent = equipped ? equipped.name : "Empty Slot"; slot.onclick = function () { return openCardSelector(i); }; cardSlotsContainer.appendChild(slot); } } function openCardSelector(slotIndex) { var cardList = document.getElementById("card-list"); cardList.innerHTML = ""; gameState.ownedCards.forEach(function (card) { var isEquipped = gameState.equippedCards.some(function (c) { return (c === null || c === void 0 ? void 0 : c.name) === card.name; }); var cardBtn = document.createElement("button"); cardBtn.textContent = "".concat(card.name, " (").concat(card.effect, ")"); cardBtn.disabled = isEquipped; cardBtn.style.margin = "5px"; cardBtn.onclick = function () { gameState.equippedCards[slotIndex] = card; cardModal.style.display = "none"; renderCardSlots(); saveGame(); }; cardList.appendChild(cardBtn); }); cardModal.style.display = "block"; } clicker.addEventListener("click", function () { gameState.score += gameState.clickValue; gameState.coins += gameState.clickValue; updateDisplay(); saveGame(); }); upgradeButton.addEventListener("click", function () { if (gameState.coins >= gameState.upgradeCost) { gameState.coins -= gameState.upgradeCost; gameState.upgradeLevel += 1; gameState.clickValue += 1; gameState.upgradeCost = Math.floor(gameState.upgradeCost * 1.5); updateDisplay(); saveGame(); } }); buySlotButton.addEventListener("click", function () { var cost = 100 * (gameState.cardSlots + 1); if (gameState.coins >= cost) { gameState.coins -= cost; gameState.cardSlots += 1; gameState.equippedCards.push(null); updateDisplay(); renderCardSlots(); saveGame(); } else { alert("Not enough coins to buy a new card slot!"); } }); loadGame();
===================================================================
--- original.js
+++ change.js
@@ -1,654 +1,139 @@
/****
-* Plugins
-****/
-var storage = LK.import("@upit/storage.v1");
-var tween = LK.import("@upit/tween.v1");
-
-/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x1a1a2e
+ backgroundColor: 0x000000
});
/****
* Game Code
****/
-var currentTab = storage.currentTab || 'infinity';
-var clickCount = storage.clickCount || 0;
-// Cards and store variables
-var cards = storage.cards || [];
-var ownedCards = storage.ownedCards || [];
-var equippedCards = storage.equippedCards || [];
-var cardSlots = storage.cardSlots || 1;
-var coins = storage.coins || 0;
-var currentTab = storage.currentTab || 'infinity';
-// Create tab button shadows
-var infinityTabShadow = game.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 500,
- height: 160
-}));
-infinityTabShadow.tint = 0x000000;
-infinityTabShadow.alpha = 0.3;
-infinityTabShadow.x = 2048 / 2 - 400 + 6;
-infinityTabShadow.y = 200 + 6;
-var cardsTabShadow = game.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 500,
- height: 160
-}));
-cardsTabShadow.tint = 0x000000;
-cardsTabShadow.alpha = 0.3;
-cardsTabShadow.x = 2048 / 2 + 400 + 6;
-cardsTabShadow.y = 200 + 6;
-// Create tab buttons
-var infinityTab = game.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 500,
- height: 160
-}));
-infinityTab.x = 2048 / 2 - 400;
-infinityTab.y = 200;
-var cardsTab = game.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 500,
- height: 160
-}));
-cardsTab.x = 2048 / 2 + 400;
-cardsTab.y = 200;
-// Tab text
-var infinityTabText = new Text2('INFINITY', {
- size: 60,
- fill: 0xffffff
-});
-infinityTabText.anchor.set(0.5, 0.5);
-infinityTabText.x = infinityTab.x;
-infinityTabText.y = infinityTab.y;
-game.addChild(infinityTabText);
-var cardsTabText = new Text2('CARDS', {
- size: 60,
- fill: 0xffffff
-});
-cardsTabText.anchor.set(0.5, 0.5);
-cardsTabText.x = cardsTab.x;
-cardsTabText.y = cardsTab.y;
-game.addChild(cardsTabText);
-// Create button shadow
-var buttonShadow = game.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5
-}));
-buttonShadow.tint = 0x000000;
-buttonShadow.alpha = 0.3;
-buttonShadow.x = 2048 / 2 + 8;
-buttonShadow.y = 2732 / 2 - 100 + 8;
-// Create the main button
-var button = game.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5
-}));
-// Position button in center of screen
-button.x = 2048 / 2;
-button.y = 2732 / 2 - 100;
-// Array of random button texts
-var buttonTexts = ['CLICK ME!', 'TAP HERE!', 'PRESS ME!', 'HIT IT!', 'CLICK NOW!', 'TAP AWAY!', 'PUSH IT!', 'GO AHEAD!', 'CLICK THIS!', 'TAP TAP!'];
-// Create button text with random initial text
-var buttonText = new Text2(buttonTexts[Math.floor(Math.random() * buttonTexts.length)], {
- size: 60,
- fill: 0xffffff
-});
-buttonText.anchor.set(0.5, 0.5);
-buttonText.x = button.x;
-buttonText.y = button.y;
-game.addChild(buttonText);
-// Create counter text
-var counterText = new Text2('Clicks: 0', {
- size: 160,
- fill: 0x50fa7b
-});
-counterText.anchor.set(0.5, 0.5);
-counterText.x = 2048 / 2;
-counterText.y = 2732 / 2 + 300;
-game.addChild(counterText);
-// Create coins display
-var coinsText = new Text2('Coins: ' + coins, {
- size: 100,
- fill: 0xff79c6
-});
-coinsText.anchor.set(0.5, 0.5);
-coinsText.x = 2048 / 2;
-coinsText.y = 700;
-game.addChild(coinsText);
-// Cards menu container
-var cardsMenuContainer = new Container();
-game.addChild(cardsMenuContainer);
-// Create store menu button shadow
-var storeMenuButtonShadow = cardsMenuContainer.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 800,
- height: 200
-}));
-storeMenuButtonShadow.tint = 0x000000;
-storeMenuButtonShadow.alpha = 0.3;
-storeMenuButtonShadow.x = 2048 / 2 + 8;
-storeMenuButtonShadow.y = 400 + 8;
-// Create store menu button only
-var storeMenuButton = cardsMenuContainer.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 800,
- height: 200
-}));
-storeMenuButton.x = 2048 / 2;
-storeMenuButton.y = 400;
-var storeMenuText = new Text2('STORE', {
- size: 80,
- fill: 0xffffff
-});
-storeMenuText.anchor.set(0.5, 0.5);
-storeMenuText.x = storeMenuButton.x;
-storeMenuText.y = storeMenuButton.y;
-cardsMenuContainer.addChild(storeMenuText);
-// Cards tab UI elements
-var cardSlotsContainer = new Container();
-game.addChild(cardSlotsContainer);
-var cardSlotButtons = [];
-var cardSlotTexts = [];
-// Store tab UI elements
-var storeContainer = new Container();
-game.addChild(storeContainer);
-var storeCards = [{
- name: 'Critical Hit',
- description: '15% chance for critical hit (2x damage)',
- price: 100
-}, {
- name: 'Auto Clicker',
- description: 'One click per second automatically',
- price: 200
-}, {
- name: 'Double Coins',
- description: 'Earn 2x coins from clicks',
- price: 300
-}, {
- name: 'Lucky Strike',
- description: '10% chance for 5x click value',
- price: 250
-}];
-// Function to update tab visibility
-function updateTabDisplay() {
- if (currentTab === 'infinity') {
- // Show infinity mode elements
- button.visible = true;
- buttonText.visible = true;
- counterText.visible = true;
- counterText.setText('Clicks: ' + clickCount);
- coinsText.visible = true;
- // Hide other mode elements
- cardSlotsContainer.visible = false;
- storeContainer.visible = false;
- cardsMenuContainer.visible = false;
- // Update tab colors
- infinityTab.tint = 0x8b5cf6;
- cardsTab.tint = 0x4a90e2;
- } else if (currentTab === 'cards') {
- // Show cards mode elements with card slots
- button.visible = false;
- buttonText.visible = false;
- counterText.visible = false;
- coinsText.visible = true;
- cardSlotsContainer.visible = true;
- storeContainer.visible = false;
- cardsMenuContainer.visible = true;
- // Update card slots display
- updateCardSlots();
- // Update tab colors
- infinityTab.tint = 0x4a90e2;
- cardsTab.tint = 0x8b5cf6;
- } else if (currentTab === 'store') {
- // Show store mode elements
- button.visible = false;
- buttonText.visible = false;
- counterText.visible = false;
- coinsText.visible = true;
- cardSlotsContainer.visible = false;
- storeContainer.visible = true;
- cardsMenuContainer.visible = false;
- // Update store display
- updateStoreDisplay();
- // Update tab colors
- infinityTab.tint = 0x4a90e2;
- cardsTab.tint = 0x8b5cf6;
+var gameContainer = document.getElementById("game-container");
+var clicker = document.getElementById("clicker");
+var scoreDisplay = document.getElementById("score");
+var coinDisplay = document.getElementById("coin-display");
+var upgradeButton = document.getElementById("upgrade-button");
+var upgradeCostDisplay = document.getElementById("upgrade-cost");
+var cardSlotsContainer = document.getElementById("card-slots");
+var buySlotButton = document.getElementById("buy-slot-button");
+// Modal for card selection
+var cardModal = document.createElement("div");
+cardModal.style.display = "none";
+cardModal.style.position = "fixed";
+cardModal.style.top = "50%";
+cardModal.style.left = "50%";
+cardModal.style.transform = "translate(-50%, -50%)";
+cardModal.style.backgroundColor = "white";
+cardModal.style.border = "1px solid black";
+cardModal.style.padding = "20px";
+cardModal.style.zIndex = "1000";
+cardModal.innerHTML = "<h3>Select a Card</h3><div id=\"card-list\"></div><button id=\"cancel-select\">Cancel</button>";
+document.body.appendChild(cardModal);
+document.getElementById("cancel-select").onclick = function () {
+ cardModal.style.display = "none";
+};
+var gameState = {
+ score: 0,
+ coins: 0,
+ upgradeLevel: 1,
+ upgradeCost: 50,
+ clickValue: 1,
+ ownedCards: [{
+ name: "Fire Boost",
+ effect: "+2 per click"
+ }, {
+ name: "Golden Touch",
+ effect: "+10% coins"
+ }, {
+ name: "Double Strike",
+ effect: "x2 click every 5s"
+ }],
+ equippedCards: [],
+ cardSlots: 1
+};
+function loadGame() {
+ var savedState = localStorage.getItem("clickerGame");
+ if (savedState) {
+ gameState = JSON.parse(savedState);
}
+ updateDisplay();
+ renderCardSlots();
}
-// Function to update card slots display
-function updateCardSlots() {
- // Clear existing slot UI
- cardSlotsContainer.removeChildren();
- cardSlotButtons = [];
- cardSlotTexts = [];
- // Create card slots
- for (var i = 0; i < cardSlots; i++) {
- var slotButton = cardSlotsContainer.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 600,
- height: 240
- }));
- slotButton.x = 2048 / 2 - 700 + i % 3 * 700;
- slotButton.y = 1000 + Math.floor(i / 3) * 500;
- var equippedCard = equippedCards[i];
- var slotText = new Text2(equippedCard ? equippedCard.name : 'Empty Slot', {
- size: 50,
- fill: 0xffffff
- });
- slotText.anchor.set(0.5, 0.5);
- slotText.x = slotButton.x;
- slotText.y = slotButton.y;
- cardSlotsContainer.addChild(slotText);
- cardSlotButtons.push(slotButton);
- cardSlotTexts.push(slotText);
- }
- // Add buy slot button if less than 6 slots
- if (cardSlots < 6) {
- var buySlotButton = cardSlotsContainer.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 500,
- height: 160
- }));
- buySlotButton.x = 2048 / 2;
- buySlotButton.y = 1400;
- var buySlotText = new Text2('Buy Slot (50 coins)', {
- size: 60,
- fill: 0xffffff
- });
- buySlotText.anchor.set(0.5, 0.5);
- buySlotText.x = buySlotButton.x;
- buySlotText.y = buySlotButton.y;
- cardSlotsContainer.addChild(buySlotText);
- buySlotButton.down = function () {
- if (coins >= 50) {
- coins -= 50;
- cardSlots++;
- storage.coins = coins;
- storage.cardSlots = cardSlots;
- coinsText.setText('Coins: ' + coins);
- updateCardSlots();
- }
+function saveGame() {
+ localStorage.setItem("clickerGame", JSON.stringify(gameState));
+}
+function updateDisplay() {
+ scoreDisplay.textContent = "Score: ".concat(gameState.score);
+ coinDisplay.textContent = "Coins: ".concat(gameState.coins);
+ upgradeCostDisplay.textContent = "Upgrade Cost: ".concat(gameState.upgradeCost);
+}
+function renderCardSlots() {
+ cardSlotsContainer.innerHTML = "";
+ for (var i = 0; i < gameState.cardSlots; i++) {
+ var slot = document.createElement("div");
+ slot.className = "card-slot";
+ slot.dataset.index = i;
+ slot.style.border = "1px solid gray";
+ slot.style.padding = "10px";
+ slot.style.margin = "5px";
+ slot.style.cursor = "pointer";
+ slot.style.backgroundColor = "#f0f0f0";
+ var equipped = gameState.equippedCards[i];
+ slot.textContent = equipped ? equipped.name : "Empty Slot";
+ slot.onclick = function () {
+ return openCardSelector(i);
};
+ cardSlotsContainer.appendChild(slot);
}
}
-// Function to update store display
-function updateStoreDisplay() {
- // Clear existing store UI
- storeContainer.removeChildren();
- // Add back button
- var backButton = storeContainer.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 300,
- height: 120
- }));
- backButton.x = 150;
- backButton.y = 350;
- var backText = new Text2('BACK', {
- size: 50,
- fill: 0xffffff
- });
- backText.anchor.set(0.5, 0.5);
- backText.x = backButton.x;
- backText.y = backButton.y;
- storeContainer.addChild(backText);
- backButton.down = function () {
- currentTab = 'cards';
- storage.currentTab = currentTab;
- updateTabDisplay();
- };
- for (var i = 0; i < storeCards.length; i++) {
- var card = storeCards[i];
- var cardButton = storeContainer.addChild(LK.getAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 800,
- height: 200
- }));
- cardButton.x = 2048 / 2;
- cardButton.y = 800 + i * 240;
- var cardText = new Text2(card.name + ' - ' + card.price + ' coins', {
- size: 60,
- fill: 0xffffff
+function openCardSelector(slotIndex) {
+ var cardList = document.getElementById("card-list");
+ cardList.innerHTML = "";
+ gameState.ownedCards.forEach(function (card) {
+ var isEquipped = gameState.equippedCards.some(function (c) {
+ return (c === null || c === void 0 ? void 0 : c.name) === card.name;
});
- cardText.anchor.set(0.5, 0.4);
- cardText.x = cardButton.x;
- cardText.y = cardButton.y - 30;
- storeContainer.addChild(cardText);
- var descText = new Text2(card.description, {
- size: 40,
- fill: 0xbd93f9
- });
- descText.anchor.set(0.5, 0.6);
- descText.x = cardButton.x;
- descText.y = cardButton.y + 30;
- storeContainer.addChild(descText);
- cardButton.cardData = card;
- cardButton.down = function () {
- if (coins >= this.cardData.price) {
- coins -= this.cardData.price;
- ownedCards.push(this.cardData);
- try {
- if (storage) {
- storage.coins = coins;
- storage.ownedCards = ownedCards;
- }
- } catch (e) {
- console.log('Storage error:', e);
- }
- coinsText.setText('Coins: ' + coins);
- // Visual feedback
- tween(this, {
- tint: 0x00ff00
- }, {
- duration: 200
- });
- LK.setTimeout(function () {
- tween(this, {
- tint: 0xffffff
- }, {
- duration: 200
- });
- }.bind(this), 200);
- }
+ var cardBtn = document.createElement("button");
+ cardBtn.textContent = "".concat(card.name, " (").concat(card.effect, ")");
+ cardBtn.disabled = isEquipped;
+ cardBtn.style.margin = "5px";
+ cardBtn.onclick = function () {
+ gameState.equippedCards[slotIndex] = card;
+ cardModal.style.display = "none";
+ renderCardSlots();
+ saveGame();
};
- }
-}
-// Tab click handlers
-infinityTab.down = function () {
- currentTab = 'infinity';
- storage.currentTab = currentTab;
- updateTabDisplay();
-};
-cardsTab.down = function () {
- currentTab = 'cards';
- storage.currentTab = currentTab;
- updateTabDisplay();
-};
-// Cards menu click handlers
-storeMenuButton.down = function () {
- currentTab = 'store';
- storage.currentTab = currentTab;
- updateTabDisplay();
-};
-// Auto clicker functionality from cards
-var autoClickerTimer = null;
-function checkCardEffects() {
- // Check for auto clicker card
- var hasAutoClicker = false;
- for (var i = 0; i < equippedCards.length; i++) {
- if (equippedCards[i] && equippedCards[i].name === 'Auto Clicker') {
- hasAutoClicker = true;
- break;
- }
- }
- if (hasAutoClicker && !autoClickerTimer && currentTab === 'infinity') {
- autoClickerTimer = LK.setInterval(function () {
- processClick(1);
- }, 1000);
- } else if (!hasAutoClicker && autoClickerTimer) {
- LK.clearInterval(autoClickerTimer);
- autoClickerTimer = null;
- }
-}
-// Function to process clicks with card effects
-function processClick(baseClicks) {
- var finalClicks = baseClicks;
- var coinsEarned = 0; // Start with 0 coins, earn based on chance
- var isCritical = false;
- var isLucky = false;
- var coinDropChance = 0.3; // 30% chance to get coins on click
- var bonusCoinsChance = 0.1; // 10% chance for bonus coins
- // Check for coin drops
- if (Math.random() < coinDropChance) {
- coinsEarned = 1;
- // Check for bonus coins
- if (Math.random() < bonusCoinsChance) {
- coinsEarned = 3; // Bonus coin drop
- }
- // Create visual coin drop effect
- createCoinDrop(button.x, button.y, coinsEarned);
- }
- // Check equipped cards for effects
- for (var i = 0; i < equippedCards.length; i++) {
- var card = equippedCards[i];
- if (!card) continue;
- if (card.name === 'Critical Hit' && Math.random() < 0.15) {
- finalClicks *= 2;
- isCritical = true;
- }
- if (card.name === 'Double Coins' && coinsEarned > 0) {
- coinsEarned *= 2;
- }
- if (card.name === 'Lucky Strike' && Math.random() < 0.10) {
- finalClicks *= 5;
- isLucky = true;
- }
- }
- clickCount += finalClicks;
- // Don't add coins here - let the animation handle it
- storage.clickCount = clickCount;
- counterText.setText('Clicks: ' + clickCount);
- // Don't update coins text here - let the animation handle it
- // Visual feedback for special effects
- if (isCritical || isLucky) {
- var effectText = isCritical ? 'CRITICAL!' : 'LUCKY STRIKE!';
- LK.effects.flashScreen(isCritical ? 0xff5555 : 0x50fa7b, 300);
- buttonText.setText(effectText);
- }
- // Check for jumpscare at every hundred
- if (clickCount % 100 === 0) {
- triggerJumpscare();
- }
-}
-// Function to create visual coin drop effect
-function createCoinDrop(startX, startY, coinValue) {
- // Create coin visual - start from bottom of screen
- var coinDrop = game.addChild(LK.getAsset('coin', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 80,
- height: 80
- }));
- coinDrop.x = startX + (Math.random() * 100 - 50); // Random spread around button
- coinDrop.y = 2732; // Start from bottom of screen
- coinDrop.tint = 0xff79c6; // Coral pink color
- // Create coin text
- var coinText = new Text2('+' + coinValue, {
- size: 60,
- fill: 0xff79c6
+ cardList.appendChild(cardBtn);
});
- coinText.anchor.set(0.5, 0.5);
- coinText.x = coinDrop.x;
- coinText.y = coinDrop.y - 20;
- game.addChild(coinText);
- // Animate coin jumping up to coin counter with bounce effect
- tween(coinDrop, {
- x: coinsText.x,
- y: coinsText.y
- }, {
- duration: 800,
- easing: tween.bounceOut,
- onFinish: function onFinish() {
- // Update coin counter when coin reaches destination
- coins += coinValue;
- storage.coins = coins;
- coinsText.setText('Coins: ' + coins);
- // Flash the coin counter to show update
- tween(coinsText, {
- scaleX: 1.2,
- scaleY: 1.2
- }, {
- duration: 100,
- easing: tween.easeOut,
- onFinish: function onFinish() {
- tween(coinsText, {
- scaleX: 1.0,
- scaleY: 1.0
- }, {
- duration: 100,
- easing: tween.easeOut
- });
- }
- });
- }
- });
- tween(coinText, {
- x: coinsText.x,
- y: coinsText.y - 50
- }, {
- duration: 800,
- easing: tween.bounceOut
- });
- // Remove coin after animation
- LK.setTimeout(function () {
- if (coinDrop.parent) {
- coinDrop.destroy();
- }
- if (coinText.parent) {
- coinText.destroy();
- }
- }, 1000);
+ cardModal.style.display = "block";
}
-// Function to trigger jumpscare
-function triggerJumpscare() {
- // Array of scary messages
- var scaryMessages = ['BOO!', 'GOTCHA!', 'SURPRISE!', 'SCARED YET?', 'JUMP!', 'AAAHHH!', 'SPOOKY!', 'FEAR ME!'];
- var randomMessage = scaryMessages[Math.floor(Math.random() * scaryMessages.length)];
- // Random jumpscare type (0-3)
- var jumpscareType = Math.floor(Math.random() * 4);
- if (jumpscareType === 0) {
- // Type 1: Pink flash with dramatic scale and shake
- LK.effects.flashScreen(0xff5555, 500);
- tween(button, {
- scaleX: 3,
- scaleY: 3
- }, {
- duration: 200,
- easing: tween.bounceOut
- });
- tween(button, {
- x: button.x + Math.random() * 40 - 20,
- y: button.y + Math.random() * 40 - 20
- }, {
- duration: 50
- });
- } else if (jumpscareType === 1) {
- // Type 2: Purple flash with spin and grow
- LK.effects.flashScreen(0x8b5cf6, 700);
- tween(button, {
- scaleX: 2.5,
- scaleY: 2.5,
- rotation: Math.PI * 2
- }, {
- duration: 400,
- easing: tween.elasticOut
- });
- } else if (jumpscareType === 2) {
- // Type 3: Orange flash with rapid shake
- LK.effects.flashScreen(0xffb86c, 600);
- var shakeCount = 0;
- var shakeInterval = LK.setInterval(function () {
- button.x = 2048 / 2 + Math.random() * 60 - 30;
- button.y = 2732 / 2 - 100 + Math.random() * 60 - 30;
- shakeCount++;
- if (shakeCount >= 10) {
- LK.clearInterval(shakeInterval);
- }
- }, 30);
+clicker.addEventListener("click", function () {
+ gameState.score += gameState.clickValue;
+ gameState.coins += gameState.clickValue;
+ updateDisplay();
+ saveGame();
+});
+upgradeButton.addEventListener("click", function () {
+ if (gameState.coins >= gameState.upgradeCost) {
+ gameState.coins -= gameState.upgradeCost;
+ gameState.upgradeLevel += 1;
+ gameState.clickValue += 1;
+ gameState.upgradeCost = Math.floor(gameState.upgradeCost * 1.5);
+ updateDisplay();
+ saveGame();
+ }
+});
+buySlotButton.addEventListener("click", function () {
+ var cost = 100 * (gameState.cardSlots + 1);
+ if (gameState.coins >= cost) {
+ gameState.coins -= cost;
+ gameState.cardSlots += 1;
+ gameState.equippedCards.push(null);
+ updateDisplay();
+ renderCardSlots();
+ saveGame();
} else {
- // Type 4: Green flash with wild scaling
- LK.effects.flashScreen(0x50fa7b, 400);
- tween(button, {
- scaleX: 4,
- scaleY: 0.5
- }, {
- duration: 150,
- easing: tween.easeIn
- });
- LK.setTimeout(function () {
- tween(button, {
- scaleX: 0.5,
- scaleY: 4
- }, {
- duration: 150,
- easing: tween.easeOut
- });
- }, 150);
+ alert("Not enough coins to buy a new card slot!");
}
- // Scale back down after a moment
- LK.setTimeout(function () {
- tween(button, {
- scaleX: 1,
- scaleY: 1,
- rotation: 0,
- x: 2048 / 2,
- y: 2732 / 2 - 100
- }, {
- duration: 300,
- easing: tween.easeOut
- });
- tween(buttonShadow, {
- scaleX: 1,
- scaleY: 1,
- rotation: 0,
- x: 2048 / 2 + 8,
- y: 2732 / 2 - 100 + 8
- }, {
- duration: 300,
- easing: tween.easeOut
- });
- }, 300);
- // Change button text to random scary message
- buttonText.setText(randomMessage + ' ' + clickCount + ' CLICKS!');
-}
-// Handle button clicks
-button.down = function (x, y, obj) {
- if (currentTab === 'infinity') {
- processClick(1);
- if (clickCount % 100 !== 0) {
- // Change button text to random message
- buttonText.setText(buttonTexts[Math.floor(Math.random() * buttonTexts.length)]);
- }
- // Play click sound
- LK.getSound('click').play();
- }
- // Visual feedback - scale button down slightly and move shadow
- button.scaleX = 0.95;
- button.scaleY = 0.95;
- buttonShadow.scaleX = 0.95;
- buttonShadow.scaleY = 0.95;
- buttonShadow.x = 2048 / 2 + 4;
- buttonShadow.y = 2732 / 2 - 100 + 4;
-};
-button.up = function (x, y, obj) {
- // Return button to normal size and shadow position
- button.scaleX = 1.0;
- button.scaleY = 1.0;
- buttonShadow.scaleX = 1.0;
- buttonShadow.scaleY = 1.0;
- buttonShadow.x = 2048 / 2 + 8;
- buttonShadow.y = 2732 / 2 - 100 + 8;
-};
-// Game update loop
-game.update = function () {
- checkCardEffects();
-};
-// Initialize the display
-updateTabDisplay();
-// Start background music
-LK.playMusic('background');
-;
\ No newline at end of file
+});
+loadGame();
\ No newline at end of file