User prompt
when player clicks thhe decoration button in shop menu it buys decoration and adds decoration to the restaurant
User prompt
then fucking fix it you god damn fuckass
User prompt
whhen player clicks the decoration button, it adds decoration
User prompt
still doesnt fucking work. whhen player clicks the decoration button, it adds decoration and the button says "purchased"
User prompt
fix it
User prompt
still doesnt work
User prompt
when player clicks the Deecoration Button it adds decoration to the restaurant
User prompt
Just make the too bigger when plsyer buys the upgrade 1 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add a money giver button
User prompt
Add the cost price to button
User prompt
It costs 300$ and it makes the restaurant bigger
User prompt
Put a upgrade button named upgrade 1 on top of the restaurant
User prompt
Also remove everything when the shop panel is opened and when its closed bring them back
User prompt
Open a new menu for shop page that covers my screen
User prompt
make customer shape square
User prompt
make less customers come in
User prompt
also add food when they sit to the table right at the time
User prompt
make customer leave animation ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
when they sit to the table, add a food to the table ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make customers sit tables ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add wall to restaurant for outline
Code edit (1 edits merged)
Please save this source code
User prompt
Kendrick's Restaurant
Initial prompt
game title: Kendirck's Restaurant objective: You start a small restaurant nearby the street, you buy new things from shop by customers money. more fancy and thing you have, more people come and give you more money. mechanics: You buy new things like, Game machines, fancy tables from shop button on top right of the screen. Title
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
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 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;
});
/****
* 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 shopOpen = false;
var lastCustomerSpawn = 0;
// 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
var table1 = new Table();
table1.x = 800;
table1.y = 1200;
game.addChild(table1);
tables.push(table1);
var table2 = new Table();
table2.x = 1248;
table2.y = 1200;
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
});
// Make walls bigger too to match
tween(leftWall, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 1000
});
tween(rightWall, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 1000
});
tween(topWall, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 1000
});
tween(bottomWall, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 1000
});
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
var shopItems = [{
name: 'Fancy Table',
price: 100,
type: 'table'
}, {
name: 'Game Machine',
price: 200,
type: 'machine'
}, {
name: 'Decoration',
price: 50,
type: 'decoration'
}];
var shopButtons = [];
function createShopButtons() {
for (var i = 0; i < shopItems.length; i++) {
var item = shopItems[i];
var btn = shopPanel.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -400 + 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;
btn.down = function (x, y, obj) {
purchaseItem(obj.itemType, obj.itemPrice);
};
shopButtons.push(btn);
}
// 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();
};
}
function openShop() {
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;
}
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;
}
upgrade1Btn.visible = true;
}
});
}
function purchaseItem(type, price) {
if (money >= price) {
money -= price;
moneyTxt.setText('$' + money);
LK.getSound('purchase').play();
if (type === 'table') {
var newTable = new Table('fancyTable');
newTable.x = 600 + tables.length * 200;
newTable.y = 1000;
game.addChild(newTable);
tables.push(newTable);
restaurantQuality += 0.5;
} else if (type === 'machine') {
var newMachine = new GameMachine();
newMachine.x = 500 + gameMachines.length * 300;
newMachine.y = 800;
game.addChild(newMachine);
gameMachines.push(newMachine);
restaurantQuality += 1;
} else if (type === 'decoration') {
var newDecoration = new Decoration();
// Place decorations in visible spots around the restaurant
var decorationSpots = [{
x: 600,
y: 900
},
// Top left area
{
x: 1400,
y: 900
},
// Top right area
{
x: 400,
y: 1500
},
// Bottom left area
{
x: 1600,
y: 1500
},
// Bottom right area
{
x: 1000,
y: 850
},
// Center top
{
x: 1000,
y: 1600
} // Center bottom
];
var spotIndex = decorations.length % decorationSpots.length;
var spot = decorationSpots[spotIndex];
newDecoration.x = spot.x + (Math.random() - 0.5) * 100; // Add some randomness
newDecoration.y = spot.y + (Math.random() - 0.5) * 100;
game.addChild(newDecoration);
decorations.push(newDecoration);
restaurantQuality += 0.3;
// Add a small scale animation when decoration is placed
newDecoration.scaleX = 0.1;
newDecoration.scaleY = 0.1;
tween(newDecoration, {
scaleX: 1,
scaleY: 1
}, {
duration: 500
});
console.log("Decoration added at:", newDecoration.x, newDecoration.y, "Restaurant quality:", restaurantQuality);
}
closeShop();
}
}
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
@@ -423,11 +423,43 @@
gameMachines.push(newMachine);
restaurantQuality += 1;
} else if (type === 'decoration') {
var newDecoration = new Decoration();
- // Place decorations randomly within restaurant bounds
- newDecoration.x = 400 + Math.random() * 1200;
- newDecoration.y = 1000 + Math.random() * 600;
+ // Place decorations in visible spots around the restaurant
+ var decorationSpots = [{
+ x: 600,
+ y: 900
+ },
+ // Top left area
+ {
+ x: 1400,
+ y: 900
+ },
+ // Top right area
+ {
+ x: 400,
+ y: 1500
+ },
+ // Bottom left area
+ {
+ x: 1600,
+ y: 1500
+ },
+ // Bottom right area
+ {
+ x: 1000,
+ y: 850
+ },
+ // Center top
+ {
+ x: 1000,
+ y: 1600
+ } // Center bottom
+ ];
+ var spotIndex = decorations.length % decorationSpots.length;
+ var spot = decorationSpots[spotIndex];
+ newDecoration.x = spot.x + (Math.random() - 0.5) * 100; // Add some randomness
+ newDecoration.y = spot.y + (Math.random() - 0.5) * 100;
game.addChild(newDecoration);
decorations.push(newDecoration);
restaurantQuality += 0.3;
// Add a small scale animation when decoration is placed
@@ -438,9 +470,9 @@
scaleY: 1
}, {
duration: 500
});
- console.log("Decoration added! Restaurant quality:", restaurantQuality);
+ console.log("Decoration added at:", newDecoration.x, newDecoration.y, "Restaurant quality:", restaurantQuality);
}
closeShop();
}
}