User prompt
Add a win item to the shop that costs 70k.
User prompt
Add an option in the shop for a thousand dollars
User prompt
Make a mute and unmute button for the music.
User prompt
Add music to the game.
User prompt
Make more items to buy in the shop.
Code edit (1 edits merged)
Please save this source code
User prompt
Ice Cream Empire
Initial prompt
I want to make a clicker game with cookie clicker, but with ice cream.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var FloatingText = Container.expand(function (text, x, y) {
var self = Container.call(this);
var textObj = new Text2('+' + formatNumber(text), {
size: 40,
fill: 0x00FF00
});
textObj.anchor.set(0.5, 0.5);
self.addChild(textObj);
self.x = x;
self.y = y;
// Animate floating up and fading out
tween(self, {
y: self.y - 100,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
if (self.parent) {
self.parent.removeChild(self);
}
}
});
return self;
});
var IceCreamDisplay = Container.expand(function () {
var self = Container.call(this);
// Create cone base
var cone = self.attachAsset('iceCreamCone', {
anchorX: 0.5,
anchorY: 1.0
});
// Create ice cream scoop
var scoop = self.attachAsset('iceCreamScoop', {
anchorX: 0.5,
anchorY: 1.0,
y: -20
});
self.animateScoop = function () {
// Scale animation on tap
tween(scoop, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
onFinish: function onFinish() {
tween(scoop, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
}
});
// Color flash
var originalTint = scoop.tint;
scoop.tint = 0xFFFFFF;
tween(scoop, {
tint: originalTint
}, {
duration: 200
});
};
self.down = function (x, y, obj) {
self.animateScoop();
earnIceCream(manualIcePerClick);
LK.getSound('scoop').play();
};
return self;
});
var UpgradeItem = Container.expand(function (config) {
var self = Container.call(this);
var button = self.attachAsset('upgradeButton', {
anchorX: 0,
anchorY: 0
});
var nameText = new Text2(config.name, {
size: 32,
fill: 0xFFFFFF
});
nameText.anchor.set(0, 0.5);
nameText.x = 10;
nameText.y = 25;
self.addChild(nameText);
var costText = new Text2('Cost: ' + formatNumber(config.cost), {
size: 24,
fill: 0xFFFFFF
});
costText.anchor.set(0, 0.5);
costText.x = 10;
costText.y = 55;
self.addChild(costText);
var countText = new Text2('Owned: ' + config.owned, {
size: 20,
fill: 0xFFFFFF
});
countText.anchor.set(1, 0.5);
countText.x = 290;
countText.y = 40;
self.addChild(countText);
self.config = config;
self.nameText = nameText;
self.costText = costText;
self.countText = countText;
self.updateDisplay = function () {
self.costText.setText('Cost: ' + formatNumber(self.config.cost));
self.countText.setText('Owned: ' + self.config.owned);
// Disable if can't afford
if (totalIceCream < self.config.cost) {
button.tint = 0x888888;
} else {
button.tint = 0xFFFFFF;
}
};
self.down = function (x, y, obj) {
if (totalIceCream >= self.config.cost) {
totalIceCream -= self.config.cost;
self.config.owned++;
self.config.cost = Math.floor(self.config.cost * 1.15);
// Update automation
if (self.config.type === 'autoScoop') {
autoIcePerSecond += self.config.production;
} else if (self.config.type === 'clickPower') {
manualIcePerClick += self.config.bonus;
}
self.updateDisplay();
updateAllDisplays();
LK.getSound('purchase').play();
// Achievement check
checkAchievements();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game state variables
var totalIceCream = storage.totalIceCream || 0;
var manualIcePerClick = storage.manualIcePerClick || 1;
var autoIcePerSecond = storage.autoIcePerSecond || 0;
var lifetimeIceCream = storage.lifetimeIceCream || 0;
var isMusicMuted = storage.isMusicMuted || false;
// Upgrade definitions
var upgrades = [{
name: 'Auto Scooper',
cost: storage.autoScoop_cost || 10,
owned: storage.autoScoop_owned || 0,
production: 1,
type: 'autoScoop'
}, {
name: 'Better Scoop',
cost: storage.clickPower_cost || 50,
owned: storage.clickPower_owned || 0,
bonus: 1,
type: 'clickPower'
}, {
name: 'Ice Cream Machine',
cost: storage.machine_cost || 200,
owned: storage.machine_owned || 0,
production: 5,
type: 'autoScoop'
}, {
name: 'Premium Flavors',
cost: storage.premium_cost || 500,
owned: storage.premium_owned || 0,
bonus: 5,
type: 'clickPower'
}, {
name: 'Ice Cream Truck',
cost: storage.truck_cost || 1000,
owned: storage.truck_owned || 0,
production: 15,
type: 'autoScoop'
}, {
name: 'Golden Spoon',
cost: storage.goldenspoon_cost || 2000,
owned: storage.goldenspoon_owned || 0,
bonus: 10,
type: 'clickPower'
}, {
name: 'Flavor Laboratory',
cost: storage.flavorlab_cost || 5000,
owned: storage.flavorlab_owned || 0,
production: 50,
type: 'autoScoop'
}, {
name: 'Marketing Campaign',
cost: storage.marketing_cost || 10000,
owned: storage.marketing_owned || 0,
bonus: 25,
type: 'clickPower'
}, {
name: 'Ice Cream Factory',
cost: storage.factory_cost || 25000,
owned: storage.factory_owned || 0,
production: 150,
type: 'autoScoop'
}, {
name: 'Mega Freezer',
cost: storage.megafreezer_cost || 50000,
owned: storage.megafreezer_owned || 0,
production: 300,
type: 'autoScoop'
}, {
name: 'Premium Shop',
cost: storage.premiumshop_cost || 1000,
owned: storage.premiumshop_owned || 0,
production: 10,
type: 'autoScoop'
}];
// Achievements
var achievements = [{
name: 'First Scoop',
requirement: 1,
unlocked: storage.ach_firstScoop || false
}, {
name: 'Ice Cream Lover',
requirement: 100,
unlocked: storage.ach_lover || false
}, {
name: 'Sweet Empire',
requirement: 1000,
unlocked: storage.ach_empire || false
}, {
name: 'Frozen Fortune',
requirement: 10000,
unlocked: storage.ach_fortune || false
}, {
name: 'Ice Cream Mogul',
requirement: 100000,
unlocked: storage.ach_mogul || false
}, {
name: 'Dessert Dynasty',
requirement: 1000000,
unlocked: storage.ach_dynasty || false
}];
// Create main ice cream display
var iceCreamDisplay = game.addChild(new IceCreamDisplay());
iceCreamDisplay.x = 1024;
iceCreamDisplay.y = 800;
// Create UI background
var shopBg = game.attachAsset('shopBackground', {
anchorX: 0,
anchorY: 0,
x: 50,
y: 1200
});
// Create currency display
var currencyText = new Text2('Ice Cream: ' + formatNumber(totalIceCream), {
size: 48,
fill: 0x2E7D32
});
currencyText.anchor.set(0.5, 0);
LK.gui.top.addChild(currencyText);
currencyText.y = 100;
// Create IPS display
var ipsText = new Text2('IPS: ' + formatNumber(autoIcePerSecond), {
size: 32,
fill: 0x1976D2
});
ipsText.anchor.set(0.5, 0);
LK.gui.top.addChild(ipsText);
ipsText.y = 160;
// Create upgrade items
var upgradeItems = [];
for (var i = 0; i < upgrades.length; i++) {
var upgradeItem = new UpgradeItem(upgrades[i]);
upgradeItem.x = 70;
upgradeItem.y = 1220 + i * 100;
game.addChild(upgradeItem);
upgradeItems.push(upgradeItem);
}
// Create achievement display
var achievementText = new Text2('Achievements: 0/' + achievements.length, {
size: 28,
fill: 0xFF6F00
});
achievementText.anchor.set(0.5, 0);
LK.gui.top.addChild(achievementText);
achievementText.y = 200;
// Create mute button
var muteButton = LK.getAsset('muteButton', {
anchorX: 0.5,
anchorY: 0.5
});
muteButton.x = 1950;
muteButton.y = 150;
game.addChild(muteButton);
// Create mute button text
var muteButtonText = new Text2(isMusicMuted ? 'UNMUTE' : 'MUTE', {
size: 20,
fill: 0xFFFFFF
});
muteButtonText.anchor.set(0.5, 0.5);
muteButtonText.x = muteButton.x;
muteButtonText.y = muteButton.y;
game.addChild(muteButtonText);
// Mute button functionality
muteButton.down = function (x, y, obj) {
isMusicMuted = !isMusicMuted;
if (isMusicMuted) {
LK.stopMusic();
muteButtonText.setText('UNMUTE');
} else {
LK.playMusic('background');
muteButtonText.setText('MUTE');
}
storage.isMusicMuted = isMusicMuted;
};
// Helper functions
function formatNumber(num) {
if (num >= 1000000) {
return (num / 1000000).toFixed(1) + 'M';
} else if (num >= 1000) {
return (num / 1000).toFixed(1) + 'K';
}
return Math.floor(num).toString();
}
function earnIceCream(amount) {
totalIceCream += amount;
lifetimeIceCream += amount;
// Create floating text
var floatingText = new FloatingText(amount, iceCreamDisplay.x, iceCreamDisplay.y - 50);
game.addChild(floatingText);
updateAllDisplays();
saveGame();
}
function updateAllDisplays() {
currencyText.setText('Ice Cream: ' + formatNumber(totalIceCream));
ipsText.setText('IPS: ' + formatNumber(autoIcePerSecond));
for (var i = 0; i < upgradeItems.length; i++) {
upgradeItems[i].updateDisplay();
}
}
function checkAchievements() {
var unlockedCount = 0;
for (var i = 0; i < achievements.length; i++) {
if (!achievements[i].unlocked && lifetimeIceCream >= achievements[i].requirement) {
achievements[i].unlocked = true;
LK.getSound('achievement').play();
// Show achievement notification
var achText = new Text2('Achievement: ' + achievements[i].name, {
size: 36,
fill: 0xFFD700
});
achText.anchor.set(0.5, 0.5);
achText.x = 1024;
achText.y = 400;
game.addChild(achText);
tween(achText, {
alpha: 0
}, {
duration: 3000,
onFinish: function onFinish() {
if (achText.parent) {
achText.parent.removeChild(achText);
}
}
});
}
if (achievements[i].unlocked) unlockedCount++;
}
achievementText.setText('Achievements: ' + unlockedCount + '/' + achievements.length);
}
function saveGame() {
storage.totalIceCream = totalIceCream;
storage.manualIcePerClick = manualIcePerClick;
storage.autoIcePerSecond = autoIcePerSecond;
storage.lifetimeIceCream = lifetimeIceCream;
// Save upgrade states
for (var i = 0; i < upgrades.length; i++) {
var upgrade = upgrades[i];
if (upgrade.type === 'autoScoop') {
storage[upgrade.name.replace(' ', '').toLowerCase() + '_cost'] = upgrade.cost;
storage[upgrade.name.replace(' ', '').toLowerCase() + '_owned'] = upgrade.owned;
} else {
storage[upgrade.name.replace(' ', '').toLowerCase() + '_cost'] = upgrade.cost;
storage[upgrade.name.replace(' ', '').toLowerCase() + '_owned'] = upgrade.owned;
}
}
// Save achievements
for (var i = 0; i < achievements.length; i++) {
storage['ach_' + achievements[i].name.replace(' ', '').toLowerCase()] = achievements[i].unlocked;
}
}
// Initialize automation production from saved data
for (var i = 0; i < upgrades.length; i++) {
if (upgrades[i].type === 'autoScoop') {
autoIcePerSecond += upgrades[i].owned * upgrades[i].production;
} else if (upgrades[i].type === 'clickPower') {
manualIcePerClick += upgrades[i].owned * upgrades[i].bonus;
}
}
// Game loop
var autoProductionTimer = 0;
game.update = function () {
// Auto production every second (60 ticks = 1 second)
autoProductionTimer++;
if (autoProductionTimer >= 60) {
if (autoIcePerSecond > 0) {
earnIceCream(autoIcePerSecond);
}
autoProductionTimer = 0;
}
// Check achievements periodically
if (LK.ticks % 300 === 0) {
checkAchievements();
}
};
// Start background music if not muted
if (!isMusicMuted) {
LK.playMusic('background');
}
// Initial display update
updateAllDisplays();
checkAchievements(); ===================================================================
--- original.js
+++ change.js
@@ -217,8 +217,14 @@
cost: storage.megafreezer_cost || 50000,
owned: storage.megafreezer_owned || 0,
production: 300,
type: 'autoScoop'
+}, {
+ name: 'Premium Shop',
+ cost: storage.premiumshop_cost || 1000,
+ owned: storage.premiumshop_owned || 0,
+ production: 10,
+ type: 'autoScoop'
}];
// Achievements
var achievements = [{
name: 'First Scoop',