User prompt
dont increase the purchasing prices this much
User prompt
take the hives further from each other. add honey production effects. add more perks and display every perk's effect ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
expand the perks
User prompt
add purchaseable perks to the game.
User prompt
everything should be sold for money. not honey
User prompt
put the display to letf bottom corner
User prompt
give me a money display and display how many honey is being produced per second and how many is being jarred and how many is being sold per second
User prompt
make the images and the game's buttons and text much bigger than this
User prompt
make the bee hive look like a bee hive. make the background grass. there should be a packaging mechanism that i can upgrade which puts the honey in a jar before selling it. after that, there should be a sales dept to sell the honey and i should be able to sell the honey for free ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Timeout.tick error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.savedHives = hivesData;' Line Number: 332
Code edit (1 edits merged)
Please save this source code
User prompt
Bee Hive Tycoon
Initial prompt
we're making a tycoon game. i want a game where we have bee hives. in these bee hives, we have bees.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var BuyButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('Buy Hive\n$' + hiveCost, {
size: 48,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.update = function () {
buttonText.setText('Buy Hive\n$' + hiveCost);
if (totalHoney >= hiveCost) {
buttonGraphics.tint = 0x32CD32;
buttonGraphics.alpha = 1.0;
} else {
buttonGraphics.tint = 0x888888;
buttonGraphics.alpha = 0.7;
}
};
self.down = function (x, y, obj) {
if (totalHoney >= hiveCost && hives.length < maxHives) {
totalHoney -= hiveCost;
createNewHive();
hiveCost = Math.floor(hiveCost * 1.8);
updateHoneyDisplay();
LK.getSound('buy').play();
// Button press animation
tween(self, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
}
});
}
};
return self;
});
var Hive = Container.expand(function () {
var self = Container.call(this);
var hiveGraphics = self.attachAsset('hive', {
anchorX: 0.5,
anchorY: 1.0
});
var beeGraphics = self.attachAsset('bee', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -75
});
self.level = 1;
self.baseProduction = 1;
self.productionRate = self.baseProduction;
self.lastCollectTime = Date.now();
self.honeyAccumulated = 0;
self.upgradeCost = 50;
self.maxHoney = 100;
self.lastBeeAnimation = 0;
var honeyText = new Text2('0', {
size: 40,
fill: 0xFFFFFF
});
honeyText.anchor.set(0.5, 0.5);
honeyText.x = 0;
honeyText.y = -240;
self.addChild(honeyText);
var levelText = new Text2('Lv.1', {
size: 32,
fill: 0x000000
});
levelText.anchor.set(0.5, 0.5);
levelText.x = 0;
levelText.y = -80;
self.addChild(levelText);
self.update = function () {
var currentTime = Date.now();
var deltaTime = (currentTime - self.lastCollectTime) / 1000;
if (deltaTime > 0) {
var honeyToAdd = self.productionRate * deltaTime;
self.honeyAccumulated = Math.min(self.honeyAccumulated + honeyToAdd, self.maxHoney);
self.lastCollectTime = currentTime;
}
honeyText.setText(Math.floor(self.honeyAccumulated));
// Animate bee
if (currentTime - self.lastBeeAnimation > 2000) {
self.lastBeeAnimation = currentTime;
tween(beeGraphics, {
x: 30
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(beeGraphics, {
x: -30
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(beeGraphics, {
x: 0
}, {
duration: 1000,
easing: tween.easeInOut
});
}
});
}
});
}
// Visual feedback for honey accumulation
if (self.honeyAccumulated > 50) {
hiveGraphics.tint = 0xFFD700;
} else {
hiveGraphics.tint = 0xFFFFFF;
}
};
self.down = function (x, y, obj) {
self.collectHoney();
};
self.collectHoney = function () {
if (self.honeyAccumulated > 0) {
var collected = Math.floor(self.honeyAccumulated);
totalHoney += collected;
self.honeyAccumulated = 0;
updateHoneyDisplay();
LK.getSound('collect').play();
// Flash effect
LK.effects.flashObject(self, 0xFFFF00, 300);
// Animate collection
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 150,
onFinish: function onFinish() {
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 150
});
}
});
}
};
self.upgrade = function () {
if (totalHoney >= self.upgradeCost) {
totalHoney -= self.upgradeCost;
self.level++;
self.productionRate = self.baseProduction * self.level;
self.upgradeCost = Math.floor(self.upgradeCost * 1.5);
self.maxHoney = 100 * self.level;
levelText.setText('Lv.' + self.level);
updateHoneyDisplay();
LK.getSound('upgrade').play();
// Scale animation for upgrade
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
onFinish: function onFinish() {
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
}
});
return true;
}
return false;
};
return self;
});
var PackagingMachine = Container.expand(function () {
var self = Container.call(this);
var machineGraphics = self.attachAsset('packagingMachine', {
anchorX: 0.5,
anchorY: 1.0
});
self.level = 1;
self.packagingSpeed = 1;
self.upgradeCost = 200;
self.honeyJarsProduced = 0;
self.lastPackagingTime = Date.now();
var jarGraphics = self.attachAsset('honeyJar', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -50
});
var levelText = new Text2('Lv.1', {
size: 32,
fill: 0xFFFFFF
});
levelText.anchor.set(0.5, 0.5);
levelText.x = 0;
levelText.y = -40;
self.addChild(levelText);
var jarCountText = new Text2('0 Jars', {
size: 36,
fill: 0xFFFFFF
});
jarCountText.anchor.set(0.5, 0.5);
jarCountText.x = 0;
jarCountText.y = -160;
self.addChild(jarCountText);
self.update = function () {
var currentTime = Date.now();
var deltaTime = (currentTime - self.lastPackagingTime) / 1000;
if (deltaTime >= 2 / self.packagingSpeed && totalHoney >= 10) {
var jarsToMake = Math.floor(totalHoney / 10);
jarsToMake = Math.min(jarsToMake, self.packagingSpeed);
totalHoney -= jarsToMake * 10;
self.honeyJarsProduced += jarsToMake;
self.lastPackagingTime = currentTime;
updateHoneyDisplay();
// Animation for jar production
tween(jarGraphics, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
onFinish: function onFinish() {
tween(jarGraphics, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
}
});
}
jarCountText.setText(self.honeyJarsProduced + ' Jars');
};
self.upgrade = function () {
if (totalHoney >= self.upgradeCost) {
totalHoney -= self.upgradeCost;
self.level++;
self.packagingSpeed = self.level;
self.upgradeCost = Math.floor(self.upgradeCost * 1.6);
levelText.setText('Lv.' + self.level);
updateHoneyDisplay();
LK.getSound('upgrade').play();
// Scale animation for upgrade
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
onFinish: function onFinish() {
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
}
});
return true;
}
return false;
};
return self;
});
var SalesDepartment = Container.expand(function () {
var self = Container.call(this);
var salesGraphics = self.attachAsset('salesDept', {
anchorX: 0.5,
anchorY: 1.0
});
self.level = 1;
self.salesSpeed = 1;
self.upgradeCost = 300;
self.lastSaleTime = Date.now();
self.totalRevenue = 0;
var levelText = new Text2('Lv.1', {
size: 32,
fill: 0xFFFFFF
});
levelText.anchor.set(0.5, 0.5);
levelText.x = 0;
levelText.y = -40;
self.addChild(levelText);
var revenueText = new Text2('$0', {
size: 36,
fill: 0xFFFFFF
});
revenueText.anchor.set(0.5, 0.5);
revenueText.x = 0;
revenueText.y = -160;
self.addChild(revenueText);
self.update = function () {
var currentTime = Date.now();
var deltaTime = (currentTime - self.lastSaleTime) / 1000;
if (deltaTime >= 3 / self.salesSpeed && packagingMachine && packagingMachine.honeyJarsProduced > 0) {
var jarsToSell = Math.min(packagingMachine.honeyJarsProduced, self.salesSpeed);
var revenue = jarsToSell * 25;
packagingMachine.honeyJarsProduced -= jarsToSell;
totalMoney += revenue;
self.totalRevenue += revenue;
self.lastSaleTime = currentTime;
updateHoneyDisplay();
// Animation for sales
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 150,
onFinish: function onFinish() {
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 150
});
}
});
}
revenueText.setText('$' + self.totalRevenue);
};
self.upgrade = function () {
if (totalHoney >= self.upgradeCost) {
totalHoney -= self.upgradeCost;
self.level++;
self.salesSpeed = self.level;
self.upgradeCost = Math.floor(self.upgradeCost * 1.7);
levelText.setText('Lv.' + self.level);
updateHoneyDisplay();
LK.getSound('upgrade').play();
// Scale animation for upgrade
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
onFinish: function onFinish() {
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
}
});
return true;
}
return false;
};
return self;
});
var UpgradeButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('Upgrade', {
size: 36,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.targetHive = null;
self.update = function () {
if (self.targetHive) {
buttonText.setText('Upgrade\n$' + self.targetHive.upgradeCost);
if (totalHoney >= self.targetHive.upgradeCost) {
buttonGraphics.tint = 0x90EE90;
buttonGraphics.alpha = 1.0;
} else {
buttonGraphics.tint = 0x666666;
buttonGraphics.alpha = 0.7;
}
}
};
self.down = function (x, y, obj) {
if (self.targetHive) {
self.targetHive.upgrade();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228B22
});
/****
* Game Code
****/
var totalHoney = storage.totalHoney || 0;
var totalMoney = storage.totalMoney || 0;
var hiveCost = storage.hiveCost || 100;
var maxHives = 12;
var hives = [];
var honeyDisplay = new Text2('Honey: 0', {
size: 72,
fill: 0xFFFFFF
});
honeyDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(honeyDisplay);
honeyDisplay.y = 120;
var moneyDisplay = new Text2('Money: $0', {
size: 64,
fill: 0x90EE90
});
moneyDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(moneyDisplay);
moneyDisplay.y = 220;
var productionDisplay = new Text2('Honey/s: 0', {
size: 48,
fill: 0xFFD700
});
productionDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(productionDisplay);
productionDisplay.y = 310;
var packagingDisplay = new Text2('Jarring/s: 0', {
size: 48,
fill: 0x4682B4
});
packagingDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(packagingDisplay);
packagingDisplay.y = 380;
var salesDisplay = new Text2('Selling/s: 0', {
size: 48,
fill: 0x8A2BE2
});
salesDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(salesDisplay);
salesDisplay.y = 450;
var titleText = new Text2('Bee Hive Tycoon', {
size: 96,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0);
LK.gui.top.addChild(titleText);
titleText.y = 20;
var buyButton = game.addChild(new BuyButton());
buyButton.x = 2048 / 2;
buyButton.y = 2732 - 120;
var upgradeButtons = [];
var packagingMachine = null;
var salesDepartment = null;
var packagingUpgradeButton = null;
var salesUpgradeButton = null;
function updateHoneyDisplay() {
honeyDisplay.setText('Honey: ' + totalHoney);
moneyDisplay.setText('Money: $' + totalMoney);
// Calculate production rates
var honeyPerSecond = 0;
for (var i = 0; i < hives.length; i++) {
honeyPerSecond += hives[i].productionRate;
}
var jarringPerSecond = 0;
if (packagingMachine) {
jarringPerSecond = packagingMachine.packagingSpeed / 2; // Takes 2 seconds per jar cycle
}
var sellingPerSecond = 0;
if (salesDepartment) {
sellingPerSecond = salesDepartment.salesSpeed / 3; // Takes 3 seconds per sale cycle
}
productionDisplay.setText('Honey/s: ' + honeyPerSecond.toFixed(1));
packagingDisplay.setText('Jarring/s: ' + jarringPerSecond.toFixed(1));
salesDisplay.setText('Selling/s: ' + sellingPerSecond.toFixed(1));
storage.totalHoney = totalHoney;
storage.totalMoney = totalMoney;
storage.hiveCost = hiveCost;
}
function createNewHive() {
var hive = new Hive();
var cols = 4;
var rows = Math.ceil(maxHives / cols);
var index = hives.length;
var col = index % cols;
var row = Math.floor(index / cols);
var startX = (2048 - (cols - 1) * 400) / 2;
var startY = 600;
hive.x = startX + col * 400;
hive.y = startY + row * 440;
game.addChild(hive);
hives.push(hive);
// Create upgrade button for this hive
var upgradeBtn = new UpgradeButton();
upgradeBtn.targetHive = hive;
upgradeBtn.x = hive.x;
upgradeBtn.y = hive.y + 160;
game.addChild(upgradeBtn);
upgradeButtons.push(upgradeBtn);
}
// Create initial hive
createNewHive();
// Create packaging machine
packagingMachine = new PackagingMachine();
packagingMachine.x = 2048 / 2 - 400;
packagingMachine.y = 400;
game.addChild(packagingMachine);
// Create sales department
salesDepartment = new SalesDepartment();
salesDepartment.x = 2048 / 2 + 400;
salesDepartment.y = 400;
game.addChild(salesDepartment);
// Create upgrade buttons for packaging and sales
packagingUpgradeButton = new UpgradeButton();
packagingUpgradeButton.targetHive = packagingMachine;
packagingUpgradeButton.x = packagingMachine.x;
packagingUpgradeButton.y = packagingMachine.y + 160;
game.addChild(packagingUpgradeButton);
salesUpgradeButton = new UpgradeButton();
salesUpgradeButton.targetHive = salesDepartment;
salesUpgradeButton.x = salesDepartment.x;
salesUpgradeButton.y = salesDepartment.y + 160;
game.addChild(salesUpgradeButton);
// Load saved hives data
var savedHives = storage.savedHives || [];
for (var i = 0; i < savedHives.length; i++) {
if (i < hives.length) {
hives[i].level = savedHives[i] || 1;
hives[i].productionRate = hives[i].baseProduction * hives[i].level;
hives[i].upgradeCost = Math.pow(1.5, hives[i].level - 1) * 50;
hives[i].maxHoney = 100 * hives[i].level;
}
}
// Create additional saved hives
while (hives.length < savedHives.length && hives.length < maxHives) {
createNewHive();
var lastHive = hives[hives.length - 1];
var savedLevel = savedHives[hives.length - 1];
lastHive.level = savedLevel || 1;
lastHive.productionRate = lastHive.baseProduction * lastHive.level;
lastHive.upgradeCost = Math.pow(1.5, lastHive.level - 1) * 50;
lastHive.maxHoney = 100 * lastHive.level;
}
updateHoneyDisplay();
// Auto-save timer
var saveTimer = LK.setInterval(function () {
storage.totalHoney = totalHoney;
storage.totalMoney = totalMoney;
storage.hiveCost = hiveCost;
var hivesData = [];
for (var i = 0; i < hives.length; i++) {
hivesData.push(hives[i].level);
}
storage.savedHives = hivesData;
}, 5000);
game.update = function () {
// Auto-collect from all hives periodically
if (LK.ticks % 180 == 0) {
// Every 3 seconds
var autoCollected = 0;
for (var i = 0; i < hives.length; i++) {
if (hives[i].honeyAccumulated > 0) {
autoCollected += Math.floor(hives[i].honeyAccumulated);
hives[i].honeyAccumulated = 0;
}
}
if (autoCollected > 0) {
totalHoney += autoCollected;
updateHoneyDisplay();
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -317,9 +317,9 @@
if (deltaTime >= 3 / self.salesSpeed && packagingMachine && packagingMachine.honeyJarsProduced > 0) {
var jarsToSell = Math.min(packagingMachine.honeyJarsProduced, self.salesSpeed);
var revenue = jarsToSell * 25;
packagingMachine.honeyJarsProduced -= jarsToSell;
- totalHoney += revenue;
+ totalMoney += revenue;
self.totalRevenue += revenue;
self.lastSaleTime = currentTime;
updateHoneyDisplay();
// Animation for sales
@@ -413,8 +413,9 @@
/****
* Game Code
****/
var totalHoney = storage.totalHoney || 0;
+var totalMoney = storage.totalMoney || 0;
var hiveCost = storage.hiveCost || 100;
var maxHives = 12;
var hives = [];
var honeyDisplay = new Text2('Honey: 0', {
@@ -423,8 +424,36 @@
});
honeyDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(honeyDisplay);
honeyDisplay.y = 120;
+var moneyDisplay = new Text2('Money: $0', {
+ size: 64,
+ fill: 0x90EE90
+});
+moneyDisplay.anchor.set(0.5, 0);
+LK.gui.top.addChild(moneyDisplay);
+moneyDisplay.y = 220;
+var productionDisplay = new Text2('Honey/s: 0', {
+ size: 48,
+ fill: 0xFFD700
+});
+productionDisplay.anchor.set(0.5, 0);
+LK.gui.top.addChild(productionDisplay);
+productionDisplay.y = 310;
+var packagingDisplay = new Text2('Jarring/s: 0', {
+ size: 48,
+ fill: 0x4682B4
+});
+packagingDisplay.anchor.set(0.5, 0);
+LK.gui.top.addChild(packagingDisplay);
+packagingDisplay.y = 380;
+var salesDisplay = new Text2('Selling/s: 0', {
+ size: 48,
+ fill: 0x8A2BE2
+});
+salesDisplay.anchor.set(0.5, 0);
+LK.gui.top.addChild(salesDisplay);
+salesDisplay.y = 450;
var titleText = new Text2('Bee Hive Tycoon', {
size: 96,
fill: 0xFFD700
});
@@ -440,9 +469,27 @@
var packagingUpgradeButton = null;
var salesUpgradeButton = null;
function updateHoneyDisplay() {
honeyDisplay.setText('Honey: ' + totalHoney);
+ moneyDisplay.setText('Money: $' + totalMoney);
+ // Calculate production rates
+ var honeyPerSecond = 0;
+ for (var i = 0; i < hives.length; i++) {
+ honeyPerSecond += hives[i].productionRate;
+ }
+ var jarringPerSecond = 0;
+ if (packagingMachine) {
+ jarringPerSecond = packagingMachine.packagingSpeed / 2; // Takes 2 seconds per jar cycle
+ }
+ var sellingPerSecond = 0;
+ if (salesDepartment) {
+ sellingPerSecond = salesDepartment.salesSpeed / 3; // Takes 3 seconds per sale cycle
+ }
+ productionDisplay.setText('Honey/s: ' + honeyPerSecond.toFixed(1));
+ packagingDisplay.setText('Jarring/s: ' + jarringPerSecond.toFixed(1));
+ salesDisplay.setText('Selling/s: ' + sellingPerSecond.toFixed(1));
storage.totalHoney = totalHoney;
+ storage.totalMoney = totalMoney;
storage.hiveCost = hiveCost;
}
function createNewHive() {
var hive = new Hive();
@@ -511,8 +558,9 @@
updateHoneyDisplay();
// Auto-save timer
var saveTimer = LK.setInterval(function () {
storage.totalHoney = totalHoney;
+ storage.totalMoney = totalMoney;
storage.hiveCost = hiveCost;
var hivesData = [];
for (var i = 0; i < hives.length; i++) {
hivesData.push(hives[i].level);
Modern App Store icon, high definition, square with rounded corners, for a game titled "Bee Hive Tycoon" and with the description "Build and manage your bee hive empire in this incremental tycoon game. Collect honey, upgrade hives, and expand your apiary to create the ultimate honey production operation.". No text on icon!
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Bee Hive Tycoon" and with the description "Build and manage your bee hive empire in this incremental tycoon game. Collect honey, upgrade hives, and expand your apiary to create the ultimate honey production operation.". No text on banner!