/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var BackgroundElement = Container.expand(function (assetId, x, y, speed, rotationSpeed) {
var self = Container.call(this);
self.graphic = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.speed = speed;
self.rotationSpeed = rotationSpeed;
self.graphic.alpha = 0.1;
// Fade in animation
tween(self.graphic, {
alpha: 0.3
}, {
duration: 2000 + Math.random() * 3000
});
self.update = function () {
self.y += self.speed;
self.graphic.rotation += self.rotationSpeed;
// Reset position when off screen
if (self.y > 2800) {
self.y = -100;
self.x = Math.random() * 2048;
}
};
return self;
});
var Business = Container.expand(function (type, name, baseCost, baseIncome) {
var self = Container.call(this);
self.type = type;
self.name = name;
self.baseCost = baseCost;
self.baseIncome = baseIncome;
self.level = 0;
self.cost = baseCost;
self.income = 0;
var background = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.businessIcon = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.businessIcon.x = -200;
self.businessIcon.alpha = 0;
self.nameText = new Text2(name, {
size: 40,
fill: 0xFFFFFF
});
self.nameText.anchor.set(0.5, 0.3);
self.addChild(self.nameText);
self.costText = new Text2('$' + self.cost, {
size: 32,
fill: 0xFFFF00
});
self.costText.anchor.set(0.5, 0.7);
self.addChild(self.costText);
self.levelText = new Text2('Lv.0', {
size: 28,
fill: 0x00ff00
});
self.levelText.anchor.set(0.5, 0.5);
self.levelText.x = -200;
self.levelText.y = 50;
self.levelText.alpha = 0;
self.addChild(self.levelText);
self.updateDisplay = function () {
var businessIndex = -1;
for (var i = 0; i < businesses.length; i++) {
if (businesses[i] === self) {
businessIndex = i;
break;
}
}
var isUnlocked = businessIndex === -1 ? true : isBusinessUnlocked(businessIndex);
var synergyMultiplier = businessIndex === -1 ? 1 : calculateSynergyBonus(businessIndex);
var hasBonus = synergyMultiplier > 1;
if (!isUnlocked) {
background.tint = 0x444444;
self.alpha = 0.3;
self.costText.setText('LOCKED');
} else {
self.costText.setText('$' + formatNumber(self.cost));
if (hasBonus) {
background.tint = money >= self.cost ? 0xf39c12 : 0x7f8c8d;
} else {
background.tint = money >= self.cost ? 0x3498db : 0x7f8c8d;
}
self.alpha = 1;
}
self.levelText.setText('Lv.' + self.level + (hasBonus ? ' +' + Math.floor((synergyMultiplier - 1) * 100) + '%' : ''));
if (self.level > 0) {
self.businessIcon.alpha = Math.min(1, self.level * 0.2 + 0.3);
self.levelText.alpha = 1;
var scale = Math.min(2, 1 + self.level * 0.1);
self.businessIcon.scaleX = scale;
self.businessIcon.scaleY = scale;
if (hasBonus) {
self.businessIcon.tint = 0xf1c40f;
}
} else {
self.businessIcon.alpha = 0;
self.levelText.alpha = 0;
}
};
self.purchase = function () {
var businessIndex = -1;
for (var i = 0; i < businesses.length; i++) {
if (businesses[i] === self) {
businessIndex = i;
break;
}
}
var isUnlocked = businessIndex === -1 ? true : isBusinessUnlocked(businessIndex);
if (money >= self.cost && isUnlocked) {
// Button press animation
tween(background, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100,
onFinish: function onFinish() {
tween(background, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
money -= self.cost;
var wasFirstPurchase = self.level === 0;
self.level++;
self.income = self.baseIncome * self.level;
self.cost = Math.floor(self.baseCost * Math.pow(1.15, self.level));
if (!window.soundMuted && !soundMuted) {
var purchaseSound = LK.getSound('purchase');
purchaseSound.volume = window.soundVolume || soundVolume;
purchaseSound.play();
}
self.updateDisplay();
updateMoneyDisplay();
updateConnections();
// Update all businesses to show new synergy bonuses
for (var i = 0; i < businesses.length; i++) {
businesses[i].updateDisplay();
}
if (wasFirstPurchase) {
tween(self.businessIcon, {
alpha: 0.5,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
onFinish: function onFinish() {
tween(self.businessIcon, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
tween(self.levelText, {
alpha: 1
}, {
duration: 300
});
} else {
tween(self.businessIcon, {
scaleX: self.businessIcon.scaleX + 0.1,
scaleY: self.businessIcon.scaleY + 0.1
}, {
duration: 200,
onFinish: function onFinish() {
tween(self.businessIcon, {
scaleX: Math.min(2, 1 + self.level * 0.1),
scaleY: Math.min(2, 1 + self.level * 0.1)
}, {
duration: 100
});
}
});
}
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
}
};
self.down = function (x, y, obj) {
self.purchase();
};
return self;
});
var ConfirmationPanel = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.5
});
background.tint = 0x34495E;
background.alpha = 0.98;
var titleText = new Text2('Warning!', {
size: 50,
fill: 0xE74C3C
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -100;
self.addChild(titleText);
var messageText = new Text2('This will reset all your progress!\nAre you sure?', {
size: 35,
fill: 0xFFFFFF
});
messageText.anchor.set(0.5, 0.5);
messageText.y = -20;
self.addChild(messageText);
// Yes button
var yesButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.4,
scaleY: 0.4
});
yesButton.tint = 0xE74C3C;
yesButton.x = -100;
yesButton.y = 80;
var yesText = new Text2('Yes', {
size: 35,
fill: 0xFFFFFF
});
yesText.anchor.set(0.5, 0.5);
yesText.x = -100;
yesText.y = 80;
self.addChild(yesText);
// No button
var noButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.4,
scaleY: 0.4
});
noButton.tint = 0x95A5A6;
noButton.x = 100;
noButton.y = 80;
var noText = new Text2('No', {
size: 35,
fill: 0xFFFFFF
});
noText.anchor.set(0.5, 0.5);
noText.x = 100;
noText.y = 80;
self.addChild(noText);
self.down = function (x, y, obj) {
var localPos = {
x: x,
y: y
};
// Yes button
if (Math.abs(localPos.x + 100) < 60 && Math.abs(localPos.y - 80) < 30) {
// Reset all game data
storage.money = 0;
storage.tapValue = 1;
storage.prestigeMultiplier = 1;
storage.totalEarned = 0;
storage.prestigeCount = 0;
storage.prestigeCost = 1000000;
for (var i = 0; i < businesses.length; i++) {
storage['business_' + i + '_level'] = 0;
storage['business_' + i + '_cost'] = businessData[i].cost;
}
// Reset the game using LK's built-in functionality
LK.showGameOver();
return;
}
// No button
if (Math.abs(localPos.x - 100) < 60 && Math.abs(localPos.y - 80) < 30) {
self.destroy();
return;
}
};
return self;
});
var PrestigeButton = Container.expand(function () {
var self = Container.call(this);
var button = self.attachAsset('prestigeButton', {
anchorX: 0.5,
anchorY: 0.5
});
var prestigeText = new Text2('PRESTIGE', {
size: 32,
fill: 0xFFFFFF
});
prestigeText.anchor.set(0.5, 0.5);
self.addChild(prestigeText);
self.updateDisplay = function () {
var canPrestige = money >= prestigeCost && prestigeCount < 5;
button.tint = canPrestige ? 0x9b59b6 : 0x7f8c8d;
self.alpha = canPrestige ? 1 : 0.5;
if (prestigeCount >= 5) {
prestigeText.setText('MAX PRESTIGE');
button.tint = 0x444444;
self.alpha = 0.3;
} else {
prestigeText.setText('PRESTIGE (' + prestigeCount + '/5)\n$' + formatNumber(prestigeCost));
}
};
self.down = function (x, y, obj) {
// Button press animation
tween(button, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 150,
onFinish: function onFinish() {
tween(button, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
}
});
if (money >= prestigeCost && prestigeCount < 5) {
prestigeCount++;
prestigeMultiplier = Math.pow(3, prestigeCount);
money = 0;
tapValue = Math.floor(1 * Math.pow(3, prestigeCount));
// Increase prestige cost for next prestige
prestigeCost = Math.floor(prestigeCost * 5);
for (var i = 0; i < businesses.length; i++) {
businesses[i].level = 0;
businesses[i].income = 0;
businesses[i].cost = businesses[i].baseCost;
businesses[i].updateDisplay();
// Clear saved business data
storage['business_' + i + '_level'] = 0;
storage['business_' + i + '_cost'] = businesses[i].baseCost;
}
if (!window.soundMuted && !soundMuted) {
var prestigeSound = LK.getSound('prestige');
prestigeSound.volume = window.soundVolume || soundVolume;
prestigeSound.play();
}
updateMoneyDisplay();
updateIncomeDisplay();
LK.effects.flashScreen(0x9b59b6, 1000);
// Check if we've reached max prestiges
if (prestigeCount >= 5) {
LK.setTimeout(function () {
LK.effects.flashScreen(0x00ff00, 2000);
LK.showYouWin();
}, 1500);
}
}
};
return self;
});
var SettingsPanel = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 3
});
background.tint = 0x2c3e50;
background.alpha = 0.95;
var titleText = new Text2('Settings', {
size: 60,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -250;
self.addChild(titleText);
// Music volume section
var musicText = new Text2('Music Volume', {
size: 40,
fill: 0xFFFFFF
});
musicText.anchor.set(0.5, 0.5);
musicText.y = -150;
self.addChild(musicText);
var musicVolumeText = new Text2('100%', {
size: 35,
fill: 0xF1C40F
});
musicVolumeText.anchor.set(0.5, 0.5);
musicVolumeText.y = -100;
self.addChild(musicVolumeText);
// Sound effects volume section
var soundText = new Text2('Sound Effects Volume', {
size: 40,
fill: 0xFFFFFF
});
soundText.anchor.set(0.5, 0.5);
soundText.y = -20;
self.addChild(soundText);
var soundVolumeText = new Text2('100%', {
size: 35,
fill: 0xF1C40F
});
soundVolumeText.anchor.set(0.5, 0.5);
soundVolumeText.y = 30;
self.addChild(soundVolumeText);
// Reset button
var resetButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.6
});
resetButton.tint = 0xE74C3C;
resetButton.y = 150;
var resetText = new Text2('Reset Game', {
size: 40,
fill: 0xFFFFFF
});
resetText.anchor.set(0.5, 0.5);
resetText.y = 150;
self.addChild(resetText);
// Close button
var closeButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
closeButton.tint = 0x95A5A6;
closeButton.y = -300;
closeButton.x = 300;
var closeText = new Text2('X', {
size: 50,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.y = -300;
closeText.x = 300;
self.addChild(closeText);
// Volume controls
var musicVolume = storage.musicVolume || 1;
var soundVolume = storage.soundVolume || 1;
var musicMuted = storage.musicMuted || false;
var soundMuted = storage.soundMuted || false;
self.updateVolumeDisplays = function () {
musicVolumeText.setText(musicMuted ? 'MUTED' : Math.floor(musicVolume * 100) + '%');
soundVolumeText.setText(soundMuted ? 'MUTED' : Math.floor(soundVolume * 100) + '%');
musicMuteButton.tint = musicMuted ? 0x27AE60 : 0xE74C3C;
musicMuteText.setText(musicMuted ? 'UNMUTE' : 'MUTE');
soundMuteButton.tint = soundMuted ? 0x27AE60 : 0xE74C3C;
soundMuteText.setText(soundMuted ? 'UNMUTE' : 'MUTE');
};
// Music volume controls
var musicMinusButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.2,
scaleY: 0.2
});
musicMinusButton.tint = 0x3498DB;
musicMinusButton.x = -150;
musicMinusButton.y = -100;
var musicMinusText = new Text2('-', {
size: 40,
fill: 0xFFFFFF
});
musicMinusText.anchor.set(0.5, 0.5);
musicMinusText.x = -150;
musicMinusText.y = -100;
self.addChild(musicMinusText);
var musicPlusButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.2,
scaleY: 0.2
});
musicPlusButton.tint = 0x3498DB;
musicPlusButton.x = 150;
musicPlusButton.y = -100;
var musicPlusText = new Text2('+', {
size: 40,
fill: 0xFFFFFF
});
musicPlusText.anchor.set(0.5, 0.5);
musicPlusText.x = 150;
musicPlusText.y = -100;
self.addChild(musicPlusText);
// Music mute button
var musicMuteButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
musicMuteButton.tint = 0xE74C3C;
musicMuteButton.x = 200;
musicMuteButton.y = -100;
var musicMuteText = new Text2('MUTE', {
size: 25,
fill: 0xFFFFFF
});
musicMuteText.anchor.set(0.5, 0.5);
musicMuteText.x = 200;
musicMuteText.y = -100;
self.addChild(musicMuteText);
// Sound volume controls
var soundMinusButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.2,
scaleY: 0.2
});
soundMinusButton.tint = 0x3498DB;
soundMinusButton.x = -150;
soundMinusButton.y = 30;
var soundMinusText = new Text2('-', {
size: 40,
fill: 0xFFFFFF
});
soundMinusText.anchor.set(0.5, 0.5);
soundMinusText.x = -150;
soundMinusText.y = 30;
self.addChild(soundMinusText);
var soundPlusButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.2,
scaleY: 0.2
});
soundPlusButton.tint = 0x3498DB;
soundPlusButton.x = 150;
soundPlusButton.y = 30;
var soundPlusText = new Text2('+', {
size: 40,
fill: 0xFFFFFF
});
soundPlusText.anchor.set(0.5, 0.5);
soundPlusText.x = 150;
soundPlusText.y = 30;
self.addChild(soundPlusText);
// Sound effects mute button
var soundMuteButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
soundMuteButton.tint = 0xE74C3C;
soundMuteButton.x = 200;
soundMuteButton.y = 30;
var soundMuteText = new Text2('MUTE', {
size: 25,
fill: 0xFFFFFF
});
soundMuteText.anchor.set(0.5, 0.5);
soundMuteText.x = 200;
soundMuteText.y = 30;
self.addChild(soundMuteText);
// Initialize display after all elements are created
self.updateVolumeDisplays();
// Event handlers
self.down = function (x, y, obj) {
var localPos = {
x: x,
y: y
};
// Close button
if (Math.abs(localPos.x - 300) < 50 && Math.abs(localPos.y + 300) < 50) {
self.destroy();
return;
}
// Music mute button
if (Math.abs(localPos.x - 200) < 45 && Math.abs(localPos.y + 100) < 45) {
musicMuted = !musicMuted;
storage.musicMuted = musicMuted;
// Update global mute state
window.musicMuted = musicMuted;
if (typeof window.parent !== 'undefined') {
window.parent.musicMuted = musicMuted;
}
// Update music volume immediately
if (musicMuted) {
LK.stopMusic();
} else {
LK.playMusic('bgmusic', {
fade: {
start: 0,
end: musicVolume * 0.3,
duration: 200
}
});
}
self.updateVolumeDisplays();
return;
}
// Music volume controls
if (Math.abs(localPos.x + 150) < 30 && Math.abs(localPos.y + 100) < 30) {
musicVolume = Math.max(0, musicVolume - 0.1);
storage.musicVolume = musicVolume;
// Update global music volume variable
window.musicVolume = musicVolume;
// Update the global variable in game scope
window.parent.musicVolume = musicVolume;
// Update the global variable in game code scope
if (typeof window.parent.parent !== 'undefined') {
window.parent.parent.musicVolume = musicVolume;
}
// Update background music volume immediately
if (!musicMuted) {
LK.playMusic('bgmusic', {
fade: {
start: musicVolume * 0.3,
end: musicVolume * 0.3,
duration: 200
}
});
}
self.updateVolumeDisplays();
return;
}
if (Math.abs(localPos.x - 150) < 30 && Math.abs(localPos.y + 100) < 30) {
musicVolume = Math.min(1, musicVolume + 0.1);
storage.musicVolume = musicVolume;
// Update global music volume variable
window.musicVolume = musicVolume;
// Update the global variable in game scope
window.parent.musicVolume = musicVolume;
// Update the global variable in game code scope
if (typeof window.parent.parent !== 'undefined') {
window.parent.parent.musicVolume = musicVolume;
}
// Update background music volume immediately
if (!musicMuted) {
LK.playMusic('bgmusic', {
fade: {
start: musicVolume * 0.3,
end: musicVolume * 0.3,
duration: 200
}
});
}
self.updateVolumeDisplays();
return;
}
// Sound effects mute button
if (Math.abs(localPos.x - 200) < 45 && Math.abs(localPos.y - 30) < 45) {
soundMuted = !soundMuted;
storage.soundMuted = soundMuted;
// Update global mute state
window.soundMuted = soundMuted;
if (typeof window.parent !== 'undefined') {
window.parent.soundMuted = soundMuted;
}
// Play a test sound if unmuting
if (!soundMuted) {
var testSound = LK.getSound('tap');
testSound.volume = soundVolume;
testSound.play();
}
self.updateVolumeDisplays();
return;
}
// Sound volume controls
if (Math.abs(localPos.x + 150) < 30 && Math.abs(localPos.y - 30) < 30) {
soundVolume = Math.max(0, soundVolume - 0.1);
storage.soundVolume = soundVolume;
// Update global sound volume variable
window.soundVolume = soundVolume;
// Update the global variable in game scope
window.parent.soundVolume = soundVolume;
// Update the global variable in game code scope
if (typeof window.parent.parent !== 'undefined') {
window.parent.parent.soundVolume = soundVolume;
}
// Update the game scope variable
if (typeof game !== 'undefined' && game.parent) {
game.parent.soundVolume = soundVolume;
}
// Play a test sound to demonstrate volume change
if (!soundMuted) {
var testSound = LK.getSound('tap');
testSound.volume = window.soundVolume || soundVolume;
testSound.play();
}
self.updateVolumeDisplays();
return;
}
if (Math.abs(localPos.x - 150) < 30 && Math.abs(localPos.y - 30) < 30) {
soundVolume = Math.min(1, soundVolume + 0.1);
storage.soundVolume = soundVolume;
// Update global sound volume variable
window.soundVolume = soundVolume;
// Update the global variable in game scope
window.parent.soundVolume = soundVolume;
// Update the global variable in game code scope
if (typeof window.parent.parent !== 'undefined') {
window.parent.parent.soundVolume = soundVolume;
}
// Update the game scope variable
if (typeof game !== 'undefined' && game.parent) {
game.parent.soundVolume = soundVolume;
}
// Play a test sound to demonstrate volume change
if (!soundMuted) {
var testSound = LK.getSound('tap');
testSound.volume = window.soundVolume || soundVolume;
testSound.play();
}
self.updateVolumeDisplays();
return;
}
// Reset button
if (Math.abs(localPos.x) < 200 && Math.abs(localPos.y - 150) < 50) {
var confirmPanel = game.addChild(new ConfirmationPanel());
confirmPanel.x = 1024;
confirmPanel.y = 1366;
return;
}
};
return self;
});
var TapButton = Container.expand(function () {
var self = Container.call(this);
var button = self.attachAsset('tapButton', {
anchorX: 0.5,
anchorY: 0.5
});
var tapText = new Text2('TAP\nFOR $' + tapValue, {
size: 60,
fill: 0xFFFFFF
});
tapText.anchor.set(0.5, 0.5);
self.addChild(tapText);
self.updateDisplay = function () {
tapText.setText('TAP\nFOR $' + tapValue);
};
self.down = function (x, y, obj) {
money += tapValue;
updateMoneyDisplay();
if (!window.soundMuted && !soundMuted) {
var tapSound = LK.getSound('tap');
tapSound.volume = window.soundVolume || soundVolume;
tapSound.play();
}
// Enhanced button press animation with color flash
tween(button, {
tint: 0xFFFFFF
}, {
duration: 50,
onFinish: function onFinish() {
tween(button, {
tint: 0xFFFFFF
}, {
duration: 50
});
}
});
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
var floatingText = new Text2('+$' + tapValue, {
size: 40,
fill: 0x00FF00
});
floatingText.anchor.set(0.5, 0.5);
floatingText.x = x;
floatingText.y = y;
game.addChild(floatingText);
tween(floatingText, {
y: floatingText.y - 100,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
floatingText.destroy();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a252f
});
/****
* Game Code
****/
var money = storage.money || 0;
var tapValue = storage.tapValue || 1;
var prestigeMultiplier = storage.prestigeMultiplier || 1;
var totalEarned = storage.totalEarned || 0;
var prestigeCount = storage.prestigeCount || 0;
var prestigeCost = storage.prestigeCost || 1000000;
var musicVolume = storage.musicVolume || 1;
var soundVolume = storage.soundVolume || 1;
var musicMuted = storage.musicMuted || false;
var soundMuted = storage.soundMuted || false;
// Make volume variables globally accessible
window.musicVolume = musicVolume;
window.soundVolume = soundVolume;
window.musicMuted = musicMuted;
window.soundMuted = soundMuted;
// Make parent reference available for updating from settings
window.parent = {
musicVolume: musicVolume,
soundVolume: soundVolume,
musicMuted: musicMuted,
soundMuted: soundMuted
};
// Update tap value based on prestige multiplier
tapValue = Math.floor(1 * Math.pow(3, prestigeCount));
var businesses = [];
var businessData = [{
type: 'lemonadeStand',
name: 'Lemonade Stand',
cost: 10,
income: 1,
unlockRequirement: null,
synergies: ['newspaper'],
// Newspaper route helps advertise lemonade
synergyBonus: 0.1 // 10% bonus per synergy business level
}, {
type: 'newspaper',
name: 'Newspaper Route',
cost: 100,
income: 5,
unlockRequirement: {
business: 0,
level: 1
},
// Requires 1 lemonade stand
synergies: ['lemonadeStand', 'restaurant'],
// Advertises both lemonade and restaurant
synergyBonus: 0.15
}, {
type: 'carwash',
name: 'Car Wash',
cost: 500,
income: 20,
unlockRequirement: {
business: 1,
level: 2
},
// Requires 2 newspaper routes
synergies: ['restaurant'],
// Clean cars bring customers to restaurant
synergyBonus: 0.2
}, {
type: 'restaurant',
name: 'Restaurant',
cost: 2000,
income: 80,
unlockRequirement: {
business: 2,
level: 1
},
// Requires 1 car wash
synergies: ['factory'],
// Restaurant supplies factory workers
synergyBonus: 0.25
}, {
type: 'factory',
name: 'Factory',
cost: 10000,
income: 400,
unlockRequirement: {
business: 3,
level: 2
},
// Requires 2 restaurants
synergies: ['bank'],
// Factory profits go to bank
synergyBonus: 0.3
}, {
type: 'bank',
name: 'Bank',
cost: 50000,
income: 2000,
unlockRequirement: {
business: 4,
level: 1
},
// Requires 1 factory
synergies: ['tech'],
// Bank finances tech company
synergyBonus: 0.35
}, {
type: 'tech',
name: 'Tech Company',
cost: 250000,
income: 10000,
unlockRequirement: {
business: 5,
level: 1
},
// Requires 1 bank
synergies: [],
// No synergies for final business
synergyBonus: 0.4
}];
function formatNumber(num) {
if (num >= 1000000000) {
return (num / 1000000000).toFixed(1) + 'B';
} else 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 updateMoneyDisplay() {
moneyText.setText('$' + formatNumber(money));
for (var i = 0; i < businesses.length; i++) {
businesses[i].updateDisplay();
}
prestigeButton.updateDisplay();
if (tapButton.updateDisplay) {
tapButton.updateDisplay();
}
}
function calculateSynergyBonus(businessIndex) {
var business = businesses[businessIndex];
var data = businessData[businessIndex];
var synergyMultiplier = 1;
if (data.synergies && data.synergies.length > 0) {
for (var i = 0; i < data.synergies.length; i++) {
var synergyType = data.synergies[i];
for (var j = 0; j < businesses.length; j++) {
if (businessData[j].type === synergyType) {
synergyMultiplier += businesses[j].level * data.synergyBonus;
break;
}
}
}
}
return synergyMultiplier;
}
function isBusinessUnlocked(businessIndex) {
var data = businessData[businessIndex];
if (!data.unlockRequirement) return true;
var requiredBusiness = businesses[data.unlockRequirement.business];
return requiredBusiness && requiredBusiness.level >= data.unlockRequirement.level;
}
function updateIncomeDisplay() {
var totalIncome = 0;
for (var i = 0; i < businesses.length; i++) {
var baseIncome = businesses[i].income;
var synergyMultiplier = calculateSynergyBonus(i);
var finalIncome = baseIncome * synergyMultiplier * prestigeMultiplier;
totalIncome += finalIncome;
}
var prestigeText = prestigeCount > 0 ? ' (x' + prestigeMultiplier.toFixed(0) + ')' : '';
incomeText.setText('$' + formatNumber(totalIncome) + '/sec' + prestigeText);
}
var moneyText = new Text2('$' + formatNumber(money), {
size: 80,
fill: 0xF1C40F
});
moneyText.anchor.set(0.5, 0);
LK.gui.top.addChild(moneyText);
var incomeText = new Text2('$0/sec', {
size: 50,
fill: 0xE74C3C
});
incomeText.anchor.set(0.5, 0);
incomeText.y = 100;
LK.gui.top.addChild(incomeText);
var settingsButton = new Text2('⚙️', {
size: 60,
fill: 0xFFFFFF
});
settingsButton.anchor.set(1, 0);
settingsButton.x = -20;
settingsButton.y = 20;
LK.gui.topRight.addChild(settingsButton);
settingsButton.down = function (x, y, obj) {
var settingsPanel = game.addChild(new SettingsPanel());
settingsPanel.x = 1024;
settingsPanel.y = 1366;
};
var tapButton = game.addChild(new TapButton());
tapButton.x = 1024;
tapButton.y = 800;
for (var i = 0; i < businessData.length; i++) {
var business = new Business(businessData[i].type, businessData[i].name, businessData[i].cost, businessData[i].income);
business.x = 1024;
business.y = 1200 + i * 140;
// Load saved business data
var savedLevel = storage['business_' + i + '_level'] || 0;
var savedCost = storage['business_' + i + '_cost'] || businessData[i].cost;
business.level = savedLevel;
business.cost = savedCost;
business.income = businessData[i].income * savedLevel;
businesses.push(business);
game.addChild(business);
}
var prestigeButton = game.addChild(new PrestigeButton());
prestigeButton.x = 1024;
prestigeButton.y = 2500;
var winText = new Text2('TECH EMPIRE UNLOCKED!', {
size: 60,
fill: 0xFFFFFF
});
winText.anchor.set(0.5, 0.5);
winText.x = 1024;
winText.y = 1366;
winText.alpha = 0;
game.addChild(winText);
var connectionLines = [];
var backgroundElements = [];
// Create animated background elements
for (var i = 0; i < 8; i++) {
var assetTypes = ['bgCircle1', 'bgCircle2', 'bgCircle3', 'bgRect1', 'bgRect2'];
var randomAsset = assetTypes[Math.floor(Math.random() * assetTypes.length)];
var bgElement = new BackgroundElement(randomAsset, Math.random() * 2048, Math.random() * 2732, 0.2 + Math.random() * 0.8, (Math.random() - 0.5) * 0.02);
backgroundElements.push(bgElement);
game.addChild(bgElement);
}
// Update displays after loading saved data
for (var i = 0; i < businesses.length; i++) {
businesses[i].updateDisplay();
}
updateMoneyDisplay();
updateIncomeDisplay();
updateConnections();
// Play background music
if (!musicMuted) {
LK.playMusic('bgmusic', {
fade: {
start: 0,
end: musicVolume * 0.3,
duration: 2000
}
});
}
// Create gradient overlay for visual depth
var gradientOverlay = LK.getAsset('upgradeButton', {
anchorX: 0,
anchorY: 0,
scaleX: 3.5,
scaleY: 4.5
});
gradientOverlay.tint = 0x0f1419;
gradientOverlay.alpha = 0.4;
gradientOverlay.x = 0;
gradientOverlay.y = 0;
game.addChild(gradientOverlay);
function createConnectionLine(fromBusiness, toBusiness) {
var line = new Container();
var connectionShape = line.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.5
});
connectionShape.tint = 0x27ae60;
connectionShape.alpha = 0.3;
var midX = (fromBusiness.x + toBusiness.x) / 2;
var midY = (fromBusiness.y + toBusiness.y) / 2;
line.x = midX;
line.y = midY;
var angle = Math.atan2(toBusiness.y - fromBusiness.y, toBusiness.x - fromBusiness.x);
line.rotation = angle;
game.addChild(line);
connectionLines.push(line);
return line;
}
function updateConnections() {
// Clear existing connections
for (var i = 0; i < connectionLines.length; i++) {
connectionLines[i].destroy();
}
connectionLines = [];
// Create new connections based on synergies
for (var i = 0; i < businesses.length; i++) {
var business = businesses[i];
var data = businessData[i];
if (business.level > 0 && data.synergies) {
for (var j = 0; j < data.synergies.length; j++) {
var synergyType = data.synergies[j];
for (var k = 0; k < businesses.length; k++) {
if (businessData[k].type === synergyType && businesses[k].level > 0) {
var line = createConnectionLine(business, businesses[k]);
tween(line, {
alpha: 0.6
}, {
duration: 500
});
break;
}
}
}
}
}
}
var hasWon = false;
var lastIncomeUpdate = 0;
game.update = function () {
if (LK.ticks % 60 === 0) {
var totalIncome = 0;
for (var i = 0; i < businesses.length; i++) {
var baseIncome = businesses[i].income;
var synergyMultiplier = calculateSynergyBonus(i);
var finalIncome = baseIncome * synergyMultiplier * prestigeMultiplier;
totalIncome += finalIncome;
}
if (totalIncome > 0) {
money += totalIncome;
totalEarned += totalIncome;
updateMoneyDisplay();
}
if (totalIncome !== lastIncomeUpdate) {
updateIncomeDisplay();
lastIncomeUpdate = totalIncome;
}
}
// Game only ends when 5 prestiges are completed (handled in PrestigeButton)
if (LK.ticks % 300 === 0) {
storage.money = money;
storage.tapValue = tapValue;
storage.prestigeMultiplier = prestigeMultiplier;
storage.totalEarned = totalEarned;
storage.prestigeCount = prestigeCount;
storage.prestigeCost = prestigeCost;
storage.musicVolume = musicVolume;
storage.soundVolume = soundVolume;
storage.musicMuted = musicMuted;
storage.soundMuted = soundMuted;
// Save business data
for (var i = 0; i < businesses.length; i++) {
storage['business_' + i + '_level'] = businesses[i].level;
storage['business_' + i + '_cost'] = businesses[i].cost;
}
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var BackgroundElement = Container.expand(function (assetId, x, y, speed, rotationSpeed) {
var self = Container.call(this);
self.graphic = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.speed = speed;
self.rotationSpeed = rotationSpeed;
self.graphic.alpha = 0.1;
// Fade in animation
tween(self.graphic, {
alpha: 0.3
}, {
duration: 2000 + Math.random() * 3000
});
self.update = function () {
self.y += self.speed;
self.graphic.rotation += self.rotationSpeed;
// Reset position when off screen
if (self.y > 2800) {
self.y = -100;
self.x = Math.random() * 2048;
}
};
return self;
});
var Business = Container.expand(function (type, name, baseCost, baseIncome) {
var self = Container.call(this);
self.type = type;
self.name = name;
self.baseCost = baseCost;
self.baseIncome = baseIncome;
self.level = 0;
self.cost = baseCost;
self.income = 0;
var background = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.businessIcon = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.businessIcon.x = -200;
self.businessIcon.alpha = 0;
self.nameText = new Text2(name, {
size: 40,
fill: 0xFFFFFF
});
self.nameText.anchor.set(0.5, 0.3);
self.addChild(self.nameText);
self.costText = new Text2('$' + self.cost, {
size: 32,
fill: 0xFFFF00
});
self.costText.anchor.set(0.5, 0.7);
self.addChild(self.costText);
self.levelText = new Text2('Lv.0', {
size: 28,
fill: 0x00ff00
});
self.levelText.anchor.set(0.5, 0.5);
self.levelText.x = -200;
self.levelText.y = 50;
self.levelText.alpha = 0;
self.addChild(self.levelText);
self.updateDisplay = function () {
var businessIndex = -1;
for (var i = 0; i < businesses.length; i++) {
if (businesses[i] === self) {
businessIndex = i;
break;
}
}
var isUnlocked = businessIndex === -1 ? true : isBusinessUnlocked(businessIndex);
var synergyMultiplier = businessIndex === -1 ? 1 : calculateSynergyBonus(businessIndex);
var hasBonus = synergyMultiplier > 1;
if (!isUnlocked) {
background.tint = 0x444444;
self.alpha = 0.3;
self.costText.setText('LOCKED');
} else {
self.costText.setText('$' + formatNumber(self.cost));
if (hasBonus) {
background.tint = money >= self.cost ? 0xf39c12 : 0x7f8c8d;
} else {
background.tint = money >= self.cost ? 0x3498db : 0x7f8c8d;
}
self.alpha = 1;
}
self.levelText.setText('Lv.' + self.level + (hasBonus ? ' +' + Math.floor((synergyMultiplier - 1) * 100) + '%' : ''));
if (self.level > 0) {
self.businessIcon.alpha = Math.min(1, self.level * 0.2 + 0.3);
self.levelText.alpha = 1;
var scale = Math.min(2, 1 + self.level * 0.1);
self.businessIcon.scaleX = scale;
self.businessIcon.scaleY = scale;
if (hasBonus) {
self.businessIcon.tint = 0xf1c40f;
}
} else {
self.businessIcon.alpha = 0;
self.levelText.alpha = 0;
}
};
self.purchase = function () {
var businessIndex = -1;
for (var i = 0; i < businesses.length; i++) {
if (businesses[i] === self) {
businessIndex = i;
break;
}
}
var isUnlocked = businessIndex === -1 ? true : isBusinessUnlocked(businessIndex);
if (money >= self.cost && isUnlocked) {
// Button press animation
tween(background, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100,
onFinish: function onFinish() {
tween(background, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
money -= self.cost;
var wasFirstPurchase = self.level === 0;
self.level++;
self.income = self.baseIncome * self.level;
self.cost = Math.floor(self.baseCost * Math.pow(1.15, self.level));
if (!window.soundMuted && !soundMuted) {
var purchaseSound = LK.getSound('purchase');
purchaseSound.volume = window.soundVolume || soundVolume;
purchaseSound.play();
}
self.updateDisplay();
updateMoneyDisplay();
updateConnections();
// Update all businesses to show new synergy bonuses
for (var i = 0; i < businesses.length; i++) {
businesses[i].updateDisplay();
}
if (wasFirstPurchase) {
tween(self.businessIcon, {
alpha: 0.5,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
onFinish: function onFinish() {
tween(self.businessIcon, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
tween(self.levelText, {
alpha: 1
}, {
duration: 300
});
} else {
tween(self.businessIcon, {
scaleX: self.businessIcon.scaleX + 0.1,
scaleY: self.businessIcon.scaleY + 0.1
}, {
duration: 200,
onFinish: function onFinish() {
tween(self.businessIcon, {
scaleX: Math.min(2, 1 + self.level * 0.1),
scaleY: Math.min(2, 1 + self.level * 0.1)
}, {
duration: 100
});
}
});
}
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
}
};
self.down = function (x, y, obj) {
self.purchase();
};
return self;
});
var ConfirmationPanel = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.5
});
background.tint = 0x34495E;
background.alpha = 0.98;
var titleText = new Text2('Warning!', {
size: 50,
fill: 0xE74C3C
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -100;
self.addChild(titleText);
var messageText = new Text2('This will reset all your progress!\nAre you sure?', {
size: 35,
fill: 0xFFFFFF
});
messageText.anchor.set(0.5, 0.5);
messageText.y = -20;
self.addChild(messageText);
// Yes button
var yesButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.4,
scaleY: 0.4
});
yesButton.tint = 0xE74C3C;
yesButton.x = -100;
yesButton.y = 80;
var yesText = new Text2('Yes', {
size: 35,
fill: 0xFFFFFF
});
yesText.anchor.set(0.5, 0.5);
yesText.x = -100;
yesText.y = 80;
self.addChild(yesText);
// No button
var noButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.4,
scaleY: 0.4
});
noButton.tint = 0x95A5A6;
noButton.x = 100;
noButton.y = 80;
var noText = new Text2('No', {
size: 35,
fill: 0xFFFFFF
});
noText.anchor.set(0.5, 0.5);
noText.x = 100;
noText.y = 80;
self.addChild(noText);
self.down = function (x, y, obj) {
var localPos = {
x: x,
y: y
};
// Yes button
if (Math.abs(localPos.x + 100) < 60 && Math.abs(localPos.y - 80) < 30) {
// Reset all game data
storage.money = 0;
storage.tapValue = 1;
storage.prestigeMultiplier = 1;
storage.totalEarned = 0;
storage.prestigeCount = 0;
storage.prestigeCost = 1000000;
for (var i = 0; i < businesses.length; i++) {
storage['business_' + i + '_level'] = 0;
storage['business_' + i + '_cost'] = businessData[i].cost;
}
// Reset the game using LK's built-in functionality
LK.showGameOver();
return;
}
// No button
if (Math.abs(localPos.x - 100) < 60 && Math.abs(localPos.y - 80) < 30) {
self.destroy();
return;
}
};
return self;
});
var PrestigeButton = Container.expand(function () {
var self = Container.call(this);
var button = self.attachAsset('prestigeButton', {
anchorX: 0.5,
anchorY: 0.5
});
var prestigeText = new Text2('PRESTIGE', {
size: 32,
fill: 0xFFFFFF
});
prestigeText.anchor.set(0.5, 0.5);
self.addChild(prestigeText);
self.updateDisplay = function () {
var canPrestige = money >= prestigeCost && prestigeCount < 5;
button.tint = canPrestige ? 0x9b59b6 : 0x7f8c8d;
self.alpha = canPrestige ? 1 : 0.5;
if (prestigeCount >= 5) {
prestigeText.setText('MAX PRESTIGE');
button.tint = 0x444444;
self.alpha = 0.3;
} else {
prestigeText.setText('PRESTIGE (' + prestigeCount + '/5)\n$' + formatNumber(prestigeCost));
}
};
self.down = function (x, y, obj) {
// Button press animation
tween(button, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 150,
onFinish: function onFinish() {
tween(button, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
}
});
if (money >= prestigeCost && prestigeCount < 5) {
prestigeCount++;
prestigeMultiplier = Math.pow(3, prestigeCount);
money = 0;
tapValue = Math.floor(1 * Math.pow(3, prestigeCount));
// Increase prestige cost for next prestige
prestigeCost = Math.floor(prestigeCost * 5);
for (var i = 0; i < businesses.length; i++) {
businesses[i].level = 0;
businesses[i].income = 0;
businesses[i].cost = businesses[i].baseCost;
businesses[i].updateDisplay();
// Clear saved business data
storage['business_' + i + '_level'] = 0;
storage['business_' + i + '_cost'] = businesses[i].baseCost;
}
if (!window.soundMuted && !soundMuted) {
var prestigeSound = LK.getSound('prestige');
prestigeSound.volume = window.soundVolume || soundVolume;
prestigeSound.play();
}
updateMoneyDisplay();
updateIncomeDisplay();
LK.effects.flashScreen(0x9b59b6, 1000);
// Check if we've reached max prestiges
if (prestigeCount >= 5) {
LK.setTimeout(function () {
LK.effects.flashScreen(0x00ff00, 2000);
LK.showYouWin();
}, 1500);
}
}
};
return self;
});
var SettingsPanel = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 3
});
background.tint = 0x2c3e50;
background.alpha = 0.95;
var titleText = new Text2('Settings', {
size: 60,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -250;
self.addChild(titleText);
// Music volume section
var musicText = new Text2('Music Volume', {
size: 40,
fill: 0xFFFFFF
});
musicText.anchor.set(0.5, 0.5);
musicText.y = -150;
self.addChild(musicText);
var musicVolumeText = new Text2('100%', {
size: 35,
fill: 0xF1C40F
});
musicVolumeText.anchor.set(0.5, 0.5);
musicVolumeText.y = -100;
self.addChild(musicVolumeText);
// Sound effects volume section
var soundText = new Text2('Sound Effects Volume', {
size: 40,
fill: 0xFFFFFF
});
soundText.anchor.set(0.5, 0.5);
soundText.y = -20;
self.addChild(soundText);
var soundVolumeText = new Text2('100%', {
size: 35,
fill: 0xF1C40F
});
soundVolumeText.anchor.set(0.5, 0.5);
soundVolumeText.y = 30;
self.addChild(soundVolumeText);
// Reset button
var resetButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.6
});
resetButton.tint = 0xE74C3C;
resetButton.y = 150;
var resetText = new Text2('Reset Game', {
size: 40,
fill: 0xFFFFFF
});
resetText.anchor.set(0.5, 0.5);
resetText.y = 150;
self.addChild(resetText);
// Close button
var closeButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
closeButton.tint = 0x95A5A6;
closeButton.y = -300;
closeButton.x = 300;
var closeText = new Text2('X', {
size: 50,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.y = -300;
closeText.x = 300;
self.addChild(closeText);
// Volume controls
var musicVolume = storage.musicVolume || 1;
var soundVolume = storage.soundVolume || 1;
var musicMuted = storage.musicMuted || false;
var soundMuted = storage.soundMuted || false;
self.updateVolumeDisplays = function () {
musicVolumeText.setText(musicMuted ? 'MUTED' : Math.floor(musicVolume * 100) + '%');
soundVolumeText.setText(soundMuted ? 'MUTED' : Math.floor(soundVolume * 100) + '%');
musicMuteButton.tint = musicMuted ? 0x27AE60 : 0xE74C3C;
musicMuteText.setText(musicMuted ? 'UNMUTE' : 'MUTE');
soundMuteButton.tint = soundMuted ? 0x27AE60 : 0xE74C3C;
soundMuteText.setText(soundMuted ? 'UNMUTE' : 'MUTE');
};
// Music volume controls
var musicMinusButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.2,
scaleY: 0.2
});
musicMinusButton.tint = 0x3498DB;
musicMinusButton.x = -150;
musicMinusButton.y = -100;
var musicMinusText = new Text2('-', {
size: 40,
fill: 0xFFFFFF
});
musicMinusText.anchor.set(0.5, 0.5);
musicMinusText.x = -150;
musicMinusText.y = -100;
self.addChild(musicMinusText);
var musicPlusButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.2,
scaleY: 0.2
});
musicPlusButton.tint = 0x3498DB;
musicPlusButton.x = 150;
musicPlusButton.y = -100;
var musicPlusText = new Text2('+', {
size: 40,
fill: 0xFFFFFF
});
musicPlusText.anchor.set(0.5, 0.5);
musicPlusText.x = 150;
musicPlusText.y = -100;
self.addChild(musicPlusText);
// Music mute button
var musicMuteButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
musicMuteButton.tint = 0xE74C3C;
musicMuteButton.x = 200;
musicMuteButton.y = -100;
var musicMuteText = new Text2('MUTE', {
size: 25,
fill: 0xFFFFFF
});
musicMuteText.anchor.set(0.5, 0.5);
musicMuteText.x = 200;
musicMuteText.y = -100;
self.addChild(musicMuteText);
// Sound volume controls
var soundMinusButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.2,
scaleY: 0.2
});
soundMinusButton.tint = 0x3498DB;
soundMinusButton.x = -150;
soundMinusButton.y = 30;
var soundMinusText = new Text2('-', {
size: 40,
fill: 0xFFFFFF
});
soundMinusText.anchor.set(0.5, 0.5);
soundMinusText.x = -150;
soundMinusText.y = 30;
self.addChild(soundMinusText);
var soundPlusButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.2,
scaleY: 0.2
});
soundPlusButton.tint = 0x3498DB;
soundPlusButton.x = 150;
soundPlusButton.y = 30;
var soundPlusText = new Text2('+', {
size: 40,
fill: 0xFFFFFF
});
soundPlusText.anchor.set(0.5, 0.5);
soundPlusText.x = 150;
soundPlusText.y = 30;
self.addChild(soundPlusText);
// Sound effects mute button
var soundMuteButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
soundMuteButton.tint = 0xE74C3C;
soundMuteButton.x = 200;
soundMuteButton.y = 30;
var soundMuteText = new Text2('MUTE', {
size: 25,
fill: 0xFFFFFF
});
soundMuteText.anchor.set(0.5, 0.5);
soundMuteText.x = 200;
soundMuteText.y = 30;
self.addChild(soundMuteText);
// Initialize display after all elements are created
self.updateVolumeDisplays();
// Event handlers
self.down = function (x, y, obj) {
var localPos = {
x: x,
y: y
};
// Close button
if (Math.abs(localPos.x - 300) < 50 && Math.abs(localPos.y + 300) < 50) {
self.destroy();
return;
}
// Music mute button
if (Math.abs(localPos.x - 200) < 45 && Math.abs(localPos.y + 100) < 45) {
musicMuted = !musicMuted;
storage.musicMuted = musicMuted;
// Update global mute state
window.musicMuted = musicMuted;
if (typeof window.parent !== 'undefined') {
window.parent.musicMuted = musicMuted;
}
// Update music volume immediately
if (musicMuted) {
LK.stopMusic();
} else {
LK.playMusic('bgmusic', {
fade: {
start: 0,
end: musicVolume * 0.3,
duration: 200
}
});
}
self.updateVolumeDisplays();
return;
}
// Music volume controls
if (Math.abs(localPos.x + 150) < 30 && Math.abs(localPos.y + 100) < 30) {
musicVolume = Math.max(0, musicVolume - 0.1);
storage.musicVolume = musicVolume;
// Update global music volume variable
window.musicVolume = musicVolume;
// Update the global variable in game scope
window.parent.musicVolume = musicVolume;
// Update the global variable in game code scope
if (typeof window.parent.parent !== 'undefined') {
window.parent.parent.musicVolume = musicVolume;
}
// Update background music volume immediately
if (!musicMuted) {
LK.playMusic('bgmusic', {
fade: {
start: musicVolume * 0.3,
end: musicVolume * 0.3,
duration: 200
}
});
}
self.updateVolumeDisplays();
return;
}
if (Math.abs(localPos.x - 150) < 30 && Math.abs(localPos.y + 100) < 30) {
musicVolume = Math.min(1, musicVolume + 0.1);
storage.musicVolume = musicVolume;
// Update global music volume variable
window.musicVolume = musicVolume;
// Update the global variable in game scope
window.parent.musicVolume = musicVolume;
// Update the global variable in game code scope
if (typeof window.parent.parent !== 'undefined') {
window.parent.parent.musicVolume = musicVolume;
}
// Update background music volume immediately
if (!musicMuted) {
LK.playMusic('bgmusic', {
fade: {
start: musicVolume * 0.3,
end: musicVolume * 0.3,
duration: 200
}
});
}
self.updateVolumeDisplays();
return;
}
// Sound effects mute button
if (Math.abs(localPos.x - 200) < 45 && Math.abs(localPos.y - 30) < 45) {
soundMuted = !soundMuted;
storage.soundMuted = soundMuted;
// Update global mute state
window.soundMuted = soundMuted;
if (typeof window.parent !== 'undefined') {
window.parent.soundMuted = soundMuted;
}
// Play a test sound if unmuting
if (!soundMuted) {
var testSound = LK.getSound('tap');
testSound.volume = soundVolume;
testSound.play();
}
self.updateVolumeDisplays();
return;
}
// Sound volume controls
if (Math.abs(localPos.x + 150) < 30 && Math.abs(localPos.y - 30) < 30) {
soundVolume = Math.max(0, soundVolume - 0.1);
storage.soundVolume = soundVolume;
// Update global sound volume variable
window.soundVolume = soundVolume;
// Update the global variable in game scope
window.parent.soundVolume = soundVolume;
// Update the global variable in game code scope
if (typeof window.parent.parent !== 'undefined') {
window.parent.parent.soundVolume = soundVolume;
}
// Update the game scope variable
if (typeof game !== 'undefined' && game.parent) {
game.parent.soundVolume = soundVolume;
}
// Play a test sound to demonstrate volume change
if (!soundMuted) {
var testSound = LK.getSound('tap');
testSound.volume = window.soundVolume || soundVolume;
testSound.play();
}
self.updateVolumeDisplays();
return;
}
if (Math.abs(localPos.x - 150) < 30 && Math.abs(localPos.y - 30) < 30) {
soundVolume = Math.min(1, soundVolume + 0.1);
storage.soundVolume = soundVolume;
// Update global sound volume variable
window.soundVolume = soundVolume;
// Update the global variable in game scope
window.parent.soundVolume = soundVolume;
// Update the global variable in game code scope
if (typeof window.parent.parent !== 'undefined') {
window.parent.parent.soundVolume = soundVolume;
}
// Update the game scope variable
if (typeof game !== 'undefined' && game.parent) {
game.parent.soundVolume = soundVolume;
}
// Play a test sound to demonstrate volume change
if (!soundMuted) {
var testSound = LK.getSound('tap');
testSound.volume = window.soundVolume || soundVolume;
testSound.play();
}
self.updateVolumeDisplays();
return;
}
// Reset button
if (Math.abs(localPos.x) < 200 && Math.abs(localPos.y - 150) < 50) {
var confirmPanel = game.addChild(new ConfirmationPanel());
confirmPanel.x = 1024;
confirmPanel.y = 1366;
return;
}
};
return self;
});
var TapButton = Container.expand(function () {
var self = Container.call(this);
var button = self.attachAsset('tapButton', {
anchorX: 0.5,
anchorY: 0.5
});
var tapText = new Text2('TAP\nFOR $' + tapValue, {
size: 60,
fill: 0xFFFFFF
});
tapText.anchor.set(0.5, 0.5);
self.addChild(tapText);
self.updateDisplay = function () {
tapText.setText('TAP\nFOR $' + tapValue);
};
self.down = function (x, y, obj) {
money += tapValue;
updateMoneyDisplay();
if (!window.soundMuted && !soundMuted) {
var tapSound = LK.getSound('tap');
tapSound.volume = window.soundVolume || soundVolume;
tapSound.play();
}
// Enhanced button press animation with color flash
tween(button, {
tint: 0xFFFFFF
}, {
duration: 50,
onFinish: function onFinish() {
tween(button, {
tint: 0xFFFFFF
}, {
duration: 50
});
}
});
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
var floatingText = new Text2('+$' + tapValue, {
size: 40,
fill: 0x00FF00
});
floatingText.anchor.set(0.5, 0.5);
floatingText.x = x;
floatingText.y = y;
game.addChild(floatingText);
tween(floatingText, {
y: floatingText.y - 100,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
floatingText.destroy();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a252f
});
/****
* Game Code
****/
var money = storage.money || 0;
var tapValue = storage.tapValue || 1;
var prestigeMultiplier = storage.prestigeMultiplier || 1;
var totalEarned = storage.totalEarned || 0;
var prestigeCount = storage.prestigeCount || 0;
var prestigeCost = storage.prestigeCost || 1000000;
var musicVolume = storage.musicVolume || 1;
var soundVolume = storage.soundVolume || 1;
var musicMuted = storage.musicMuted || false;
var soundMuted = storage.soundMuted || false;
// Make volume variables globally accessible
window.musicVolume = musicVolume;
window.soundVolume = soundVolume;
window.musicMuted = musicMuted;
window.soundMuted = soundMuted;
// Make parent reference available for updating from settings
window.parent = {
musicVolume: musicVolume,
soundVolume: soundVolume,
musicMuted: musicMuted,
soundMuted: soundMuted
};
// Update tap value based on prestige multiplier
tapValue = Math.floor(1 * Math.pow(3, prestigeCount));
var businesses = [];
var businessData = [{
type: 'lemonadeStand',
name: 'Lemonade Stand',
cost: 10,
income: 1,
unlockRequirement: null,
synergies: ['newspaper'],
// Newspaper route helps advertise lemonade
synergyBonus: 0.1 // 10% bonus per synergy business level
}, {
type: 'newspaper',
name: 'Newspaper Route',
cost: 100,
income: 5,
unlockRequirement: {
business: 0,
level: 1
},
// Requires 1 lemonade stand
synergies: ['lemonadeStand', 'restaurant'],
// Advertises both lemonade and restaurant
synergyBonus: 0.15
}, {
type: 'carwash',
name: 'Car Wash',
cost: 500,
income: 20,
unlockRequirement: {
business: 1,
level: 2
},
// Requires 2 newspaper routes
synergies: ['restaurant'],
// Clean cars bring customers to restaurant
synergyBonus: 0.2
}, {
type: 'restaurant',
name: 'Restaurant',
cost: 2000,
income: 80,
unlockRequirement: {
business: 2,
level: 1
},
// Requires 1 car wash
synergies: ['factory'],
// Restaurant supplies factory workers
synergyBonus: 0.25
}, {
type: 'factory',
name: 'Factory',
cost: 10000,
income: 400,
unlockRequirement: {
business: 3,
level: 2
},
// Requires 2 restaurants
synergies: ['bank'],
// Factory profits go to bank
synergyBonus: 0.3
}, {
type: 'bank',
name: 'Bank',
cost: 50000,
income: 2000,
unlockRequirement: {
business: 4,
level: 1
},
// Requires 1 factory
synergies: ['tech'],
// Bank finances tech company
synergyBonus: 0.35
}, {
type: 'tech',
name: 'Tech Company',
cost: 250000,
income: 10000,
unlockRequirement: {
business: 5,
level: 1
},
// Requires 1 bank
synergies: [],
// No synergies for final business
synergyBonus: 0.4
}];
function formatNumber(num) {
if (num >= 1000000000) {
return (num / 1000000000).toFixed(1) + 'B';
} else 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 updateMoneyDisplay() {
moneyText.setText('$' + formatNumber(money));
for (var i = 0; i < businesses.length; i++) {
businesses[i].updateDisplay();
}
prestigeButton.updateDisplay();
if (tapButton.updateDisplay) {
tapButton.updateDisplay();
}
}
function calculateSynergyBonus(businessIndex) {
var business = businesses[businessIndex];
var data = businessData[businessIndex];
var synergyMultiplier = 1;
if (data.synergies && data.synergies.length > 0) {
for (var i = 0; i < data.synergies.length; i++) {
var synergyType = data.synergies[i];
for (var j = 0; j < businesses.length; j++) {
if (businessData[j].type === synergyType) {
synergyMultiplier += businesses[j].level * data.synergyBonus;
break;
}
}
}
}
return synergyMultiplier;
}
function isBusinessUnlocked(businessIndex) {
var data = businessData[businessIndex];
if (!data.unlockRequirement) return true;
var requiredBusiness = businesses[data.unlockRequirement.business];
return requiredBusiness && requiredBusiness.level >= data.unlockRequirement.level;
}
function updateIncomeDisplay() {
var totalIncome = 0;
for (var i = 0; i < businesses.length; i++) {
var baseIncome = businesses[i].income;
var synergyMultiplier = calculateSynergyBonus(i);
var finalIncome = baseIncome * synergyMultiplier * prestigeMultiplier;
totalIncome += finalIncome;
}
var prestigeText = prestigeCount > 0 ? ' (x' + prestigeMultiplier.toFixed(0) + ')' : '';
incomeText.setText('$' + formatNumber(totalIncome) + '/sec' + prestigeText);
}
var moneyText = new Text2('$' + formatNumber(money), {
size: 80,
fill: 0xF1C40F
});
moneyText.anchor.set(0.5, 0);
LK.gui.top.addChild(moneyText);
var incomeText = new Text2('$0/sec', {
size: 50,
fill: 0xE74C3C
});
incomeText.anchor.set(0.5, 0);
incomeText.y = 100;
LK.gui.top.addChild(incomeText);
var settingsButton = new Text2('⚙️', {
size: 60,
fill: 0xFFFFFF
});
settingsButton.anchor.set(1, 0);
settingsButton.x = -20;
settingsButton.y = 20;
LK.gui.topRight.addChild(settingsButton);
settingsButton.down = function (x, y, obj) {
var settingsPanel = game.addChild(new SettingsPanel());
settingsPanel.x = 1024;
settingsPanel.y = 1366;
};
var tapButton = game.addChild(new TapButton());
tapButton.x = 1024;
tapButton.y = 800;
for (var i = 0; i < businessData.length; i++) {
var business = new Business(businessData[i].type, businessData[i].name, businessData[i].cost, businessData[i].income);
business.x = 1024;
business.y = 1200 + i * 140;
// Load saved business data
var savedLevel = storage['business_' + i + '_level'] || 0;
var savedCost = storage['business_' + i + '_cost'] || businessData[i].cost;
business.level = savedLevel;
business.cost = savedCost;
business.income = businessData[i].income * savedLevel;
businesses.push(business);
game.addChild(business);
}
var prestigeButton = game.addChild(new PrestigeButton());
prestigeButton.x = 1024;
prestigeButton.y = 2500;
var winText = new Text2('TECH EMPIRE UNLOCKED!', {
size: 60,
fill: 0xFFFFFF
});
winText.anchor.set(0.5, 0.5);
winText.x = 1024;
winText.y = 1366;
winText.alpha = 0;
game.addChild(winText);
var connectionLines = [];
var backgroundElements = [];
// Create animated background elements
for (var i = 0; i < 8; i++) {
var assetTypes = ['bgCircle1', 'bgCircle2', 'bgCircle3', 'bgRect1', 'bgRect2'];
var randomAsset = assetTypes[Math.floor(Math.random() * assetTypes.length)];
var bgElement = new BackgroundElement(randomAsset, Math.random() * 2048, Math.random() * 2732, 0.2 + Math.random() * 0.8, (Math.random() - 0.5) * 0.02);
backgroundElements.push(bgElement);
game.addChild(bgElement);
}
// Update displays after loading saved data
for (var i = 0; i < businesses.length; i++) {
businesses[i].updateDisplay();
}
updateMoneyDisplay();
updateIncomeDisplay();
updateConnections();
// Play background music
if (!musicMuted) {
LK.playMusic('bgmusic', {
fade: {
start: 0,
end: musicVolume * 0.3,
duration: 2000
}
});
}
// Create gradient overlay for visual depth
var gradientOverlay = LK.getAsset('upgradeButton', {
anchorX: 0,
anchorY: 0,
scaleX: 3.5,
scaleY: 4.5
});
gradientOverlay.tint = 0x0f1419;
gradientOverlay.alpha = 0.4;
gradientOverlay.x = 0;
gradientOverlay.y = 0;
game.addChild(gradientOverlay);
function createConnectionLine(fromBusiness, toBusiness) {
var line = new Container();
var connectionShape = line.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.5
});
connectionShape.tint = 0x27ae60;
connectionShape.alpha = 0.3;
var midX = (fromBusiness.x + toBusiness.x) / 2;
var midY = (fromBusiness.y + toBusiness.y) / 2;
line.x = midX;
line.y = midY;
var angle = Math.atan2(toBusiness.y - fromBusiness.y, toBusiness.x - fromBusiness.x);
line.rotation = angle;
game.addChild(line);
connectionLines.push(line);
return line;
}
function updateConnections() {
// Clear existing connections
for (var i = 0; i < connectionLines.length; i++) {
connectionLines[i].destroy();
}
connectionLines = [];
// Create new connections based on synergies
for (var i = 0; i < businesses.length; i++) {
var business = businesses[i];
var data = businessData[i];
if (business.level > 0 && data.synergies) {
for (var j = 0; j < data.synergies.length; j++) {
var synergyType = data.synergies[j];
for (var k = 0; k < businesses.length; k++) {
if (businessData[k].type === synergyType && businesses[k].level > 0) {
var line = createConnectionLine(business, businesses[k]);
tween(line, {
alpha: 0.6
}, {
duration: 500
});
break;
}
}
}
}
}
}
var hasWon = false;
var lastIncomeUpdate = 0;
game.update = function () {
if (LK.ticks % 60 === 0) {
var totalIncome = 0;
for (var i = 0; i < businesses.length; i++) {
var baseIncome = businesses[i].income;
var synergyMultiplier = calculateSynergyBonus(i);
var finalIncome = baseIncome * synergyMultiplier * prestigeMultiplier;
totalIncome += finalIncome;
}
if (totalIncome > 0) {
money += totalIncome;
totalEarned += totalIncome;
updateMoneyDisplay();
}
if (totalIncome !== lastIncomeUpdate) {
updateIncomeDisplay();
lastIncomeUpdate = totalIncome;
}
}
// Game only ends when 5 prestiges are completed (handled in PrestigeButton)
if (LK.ticks % 300 === 0) {
storage.money = money;
storage.tapValue = tapValue;
storage.prestigeMultiplier = prestigeMultiplier;
storage.totalEarned = totalEarned;
storage.prestigeCount = prestigeCount;
storage.prestigeCost = prestigeCost;
storage.musicVolume = musicVolume;
storage.soundVolume = soundVolume;
storage.musicMuted = musicMuted;
storage.soundMuted = soundMuted;
// Save business data
for (var i = 0; i < businesses.length; i++) {
storage['business_' + i + '_level'] = businesses[i].level;
storage['business_' + i + '_cost'] = businesses[i].cost;
}
}
};
Üzerinde yazılara benzer çizgiler olan gazete. In-Game asset. 2d. High contrast. No shadows
Mavi arabayı kırmızı yıkama pompası ile yıkama logosu. In-Game asset. 2d. High contrast. No shadows
1 dolar. In-Game asset. 2d. High contrast. No shadows
Üstünde dolar logosu olan banka. In-Game asset. 2d. High contrast. No shadows
Fabrika logosu. In-Game asset. 2d. High contrast. No shadows
Restoran logosu. In-Game asset. 2d. High contrast. No shadows
teknoloji şirketi logosu. In-Game asset. 2d. High contrast. No shadows
içinde limon dilimleri, buz ve pipet olan bir limonata bardağı. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat