/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { score: 0, tapValue: 1, upgradeLevel: 1, upgradeCost: 10, hasAutoClicker: false }); /**** * Classes ****/ var AutoClickerButton = Container.expand(function () { var self = Container.call(this); var buttonGraphic = self.attachAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5, tint: 0xff9500 }); self.text = new Text2('Auto Clicker: 1000', { size: 60, fill: 0xFFFFFF }); self.text.anchor.set(0.5, 0.5); self.addChild(self.text); self.active = false; self.timer = null; self.clickInterval = 1000; // Default interval (1 second) self.level = 1; // Auto clicker level self.updateText = function (cost) { if (self.active) { if (self.level === 1) { self.text.setText('Auto Clicker: Active'); } else { self.text.setText('Auto Clicker Lvl ' + self.level + ': ' + (self.level < 6 ? getAutoClickerUpgradeCost() : 'MAX')); } } else { self.text.setText('Auto Clicker: ' + cost); } }; self.down = function () { tween(buttonGraphic, { scaleX: 0.95, scaleY: 0.95 }, { duration: 100, easing: tween.easeOut }); }; self.up = function () { tween(buttonGraphic, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.easeOut }); if (self.active) { attemptUpgradeAutoClicker(); } else { attemptBuyAutoClicker(); } }; self.disable = function () { buttonGraphic.alpha = 0.5; }; self.enable = function () { buttonGraphic.alpha = 1; }; self.restartTimer = function () { // Clear existing timer if it exists if (self.timer) { LK.clearInterval(self.timer); self.timer = null; } // Start auto clicking with new interval self.timer = LK.setInterval(function () { // Simulate a tap at a random position var randomX = Math.random() * 2048; var randomY = Math.random() * 2732; // Add points score += tapValue; storage.score = score; updateScoreDisplay(); // Create effects var shockWave = new ShockWave(); game.addChild(shockWave); shockWave.animate(randomX, randomY); createTapEffect(randomX, randomY); LK.getSound('tap').play(); }, self.clickInterval); }; self.activate = function () { self.active = true; buttonGraphic.tint = 0x00c853; self.updateText(); // Start auto clicking if (!self.timer) { self.restartTimer(); } }; self.upgrade = function () { self.level++; // Update click interval based on level switch (self.level) { case 2: self.clickInterval = 900; // 0.9 seconds break; case 3: self.clickInterval = 800; // 0.8 seconds break; case 4: self.clickInterval = 700; // 0.7 seconds break; case 5: self.clickInterval = 500; // 0.5 seconds break; case 6: self.clickInterval = 400; // 0.4 seconds break; } // Update button text self.updateText(); // Restart timer with new interval self.restartTimer(); }; return self; }); var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphic = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); // Pulse animation when active self.pulse = function () { // Stop any existing animation tween.stop(coinGraphic, { scaleX: true, scaleY: true }); // Scale up tween(coinGraphic, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { // Scale back down tween(coinGraphic, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.elasticOut }); } }); }; return self; }); var ShockWave = Container.expand(function () { var self = Container.call(this); // Create the shock wave circle var waveGraphic = self.attachAsset('tapEffect', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); // Animation method for the shock wave self.animate = function (x, y) { // Set position self.x = x; self.y = y; // Start with small scale and high opacity waveGraphic.scaleX = 0.1; waveGraphic.scaleY = 0.1; waveGraphic.alpha = 0.8; // First expand the wave quickly tween(waveGraphic, { scaleX: 3, scaleY: 3, alpha: 0.6 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { // Then continue expanding and fade out tween(waveGraphic, { scaleX: 8, scaleY: 8, alpha: 0 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { // Remove when done if (self.parent) { self.parent.removeChild(self); } } }); } }); }; return self; }); var TapEffect = Container.expand(function () { var self = Container.call(this); var effectGraphic = self.attachAsset('tapEffect', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); self.animate = function (x, y, pointsEarned) { self.x = x; self.y = y; self.alpha = 1; effectGraphic.scaleX = 0.5; effectGraphic.scaleY = 0.5; // Create points text var pointsText = new Text2("+" + pointsEarned, { size: 60, fill: 0xFFFFFF }); pointsText.anchor.set(0.5, 0.5); self.addChild(pointsText); // Animate effect tween(effectGraphic, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 500, easing: tween.easeOut }); // Animate text floating up tween(pointsText, { y: -100, alpha: 0 }, { duration: 800, easing: tween.easeOut, onFinish: function onFinish() { self.removeChild(pointsText); pointsText = null; } }); }; return self; }); var UpgradeButton = Container.expand(function () { var self = Container.call(this); var buttonGraphic = self.attachAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5 }); self.text = new Text2('Upgrade: 10 points', { size: 60, fill: 0xFFFFFF }); self.text.anchor.set(0.5, 0.5); self.addChild(self.text); self.updateText = function (cost) { self.text.setText('Upgrade: ' + cost + ' points'); }; self.down = function () { tween(buttonGraphic, { scaleX: 0.95, scaleY: 0.95 }, { duration: 100, easing: tween.easeOut }); }; self.up = function () { tween(buttonGraphic, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.easeOut }); attemptUpgrade(); }; self.disable = function () { buttonGraphic.alpha = 0.5; }; self.enable = function () { buttonGraphic.alpha = 1; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Game variables var score = storage.score || 0; var tapValue = storage.tapValue || 1; var upgradeLevel = storage.upgradeLevel || 1; var upgradeCost = storage.upgradeCost || 10; var hasAutoClicker = storage.hasAutoClicker || false; var autoClickerLevel = storage.autoClickerLevel || 1; var autoClickerCost = 1000; var effects = []; // Function to get auto clicker upgrade cost based on level function getAutoClickerUpgradeCost() { switch (autoClickerLevel) { case 1: return 1000; // First upgrade costs 1000 case 2: return 2000; // Second upgrade costs 2000 case 3: return 5000; // Third upgrade costs 5000 case 4: return 10000; // Fourth upgrade costs 10000 case 5: return 50000; // Fifth upgrade costs 50000 case 6: return 125000; // Sixth upgrade costs 125000 default: return Infinity; // No more upgrades } } // Create upgrade button in top left (but not too close to the corner) var upgradeButton = new UpgradeButton(); upgradeButton.x = 400; upgradeButton.y = 150; upgradeButton.updateText(upgradeCost); game.addChild(upgradeButton); // Create auto clicker button below the upgrade button var autoClickerButton = new AutoClickerButton(); autoClickerButton.x = 400; autoClickerButton.y = 320; autoClickerButton.updateText(autoClickerCost); game.addChild(autoClickerButton); // If player already has auto clicker, activate it if (hasAutoClicker) { // Set the correct level and interval autoClickerButton.level = autoClickerLevel; // Set the correct interval based on level switch (autoClickerLevel) { case 2: autoClickerButton.clickInterval = 900; // 0.9 seconds break; case 3: autoClickerButton.clickInterval = 800; // 0.8 seconds break; case 4: autoClickerButton.clickInterval = 700; // 0.7 seconds break; case 5: autoClickerButton.clickInterval = 500; // 0.5 seconds break; case 6: autoClickerButton.clickInterval = 400; // 0.4 seconds break; default: autoClickerButton.clickInterval = 1000; // 1 second (default) } autoClickerButton.activate(); } // Function to check if auto clicker should be visible function updateAutoClickerVisibility() { if (score >= 1000 || hasAutoClicker) { autoClickerButton.visible = true; } else { autoClickerButton.visible = false; } } // Create score display var scoreText = new Text2('Points: 0', { size: 100, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); // Create tap value display var tapValueText = new Text2('Points per tap: 1', { size: 60, fill: 0xFFFFFF }); tapValueText.anchor.set(0.5, 0); tapValueText.y = 120; LK.gui.top.addChild(tapValueText); // Format large numbers with K, M, B, T suffixes function formatScore(num) { if (num >= 1000000000000) { // Trillion var t = num / 1000000000000; return (Math.floor(t * 10) / 10).toFixed(1).replace(/\.0$/, '') + 'T'; } else if (num >= 1000000000) { // Billion var b = num / 1000000000; return (Math.floor(b * 10) / 10).toFixed(1).replace(/\.0$/, '') + 'B'; } else if (num >= 1000000) { // Million var m = num / 1000000; return (Math.floor(m * 10) / 10).toFixed(1).replace(/\.0$/, '') + 'M'; } else if (num >= 1000) { // Thousand var k = num / 1000; return (Math.floor(k * 10) / 10).toFixed(1).replace(/\.0$/, '') + 'K'; } else { return num.toString(); } } // Update score display function updateScoreDisplay() { scoreText.setText('Points: ' + formatScore(score)); tapValueText.setText('Points per tap: ' + tapValue); // Check if player can afford upgrade if (score >= upgradeCost) { upgradeButton.enable(); } else { upgradeButton.disable(); } // Check if auto clicker should be visible updateAutoClickerVisibility(); // Enable/disable auto clicker button based on score if (!hasAutoClicker) { if (score >= autoClickerCost) { autoClickerButton.enable(); } else { autoClickerButton.disable(); } } else if (autoClickerLevel < 6) { // If has auto clicker but not max level, check if can afford upgrade var nextUpgradeCost = getAutoClickerUpgradeCost(); if (score >= nextUpgradeCost) { autoClickerButton.enable(); } else { autoClickerButton.disable(); } } } // Attempt to purchase an upgrade function attemptUpgrade() { if (score >= upgradeCost) { // Deduct points score -= upgradeCost; // Increase tap value upgradeLevel++; tapValue = upgradeLevel; // Calculate new upgrade cost (increase by 50%) upgradeCost = Math.floor(upgradeCost * 1.5); // Update button text upgradeButton.updateText(upgradeCost); // Save progress storage.score = score; storage.tapValue = tapValue; storage.upgradeLevel = upgradeLevel; storage.upgradeCost = upgradeCost; // Update display updateScoreDisplay(); // Play upgrade sound LK.getSound('upgrade').play(); } } // Attempt to purchase auto clicker function attemptBuyAutoClicker() { if (!hasAutoClicker && score >= autoClickerCost) { // Deduct points score -= autoClickerCost; // Activate auto clicker hasAutoClicker = true; storage.hasAutoClicker = true; storage.autoClickerLevel = 1; storage.score = score; // Update display updateScoreDisplay(); // Activate auto clicker functionality autoClickerButton.activate(); // Play upgrade sound LK.getSound('upgrade').play(); } } // Attempt to upgrade auto clicker function attemptUpgradeAutoClicker() { // Don't proceed if already at max level if (autoClickerLevel >= 6) return; // Get the cost for the current level upgrade var upgradeCost = getAutoClickerUpgradeCost(); // Check if player can afford the upgrade if (score >= upgradeCost) { // Deduct points score -= upgradeCost; // Upgrade auto clicker autoClickerLevel++; // Save progress storage.score = score; storage.autoClickerLevel = autoClickerLevel; // Update auto clicker autoClickerButton.upgrade(); // Update display updateScoreDisplay(); // Play upgrade sound LK.getSound('upgrade').play(); } } // Create tap effect function createTapEffect(x, y) { var effect = new TapEffect(); game.addChild(effect); effect.animate(x, y, tapValue); // Remove effect after animation LK.setTimeout(function () { if (effect.parent) { game.removeChild(effect); } }, 1000); } // Handle tapping on the game game.down = function (x, y) { // Add points score += tapValue; // Save progress storage.score = score; // Update display updateScoreDisplay(); // Create shock wave effect var shockWave = new ShockWave(); game.addChild(shockWave); shockWave.animate(x, y); // Create visual effect for points createTapEffect(x, y); // Play tap sound LK.getSound('tap').play(); }; // Initial setup updateScoreDisplay(); // Play background music LK.playMusic('bgmusic', { fade: { start: 0, end: 0.3, duration: 1000 } });
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
score: 0,
tapValue: 1,
upgradeLevel: 1,
upgradeCost: 10,
hasAutoClicker: false
});
/****
* Classes
****/
var AutoClickerButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphic = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xff9500
});
self.text = new Text2('Auto Clicker: 1000', {
size: 60,
fill: 0xFFFFFF
});
self.text.anchor.set(0.5, 0.5);
self.addChild(self.text);
self.active = false;
self.timer = null;
self.clickInterval = 1000; // Default interval (1 second)
self.level = 1; // Auto clicker level
self.updateText = function (cost) {
if (self.active) {
if (self.level === 1) {
self.text.setText('Auto Clicker: Active');
} else {
self.text.setText('Auto Clicker Lvl ' + self.level + ': ' + (self.level < 6 ? getAutoClickerUpgradeCost() : 'MAX'));
}
} else {
self.text.setText('Auto Clicker: ' + cost);
}
};
self.down = function () {
tween(buttonGraphic, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100,
easing: tween.easeOut
});
};
self.up = function () {
tween(buttonGraphic, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeOut
});
if (self.active) {
attemptUpgradeAutoClicker();
} else {
attemptBuyAutoClicker();
}
};
self.disable = function () {
buttonGraphic.alpha = 0.5;
};
self.enable = function () {
buttonGraphic.alpha = 1;
};
self.restartTimer = function () {
// Clear existing timer if it exists
if (self.timer) {
LK.clearInterval(self.timer);
self.timer = null;
}
// Start auto clicking with new interval
self.timer = LK.setInterval(function () {
// Simulate a tap at a random position
var randomX = Math.random() * 2048;
var randomY = Math.random() * 2732;
// Add points
score += tapValue;
storage.score = score;
updateScoreDisplay();
// Create effects
var shockWave = new ShockWave();
game.addChild(shockWave);
shockWave.animate(randomX, randomY);
createTapEffect(randomX, randomY);
LK.getSound('tap').play();
}, self.clickInterval);
};
self.activate = function () {
self.active = true;
buttonGraphic.tint = 0x00c853;
self.updateText();
// Start auto clicking
if (!self.timer) {
self.restartTimer();
}
};
self.upgrade = function () {
self.level++;
// Update click interval based on level
switch (self.level) {
case 2:
self.clickInterval = 900; // 0.9 seconds
break;
case 3:
self.clickInterval = 800; // 0.8 seconds
break;
case 4:
self.clickInterval = 700; // 0.7 seconds
break;
case 5:
self.clickInterval = 500; // 0.5 seconds
break;
case 6:
self.clickInterval = 400; // 0.4 seconds
break;
}
// Update button text
self.updateText();
// Restart timer with new interval
self.restartTimer();
};
return self;
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphic = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
// Pulse animation when active
self.pulse = function () {
// Stop any existing animation
tween.stop(coinGraphic, {
scaleX: true,
scaleY: true
});
// Scale up
tween(coinGraphic, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
// Scale back down
tween(coinGraphic, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.elasticOut
});
}
});
};
return self;
});
var ShockWave = Container.expand(function () {
var self = Container.call(this);
// Create the shock wave circle
var waveGraphic = self.attachAsset('tapEffect', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.7
});
// Animation method for the shock wave
self.animate = function (x, y) {
// Set position
self.x = x;
self.y = y;
// Start with small scale and high opacity
waveGraphic.scaleX = 0.1;
waveGraphic.scaleY = 0.1;
waveGraphic.alpha = 0.8;
// First expand the wave quickly
tween(waveGraphic, {
scaleX: 3,
scaleY: 3,
alpha: 0.6
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
// Then continue expanding and fade out
tween(waveGraphic, {
scaleX: 8,
scaleY: 8,
alpha: 0
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
// Remove when done
if (self.parent) {
self.parent.removeChild(self);
}
}
});
}
});
};
return self;
});
var TapEffect = Container.expand(function () {
var self = Container.call(this);
var effectGraphic = self.attachAsset('tapEffect', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.7
});
self.animate = function (x, y, pointsEarned) {
self.x = x;
self.y = y;
self.alpha = 1;
effectGraphic.scaleX = 0.5;
effectGraphic.scaleY = 0.5;
// Create points text
var pointsText = new Text2("+" + pointsEarned, {
size: 60,
fill: 0xFFFFFF
});
pointsText.anchor.set(0.5, 0.5);
self.addChild(pointsText);
// Animate effect
tween(effectGraphic, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 500,
easing: tween.easeOut
});
// Animate text floating up
tween(pointsText, {
y: -100,
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
self.removeChild(pointsText);
pointsText = null;
}
});
};
return self;
});
var UpgradeButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphic = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.text = new Text2('Upgrade: 10 points', {
size: 60,
fill: 0xFFFFFF
});
self.text.anchor.set(0.5, 0.5);
self.addChild(self.text);
self.updateText = function (cost) {
self.text.setText('Upgrade: ' + cost + ' points');
};
self.down = function () {
tween(buttonGraphic, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100,
easing: tween.easeOut
});
};
self.up = function () {
tween(buttonGraphic, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeOut
});
attemptUpgrade();
};
self.disable = function () {
buttonGraphic.alpha = 0.5;
};
self.enable = function () {
buttonGraphic.alpha = 1;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game variables
var score = storage.score || 0;
var tapValue = storage.tapValue || 1;
var upgradeLevel = storage.upgradeLevel || 1;
var upgradeCost = storage.upgradeCost || 10;
var hasAutoClicker = storage.hasAutoClicker || false;
var autoClickerLevel = storage.autoClickerLevel || 1;
var autoClickerCost = 1000;
var effects = [];
// Function to get auto clicker upgrade cost based on level
function getAutoClickerUpgradeCost() {
switch (autoClickerLevel) {
case 1:
return 1000;
// First upgrade costs 1000
case 2:
return 2000;
// Second upgrade costs 2000
case 3:
return 5000;
// Third upgrade costs 5000
case 4:
return 10000;
// Fourth upgrade costs 10000
case 5:
return 50000;
// Fifth upgrade costs 50000
case 6:
return 125000;
// Sixth upgrade costs 125000
default:
return Infinity;
// No more upgrades
}
}
// Create upgrade button in top left (but not too close to the corner)
var upgradeButton = new UpgradeButton();
upgradeButton.x = 400;
upgradeButton.y = 150;
upgradeButton.updateText(upgradeCost);
game.addChild(upgradeButton);
// Create auto clicker button below the upgrade button
var autoClickerButton = new AutoClickerButton();
autoClickerButton.x = 400;
autoClickerButton.y = 320;
autoClickerButton.updateText(autoClickerCost);
game.addChild(autoClickerButton);
// If player already has auto clicker, activate it
if (hasAutoClicker) {
// Set the correct level and interval
autoClickerButton.level = autoClickerLevel;
// Set the correct interval based on level
switch (autoClickerLevel) {
case 2:
autoClickerButton.clickInterval = 900; // 0.9 seconds
break;
case 3:
autoClickerButton.clickInterval = 800; // 0.8 seconds
break;
case 4:
autoClickerButton.clickInterval = 700; // 0.7 seconds
break;
case 5:
autoClickerButton.clickInterval = 500; // 0.5 seconds
break;
case 6:
autoClickerButton.clickInterval = 400; // 0.4 seconds
break;
default:
autoClickerButton.clickInterval = 1000;
// 1 second (default)
}
autoClickerButton.activate();
}
// Function to check if auto clicker should be visible
function updateAutoClickerVisibility() {
if (score >= 1000 || hasAutoClicker) {
autoClickerButton.visible = true;
} else {
autoClickerButton.visible = false;
}
}
// Create score display
var scoreText = new Text2('Points: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Create tap value display
var tapValueText = new Text2('Points per tap: 1', {
size: 60,
fill: 0xFFFFFF
});
tapValueText.anchor.set(0.5, 0);
tapValueText.y = 120;
LK.gui.top.addChild(tapValueText);
// Format large numbers with K, M, B, T suffixes
function formatScore(num) {
if (num >= 1000000000000) {
// Trillion
var t = num / 1000000000000;
return (Math.floor(t * 10) / 10).toFixed(1).replace(/\.0$/, '') + 'T';
} else if (num >= 1000000000) {
// Billion
var b = num / 1000000000;
return (Math.floor(b * 10) / 10).toFixed(1).replace(/\.0$/, '') + 'B';
} else if (num >= 1000000) {
// Million
var m = num / 1000000;
return (Math.floor(m * 10) / 10).toFixed(1).replace(/\.0$/, '') + 'M';
} else if (num >= 1000) {
// Thousand
var k = num / 1000;
return (Math.floor(k * 10) / 10).toFixed(1).replace(/\.0$/, '') + 'K';
} else {
return num.toString();
}
}
// Update score display
function updateScoreDisplay() {
scoreText.setText('Points: ' + formatScore(score));
tapValueText.setText('Points per tap: ' + tapValue);
// Check if player can afford upgrade
if (score >= upgradeCost) {
upgradeButton.enable();
} else {
upgradeButton.disable();
}
// Check if auto clicker should be visible
updateAutoClickerVisibility();
// Enable/disable auto clicker button based on score
if (!hasAutoClicker) {
if (score >= autoClickerCost) {
autoClickerButton.enable();
} else {
autoClickerButton.disable();
}
} else if (autoClickerLevel < 6) {
// If has auto clicker but not max level, check if can afford upgrade
var nextUpgradeCost = getAutoClickerUpgradeCost();
if (score >= nextUpgradeCost) {
autoClickerButton.enable();
} else {
autoClickerButton.disable();
}
}
}
// Attempt to purchase an upgrade
function attemptUpgrade() {
if (score >= upgradeCost) {
// Deduct points
score -= upgradeCost;
// Increase tap value
upgradeLevel++;
tapValue = upgradeLevel;
// Calculate new upgrade cost (increase by 50%)
upgradeCost = Math.floor(upgradeCost * 1.5);
// Update button text
upgradeButton.updateText(upgradeCost);
// Save progress
storage.score = score;
storage.tapValue = tapValue;
storage.upgradeLevel = upgradeLevel;
storage.upgradeCost = upgradeCost;
// Update display
updateScoreDisplay();
// Play upgrade sound
LK.getSound('upgrade').play();
}
}
// Attempt to purchase auto clicker
function attemptBuyAutoClicker() {
if (!hasAutoClicker && score >= autoClickerCost) {
// Deduct points
score -= autoClickerCost;
// Activate auto clicker
hasAutoClicker = true;
storage.hasAutoClicker = true;
storage.autoClickerLevel = 1;
storage.score = score;
// Update display
updateScoreDisplay();
// Activate auto clicker functionality
autoClickerButton.activate();
// Play upgrade sound
LK.getSound('upgrade').play();
}
}
// Attempt to upgrade auto clicker
function attemptUpgradeAutoClicker() {
// Don't proceed if already at max level
if (autoClickerLevel >= 6) return;
// Get the cost for the current level upgrade
var upgradeCost = getAutoClickerUpgradeCost();
// Check if player can afford the upgrade
if (score >= upgradeCost) {
// Deduct points
score -= upgradeCost;
// Upgrade auto clicker
autoClickerLevel++;
// Save progress
storage.score = score;
storage.autoClickerLevel = autoClickerLevel;
// Update auto clicker
autoClickerButton.upgrade();
// Update display
updateScoreDisplay();
// Play upgrade sound
LK.getSound('upgrade').play();
}
}
// Create tap effect
function createTapEffect(x, y) {
var effect = new TapEffect();
game.addChild(effect);
effect.animate(x, y, tapValue);
// Remove effect after animation
LK.setTimeout(function () {
if (effect.parent) {
game.removeChild(effect);
}
}, 1000);
}
// Handle tapping on the game
game.down = function (x, y) {
// Add points
score += tapValue;
// Save progress
storage.score = score;
// Update display
updateScoreDisplay();
// Create shock wave effect
var shockWave = new ShockWave();
game.addChild(shockWave);
shockWave.animate(x, y);
// Create visual effect for points
createTapEffect(x, y);
// Play tap sound
LK.getSound('tap').play();
};
// Initial setup
updateScoreDisplay();
// Play background music
LK.playMusic('bgmusic', {
fade: {
start: 0,
end: 0.3,
duration: 1000
}
});