User prompt
when premium chair are bought= +1 fancy customer when sound system is bought= +1 Customer when VIP section is bought= +2 Fancy Customer when kitchen upgrade is bought= +1 customer When add table is bought= +1 customer
User prompt
anyways remove it
User prompt
replace the fancy ground with the restaurant image asset whhen it is bought
User prompt
add a second page to shop panel, and add fancy ground button for 500$
User prompt
player cant buy the other upgrades more then once
User prompt
player can only place 5 more tables. after 5 purchase say "puchased" also make the premium chair positon lower left in restaurant
User prompt
make the table postions better. and make the premium chair position better too in restaurant. dont collide anything in restaurant
User prompt
add it to the shop after upgrade 1 is purchased
User prompt
add "more tables" button to the shop after upgrade 1
User prompt
lower the vip chair's position in restaurant
User prompt
remove the lighning kit button, and lower the premium chair's position
User prompt
remove the chef button and make the kitchhen upgrade placement position lower
User prompt
no add chef with the kitchen upgrade
User prompt
add a chef to kitchen upgrade
User prompt
make the wall placement even better when upgrade 1 is purchased
User prompt
remove the upgrade 1 button when it is purchased, also make the wall placement better when the upgrade is made
User prompt
add them to the lower right and make spaces between them
User prompt
make the VIP section position better, also make the VIP Chair position better too
User prompt
Please fix the bug: 'Uncaught TypeError: btnText.setText is not a function' in or related to this line: 'btnText.setText('PURCHASED');' Line Number: 575
User prompt
Please fix the bug: 'Uncaught TypeError: btnText.setText is not a function' in or related to this line: 'btnText.setText('ADDED!');' Line Number: 588
User prompt
Please fix the bug: 'Uncaught TypeError: btnText.setText is not a function' in or related to this line: 'btnText.setText('MONEY ADDED!');' Line Number: 602
User prompt
add give money button
User prompt
the buttons in shop menu doesnt work
User prompt
add give money button
User prompt
add new shop menu buttons and remove the old ones
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Chairs = Container.expand(function () {
var self = Container.call(this);
var chairsGraphics = self.attachAsset('chairs', {
anchorX: 0.5,
anchorY: 0.5
});
self.qualityBonus = 1.5;
return self;
});
var Chef = Container.expand(function () {
var self = Container.call(this);
var chefGraphics = self.attachAsset('chef', {
anchorX: 0.5,
anchorY: 0.5
});
self.efficiencyBonus = 2;
return self;
});
var Customer = Container.expand(function () {
var self = Container.call(this);
var customerGraphics = self.attachAsset('customer', {
anchorX: 0.5,
anchorY: 0.5
});
self.satisfaction = 1;
self.timeInRestaurant = 0;
self.maxTime = 300; // 5 seconds at 60fps
self.hasEaten = false;
self.currentTable = null;
self.update = function () {
self.timeInRestaurant++;
// Try to sit at a table if not already seated
if (!self.currentTable && self.timeInRestaurant > 30) {
for (var i = 0; i < tables.length; i++) {
var table = tables[i];
if (!table.occupied) {
self.currentTable = table;
table.occupied = true;
// Add food to table immediately when customer sits
if (!table.food) {
table.food = table.addChild(LK.getAsset('food', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -30
}));
// Make food appear with a small scale animation
table.food.scaleX = 0;
table.food.scaleY = 0;
tween(table.food, {
scaleX: 1,
scaleY: 1
}, {
duration: 500
});
}
// Move customer to table with tween animation
tween(self, {
x: table.x,
y: table.y + 100
}, {
duration: 1000
});
break;
}
}
}
if (!self.hasEaten && self.timeInRestaurant > 60 && self.currentTable) {
// Customer eats and pays (only when seated)
var payment = Math.floor(10 * restaurantQuality * self.satisfaction);
money += payment;
moneyTxt.setText('$' + money);
self.hasEaten = true;
// Customer satisfaction affects tip
if (Math.random() < restaurantQuality / 10) {
money += Math.floor(payment * 0.5);
moneyTxt.setText('$' + money);
}
}
if (self.timeInRestaurant > self.maxTime && !self.isLeaving) {
// Mark customer as leaving to prevent multiple leave animations
self.isLeaving = true;
// Customer leaves and frees up table
if (self.currentTable) {
self.currentTable.occupied = false;
// Remove food from table
if (self.currentTable.food) {
self.currentTable.food.destroy();
self.currentTable.food = null;
}
}
// Animate customer leaving the restaurant
tween(self, {
x: -200,
// Move off screen to the left
alpha: 0.5 // Fade out slightly
}, {
duration: 1500,
onFinish: function onFinish() {
// Remove from customers array and destroy after animation
for (var i = customers.length - 1; i >= 0; i--) {
if (customers[i] === self) {
customers.splice(i, 1);
break;
}
}
self.destroy();
}
});
}
};
return self;
});
var Decoration = Container.expand(function () {
var self = Container.call(this);
var decorationGraphics = self.attachAsset('decoration', {
anchorX: 0.5,
anchorY: 0.5
});
self.qualityBonus = 1;
return self;
});
var GameMachine = Container.expand(function () {
var self = Container.call(this);
var machineGraphics = self.attachAsset('gameMachine', {
anchorX: 0.5,
anchorY: 0.5
});
self.qualityBonus = 3;
return self;
});
var KitchenUpgrade = Container.expand(function () {
var self = Container.call(this);
var kitchenGraphics = self.attachAsset('kitchenUpgrade', {
anchorX: 0.5,
anchorY: 0.5
});
self.qualityBonus = 3;
return self;
});
var LightingKit = Container.expand(function () {
var self = Container.call(this);
var lightingGraphics = self.attachAsset('lightingKit', {
anchorX: 0.5,
anchorY: 0.5
});
self.qualityBonus = 2;
return self;
});
var SoundSystem = Container.expand(function () {
var self = Container.call(this);
var soundGraphics = self.attachAsset('soundSystem', {
anchorX: 0.5,
anchorY: 0.5
});
self.qualityBonus = 2.5;
return self;
});
var Table = Container.expand(function (type) {
var self = Container.call(this);
var tableGraphics = self.attachAsset(type || 'table', {
anchorX: 0.5,
anchorY: 0.5
});
self.occupied = false;
self.qualityBonus = type === 'fancyTable' ? 2 : 1;
self.food = null;
return self;
});
var VipSection = Container.expand(function () {
var self = Container.call(this);
var vipGraphics = self.attachAsset('vipSection', {
anchorX: 0.5,
anchorY: 0.5
});
self.qualityBonus = 4;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x90EE90
});
/****
* Game Code
****/
var money = 50;
var restaurantQuality = 1;
var customers = [];
var tables = [];
var gameMachines = [];
var decorations = [];
var chairs = [];
var soundSystems = [];
var lightingKits = [];
var vipSections = [];
var kitchenUpgrades = [];
var chefs = [];
var shopOpen = false;
var lastCustomerSpawn = 0;
var upgrade1Purchased = false;
var tablesPurchased = 0;
var chairsPurchased = false;
var soundPurchased = false;
var vipPurchased = false;
var kitchenPurchased = false;
var currentShopPage = 1;
var fancyGroundPurchased = false;
// Create restaurant background
var restaurant = game.addChild(LK.getAsset('restaurant', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
// Create restaurant walls for outline
var leftWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5,
x: 154,
y: 1366
}));
var rightWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5,
x: 1894,
y: 1366
}));
var topWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 796,
width: 1800,
height: 60
}));
var bottomWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1936,
width: 1800,
height: 60
}));
// Create initial tables with better spacing
var table1 = new Table();
table1.x = 600;
table1.y = 1100;
game.addChild(table1);
tables.push(table1);
var table2 = new Table();
table2.x = 1400;
table2.y = 1100;
game.addChild(table2);
tables.push(table2);
// Money display
var moneyTxt = new Text2('$' + money, {
size: 60,
fill: 0x000000
});
moneyTxt.anchor.set(0, 0);
moneyTxt.x = 150;
moneyTxt.y = 50;
LK.gui.topLeft.addChild(moneyTxt);
// Upgrade 1 button on top of restaurant
var upgrade1Btn = game.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 700
}));
var upgrade1BtnTxt = new Text2('UPGRADE 1 - $300', {
size: 30,
fill: 0xFFFFFF
});
upgrade1BtnTxt.anchor.set(0.5, 0.5);
upgrade1Btn.addChild(upgrade1BtnTxt);
upgrade1Btn.down = function (x, y, obj) {
if (money >= 300) {
money -= 300;
moneyTxt.setText('$' + money);
// Make restaurant bigger
tween(restaurant, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 1000
});
// Calculate precise wall positions for 1.5x scaled restaurant
// Restaurant center is at (1024, 1366), scaled restaurant will be 2700x1800
var scaledWidth = 1800 * 1.5; // 2700
var scaledHeight = 1200 * 1.5; // 1800
var centerX = 1024;
var centerY = 1366;
// Left wall: center - half scaled width - wall thickness/2
var leftWallX = centerX - scaledWidth / 2 - 30;
// Right wall: center + half scaled width + wall thickness/2
var rightWallX = centerX + scaledWidth / 2 + 30;
// Top wall: center - half scaled height - wall thickness/2
var topWallY = centerY - scaledHeight / 2 - 30;
// Bottom wall: center + half scaled height + wall thickness/2
var bottomWallY = centerY + scaledHeight / 2 + 30;
// Improve wall positioning and scaling for perfect alignment
tween(leftWall, {
scaleX: 1.5,
scaleY: 1.5,
x: leftWallX
}, {
duration: 1000
});
tween(rightWall, {
scaleX: 1.5,
scaleY: 1.5,
x: rightWallX
}, {
duration: 1000
});
tween(topWall, {
scaleX: 1.5,
scaleY: 1.5,
y: topWallY
}, {
duration: 1000
});
tween(bottomWall, {
scaleX: 1.5,
scaleY: 1.5,
y: bottomWallY
}, {
duration: 1000,
onFinish: function onFinish() {
// Remove the upgrade button after animation completes
upgrade1Btn.destroy();
}
});
upgrade1Purchased = true;
console.log("Restaurant upgraded!");
} else {
console.log("Not enough money - need $300");
}
};
// Shop button
var shopBtn = game.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1900,
y: 150
}));
var shopBtnTxt = new Text2('SHOP', {
size: 40,
fill: 0xFFFFFF
});
shopBtnTxt.anchor.set(0.5, 0.5);
shopBtn.addChild(shopBtnTxt);
shopBtn.down = function (x, y, obj) {
if (!shopOpen) {
openShop();
}
};
// Shop panel (initially hidden) - full screen coverage
var shopPanel = game.addChild(LK.getAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
width: 2048,
height: 2732
}));
shopPanel.visible = false;
// Shop items - Page 1
var shopItems = [{
name: 'Premium Chairs',
price: 75,
type: 'chairs'
}, {
name: 'Sound System',
price: 250,
type: 'sound'
}, {
name: 'VIP Section',
price: 400,
type: 'vip'
}, {
name: 'Kitchen Upgrade',
price: 300,
type: 'kitchen'
}, {
name: 'Give Money (+$100)',
price: 0,
type: 'money'
}];
// Shop items - Page 2
var shopItems2 = [{
name: 'Fancy Ground',
price: 500,
type: 'fancyGround'
}];
var shopButtons = [];
function createShopButtons() {
// Determine which items to show based on current page
var currentShopItems;
if (currentShopPage === 1) {
// Add More Tables to shop items if upgrade 1 is purchased
currentShopItems = shopItems.slice(); // Copy the base shop items
if (upgrade1Purchased) {
// Insert More Tables before Give Money button (which is last)
currentShopItems.splice(currentShopItems.length - 1, 0, {
name: 'More Tables',
price: 150,
type: 'tables'
});
}
} else {
currentShopItems = shopItems2.slice(); // Page 2 items
}
for (var i = 0; i < currentShopItems.length; i++) {
var item = currentShopItems[i];
var btn = shopPanel.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -300 + i * 150
}));
var btnTxt = new Text2(item.name + ' - $' + item.price, {
size: 30,
fill: 0xFFFFFF
});
btnTxt.anchor.set(0.5, 0.5);
btn.addChild(btnTxt);
btn.itemType = item.type;
btn.itemPrice = item.price;
btn.itemName = item.name;
// Use closure to capture the correct item values
// Check if item is already purchased and disable button
var isAlreadyPurchased = false;
if (item.type === 'chairs' && chairsPurchased) {
isAlreadyPurchased = true;
} else if (item.type === 'sound' && soundPurchased) {
isAlreadyPurchased = true;
} else if (item.type === 'vip' && vipPurchased) {
isAlreadyPurchased = true;
} else if (item.type === 'kitchen' && kitchenPurchased) {
isAlreadyPurchased = true;
} else if (item.type === 'tables' && tablesPurchased >= 5) {
isAlreadyPurchased = true;
} else if (item.type === 'fancyGround' && fancyGroundPurchased) {
isAlreadyPurchased = true;
}
if (isAlreadyPurchased) {
btnTxt.text = 'PURCHASED';
btn.alpha = 0.5;
btn.down = null;
} else {
btn.down = function (itemType, itemPrice) {
return function (x, y, obj) {
purchaseItem(itemType, itemPrice);
};
}(item.type, item.price);
}
shopButtons.push(btn);
}
// Navigation buttons
if (currentShopPage === 1) {
// Next page button
var nextPageBtn = shopPanel.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: 600,
color: 0x4169E1
}));
var nextPageTxt = new Text2('NEXT PAGE', {
size: 30,
fill: 0xFFFFFF
});
nextPageTxt.anchor.set(0.5, 0.5);
nextPageBtn.addChild(nextPageTxt);
nextPageBtn.down = function (x, y, obj) {
currentShopPage = 2;
// Clear existing shop buttons
for (var i = 0; i < shopButtons.length; i++) {
shopButtons[i].destroy();
}
shopButtons = [];
// Recreate shop buttons for page 2
createShopButtons();
};
shopButtons.push(nextPageBtn);
} else {
// Previous page button
var prevPageBtn = shopPanel.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 600,
color: 0x4169E1
}));
var prevPageTxt = new Text2('PREV PAGE', {
size: 30,
fill: 0xFFFFFF
});
prevPageTxt.anchor.set(0.5, 0.5);
prevPageBtn.addChild(prevPageTxt);
prevPageBtn.down = function (x, y, obj) {
currentShopPage = 1;
// Clear existing shop buttons
for (var i = 0; i < shopButtons.length; i++) {
shopButtons[i].destroy();
}
shopButtons = [];
// Recreate shop buttons for page 1
createShopButtons();
};
shopButtons.push(prevPageBtn);
}
// Close shop button
var closeBtn = shopPanel.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 700,
color: 0xFF6B6B
}));
var closeTxt = new Text2('CLOSE', {
size: 40,
fill: 0xFFFFFF
});
closeTxt.anchor.set(0.5, 0.5);
closeBtn.addChild(closeTxt);
closeBtn.down = function (x, y, obj) {
closeShop();
};
shopButtons.push(closeBtn);
}
function openShop() {
// Clear existing shop buttons
for (var i = 0; i < shopButtons.length; i++) {
shopButtons[i].destroy();
}
shopButtons = [];
// Recreate shop buttons with current upgrade status
createShopButtons();
shopOpen = true;
shopPanel.visible = true;
// Hide all game elements
restaurant.visible = false;
leftWall.visible = false;
rightWall.visible = false;
topWall.visible = false;
bottomWall.visible = false;
shopBtn.visible = false;
for (var i = 0; i < tables.length; i++) {
tables[i].visible = false;
}
for (var i = 0; i < customers.length; i++) {
customers[i].visible = false;
}
for (var i = 0; i < gameMachines.length; i++) {
gameMachines[i].visible = false;
}
for (var i = 0; i < decorations.length; i++) {
decorations[i].visible = false;
}
for (var i = 0; i < chairs.length; i++) {
chairs[i].visible = false;
}
for (var i = 0; i < soundSystems.length; i++) {
soundSystems[i].visible = false;
}
for (var i = 0; i < lightingKits.length; i++) {
lightingKits[i].visible = false;
}
for (var i = 0; i < vipSections.length; i++) {
vipSections[i].visible = false;
}
for (var i = 0; i < kitchenUpgrades.length; i++) {
kitchenUpgrades[i].visible = false;
}
for (var i = 0; i < chefs.length; i++) {
chefs[i].visible = false;
}
if (upgrade1Btn && upgrade1Btn.parent) {
upgrade1Btn.visible = false;
}
tween(shopPanel, {
alpha: 1
}, {
duration: 300
});
}
function closeShop() {
shopOpen = false;
tween(shopPanel, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
shopPanel.visible = false;
// Show all game elements when shop closes
restaurant.visible = true;
leftWall.visible = true;
rightWall.visible = true;
topWall.visible = true;
bottomWall.visible = true;
shopBtn.visible = true;
for (var i = 0; i < tables.length; i++) {
tables[i].visible = true;
}
for (var i = 0; i < customers.length; i++) {
customers[i].visible = true;
}
for (var i = 0; i < gameMachines.length; i++) {
gameMachines[i].visible = true;
}
for (var i = 0; i < decorations.length; i++) {
decorations[i].visible = true;
}
for (var i = 0; i < chairs.length; i++) {
chairs[i].visible = true;
}
for (var i = 0; i < soundSystems.length; i++) {
soundSystems[i].visible = true;
}
for (var i = 0; i < lightingKits.length; i++) {
lightingKits[i].visible = true;
}
for (var i = 0; i < vipSections.length; i++) {
vipSections[i].visible = true;
}
for (var i = 0; i < kitchenUpgrades.length; i++) {
kitchenUpgrades[i].visible = true;
}
for (var i = 0; i < chefs.length; i++) {
chefs[i].visible = true;
}
if (upgrade1Btn && upgrade1Btn.parent) {
upgrade1Btn.visible = true;
}
}
});
}
function purchaseItem(type, price) {
// Check if item is already purchased (except for lighting, money, and tables)
if (type === 'chairs' && chairsPurchased) {
console.log("Chairs already purchased!");
return;
}
if (type === 'sound' && soundPurchased) {
console.log("Sound system already purchased!");
return;
}
if (type === 'vip' && vipPurchased) {
console.log("VIP section already purchased!");
return;
}
if (type === 'kitchen' && kitchenPurchased) {
console.log("Kitchen upgrade already purchased!");
return;
}
if (type === 'fancyGround' && fancyGroundPurchased) {
console.log("Fancy ground already purchased!");
return;
}
if (money >= price) {
money -= price;
moneyTxt.setText('$' + money);
LK.getSound('purchase').play();
if (type === 'chairs') {
var newChairs = new Chairs();
newChairs.x = 300 + chairs.length * 200;
newChairs.y = 1700;
game.addChild(newChairs);
chairs.push(newChairs);
restaurantQuality += 0.7;
chairsPurchased = true;
} else if (type === 'sound') {
var newSoundSystem = new SoundSystem();
newSoundSystem.x = 300 + soundSystems.length * 200;
newSoundSystem.y = 850;
game.addChild(newSoundSystem);
soundSystems.push(newSoundSystem);
restaurantQuality += 1.2;
soundPurchased = true;
} else if (type === 'lighting') {
var newLighting = new LightingKit();
newLighting.x = 600 + lightingKits.length * 300;
newLighting.y = 950;
game.addChild(newLighting);
lightingKits.push(newLighting);
restaurantQuality += 1;
// Add lighting effect
LK.effects.flashObject(newLighting, 0xFFFF00, 2000);
} else if (type === 'vip') {
var newVip = new VipSection();
newVip.x = 1600;
newVip.y = 1600;
game.addChild(newVip);
vipSections.push(newVip);
restaurantQuality += 2;
// Add VIP chair next to the VIP section with proper spacing
var vipChair = new Chairs();
vipChair.x = 1300;
vipChair.y = 1500;
game.addChild(vipChair);
chairs.push(vipChair);
vipPurchased = true;
} else if (type === 'kitchen') {
var newKitchen = new KitchenUpgrade();
newKitchen.x = 1024;
newKitchen.y = 1000;
game.addChild(newKitchen);
kitchenUpgrades.push(newKitchen);
restaurantQuality += 1.5;
// Add chef automatically with kitchen upgrade
var newChef = new Chef();
newChef.x = 1024 + chefs.length * 150;
newChef.y = 1100;
game.addChild(newChef);
chefs.push(newChef);
restaurantQuality += 1.0;
kitchenPurchased = true;
} else if (type === 'tables') {
if (tablesPurchased < 5) {
var newTable = new Table();
newTable.x = 400 + (tables.length - 2) * 350;
newTable.y = 1350;
game.addChild(newTable);
tables.push(newTable);
restaurantQuality += 0.5;
tablesPurchased++;
}
} else if (type === 'fancyGround') {
// Create fancy ground tiles across the restaurant floor
for (var i = 0; i < 6; i++) {
for (var j = 0; j < 4; j++) {
var groundTile = game.addChild(LK.getAsset('fancyGround', {
anchorX: 0.5,
anchorY: 0.5,
x: 400 + i * 200,
y: 1000 + j * 200
}));
groundTile.alpha = 0.7; // Make it semi-transparent so it doesn't interfere with other elements
}
}
restaurantQuality += 1.5;
fancyGroundPurchased = true;
} else if (type === 'money') {
money += 100;
moneyTxt.setText('$' + money);
}
// Update button text to show "PURCHASED" for all items except lighting, money, and tables (which can be bought multiple times)
if (type !== 'lighting' && type !== 'money' && type !== 'tables') {
for (var i = 0; i < shopButtons.length; i++) {
var btn = shopButtons[i];
if (btn.itemType === type) {
var btnText = btn.children[0]; // Get the text child
btnText.text = 'PURCHASED';
btn.alpha = 0.5; // Make button look disabled
btn.down = null; // Remove click handler
break;
}
}
} else if (type === 'tables' && tablesPurchased >= 5) {
// Handle tables purchase limit
for (var i = 0; i < shopButtons.length; i++) {
var btn = shopButtons[i];
if (btn.itemType === 'tables') {
var btnText = btn.children[0];
btnText.text = 'PURCHASED';
btn.alpha = 0.5;
btn.down = null;
break;
}
}
} else if (type === 'lighting') {
// For lighting, temporarily show feedback on the button
for (var i = 0; i < shopButtons.length; i++) {
var btn = shopButtons[i];
if (btn.itemType === 'lighting') {
var btnText = btn.children[0];
var originalText = btnText.text;
btnText.text = 'ADDED!';
LK.setTimeout(function () {
btnText.text = originalText;
}, 1000);
break;
}
}
} else if (type === 'money') {
// For money button, show feedback animation
for (var i = 0; i < shopButtons.length; i++) {
var btn = shopButtons[i];
if (btn.itemType === 'money') {
var btnText = btn.children[0];
var originalText = btnText.text;
btnText.text = 'MONEY ADDED!';
LK.setTimeout(function () {
btnText.text = originalText;
}, 1000);
break;
}
}
}
// Don't close shop immediately - let player continue shopping
console.log("Item purchased successfully!");
} else {
console.log("Not enough money for " + type + " - need $" + price);
}
}
function spawnCustomer() {
if (customers.length < Math.floor(restaurantQuality * 2) + 2) {
var customer = new Customer();
customer.x = -100;
customer.y = 1400 + Math.random() * 200;
customer.satisfaction = Math.min(restaurantQuality / 5, 2);
game.addChild(customer);
customers.push(customer);
LK.getSound('customerEnter').play();
// Move customer into restaurant
tween(customer, {
x: 200 + Math.random() * 1600
}, {
duration: 2000
});
}
}
createShopButtons();
game.update = function () {
// Spawn customers based on restaurant quality
var spawnRate = Math.max(300 - restaurantQuality * 20, 240);
if (LK.ticks - lastCustomerSpawn > spawnRate) {
spawnCustomer();
lastCustomerSpawn = LK.ticks;
}
// Update customer satisfaction based on restaurant items
for (var i = 0; i < customers.length; i++) {
var customer = customers[i];
var nearbyQuality = 1;
// Check proximity to tables
for (var j = 0; j < tables.length; j++) {
var table = tables[j];
var distance = Math.sqrt((customer.x - table.x) * (customer.x - table.x) + (customer.y - table.y) * (customer.y - table.y));
if (distance < 300) {
nearbyQuality += table.qualityBonus * 0.1;
}
}
// Check proximity to game machines
for (var k = 0; k < gameMachines.length; k++) {
var machine = gameMachines[k];
var distance = Math.sqrt((customer.x - machine.x) * (customer.x - machine.x) + (customer.y - machine.y) * (customer.y - machine.y));
if (distance < 400) {
nearbyQuality += machine.qualityBonus * 0.1;
}
}
customer.satisfaction = Math.min(customer.satisfaction * nearbyQuality, 3);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -214,8 +214,10 @@
var chairsPurchased = false;
var soundPurchased = false;
var vipPurchased = false;
var kitchenPurchased = false;
+var currentShopPage = 1;
+var fancyGroundPurchased = false;
// Create restaurant background
var restaurant = game.addChild(LK.getAsset('restaurant', {
anchorX: 0.5,
anchorY: 0.5,
@@ -375,9 +377,9 @@
width: 2048,
height: 2732
}));
shopPanel.visible = false;
-// Shop items
+// Shop items - Page 1
var shopItems = [{
name: 'Premium Chairs',
price: 75,
type: 'chairs'
@@ -397,19 +399,31 @@
name: 'Give Money (+$100)',
price: 0,
type: 'money'
}];
+// Shop items - Page 2
+var shopItems2 = [{
+ name: 'Fancy Ground',
+ price: 500,
+ type: 'fancyGround'
+}];
var shopButtons = [];
function createShopButtons() {
- // Add More Tables to shop items if upgrade 1 is purchased
- var currentShopItems = shopItems.slice(); // Copy the base shop items
- if (upgrade1Purchased) {
- // Insert More Tables before Give Money button (which is last)
- currentShopItems.splice(currentShopItems.length - 1, 0, {
- name: 'More Tables',
- price: 150,
- type: 'tables'
- });
+ // Determine which items to show based on current page
+ var currentShopItems;
+ if (currentShopPage === 1) {
+ // Add More Tables to shop items if upgrade 1 is purchased
+ currentShopItems = shopItems.slice(); // Copy the base shop items
+ if (upgrade1Purchased) {
+ // Insert More Tables before Give Money button (which is last)
+ currentShopItems.splice(currentShopItems.length - 1, 0, {
+ name: 'More Tables',
+ price: 150,
+ type: 'tables'
+ });
+ }
+ } else {
+ currentShopItems = shopItems2.slice(); // Page 2 items
}
for (var i = 0; i < currentShopItems.length; i++) {
var item = currentShopItems[i];
var btn = shopPanel.addChild(LK.getAsset('upgradeButton', {
@@ -439,8 +453,10 @@
} else if (item.type === 'kitchen' && kitchenPurchased) {
isAlreadyPurchased = true;
} else if (item.type === 'tables' && tablesPurchased >= 5) {
isAlreadyPurchased = true;
+ } else if (item.type === 'fancyGround' && fancyGroundPurchased) {
+ isAlreadyPurchased = true;
}
if (isAlreadyPurchased) {
btnTxt.text = 'PURCHASED';
btn.alpha = 0.5;
@@ -453,8 +469,62 @@
}(item.type, item.price);
}
shopButtons.push(btn);
}
+ // Navigation buttons
+ if (currentShopPage === 1) {
+ // Next page button
+ var nextPageBtn = shopPanel.addChild(LK.getAsset('upgradeButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 200,
+ y: 600,
+ color: 0x4169E1
+ }));
+ var nextPageTxt = new Text2('NEXT PAGE', {
+ size: 30,
+ fill: 0xFFFFFF
+ });
+ nextPageTxt.anchor.set(0.5, 0.5);
+ nextPageBtn.addChild(nextPageTxt);
+ nextPageBtn.down = function (x, y, obj) {
+ currentShopPage = 2;
+ // Clear existing shop buttons
+ for (var i = 0; i < shopButtons.length; i++) {
+ shopButtons[i].destroy();
+ }
+ shopButtons = [];
+ // Recreate shop buttons for page 2
+ createShopButtons();
+ };
+ shopButtons.push(nextPageBtn);
+ } else {
+ // Previous page button
+ var prevPageBtn = shopPanel.addChild(LK.getAsset('upgradeButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -200,
+ y: 600,
+ color: 0x4169E1
+ }));
+ var prevPageTxt = new Text2('PREV PAGE', {
+ size: 30,
+ fill: 0xFFFFFF
+ });
+ prevPageTxt.anchor.set(0.5, 0.5);
+ prevPageBtn.addChild(prevPageTxt);
+ prevPageBtn.down = function (x, y, obj) {
+ currentShopPage = 1;
+ // Clear existing shop buttons
+ for (var i = 0; i < shopButtons.length; i++) {
+ shopButtons[i].destroy();
+ }
+ shopButtons = [];
+ // Recreate shop buttons for page 1
+ createShopButtons();
+ };
+ shopButtons.push(prevPageBtn);
+ }
// Close shop button
var closeBtn = shopPanel.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
@@ -470,8 +540,9 @@
closeBtn.addChild(closeTxt);
closeBtn.down = function (x, y, obj) {
closeShop();
};
+ shopButtons.push(closeBtn);
}
function openShop() {
// Clear existing shop buttons
for (var i = 0; i < shopButtons.length; i++) {
@@ -596,8 +667,12 @@
if (type === 'kitchen' && kitchenPurchased) {
console.log("Kitchen upgrade already purchased!");
return;
}
+ if (type === 'fancyGround' && fancyGroundPurchased) {
+ console.log("Fancy ground already purchased!");
+ return;
+ }
if (money >= price) {
money -= price;
moneyTxt.setText('$' + money);
LK.getSound('purchase').play();
@@ -664,8 +739,23 @@
tables.push(newTable);
restaurantQuality += 0.5;
tablesPurchased++;
}
+ } else if (type === 'fancyGround') {
+ // Create fancy ground tiles across the restaurant floor
+ for (var i = 0; i < 6; i++) {
+ for (var j = 0; j < 4; j++) {
+ var groundTile = game.addChild(LK.getAsset('fancyGround', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 400 + i * 200,
+ y: 1000 + j * 200
+ }));
+ groundTile.alpha = 0.7; // Make it semi-transparent so it doesn't interfere with other elements
+ }
+ }
+ restaurantQuality += 1.5;
+ fancyGroundPurchased = true;
} else if (type === 'money') {
money += 100;
moneyTxt.setText('$' + money);
}