User prompt
allways show the 4 items in the bottom of the screen
User prompt
make sure items are made visible on level start if any customer needs that item
User prompt
refactor items creation so that they dotn blink in the beginning of every level
User prompt
Please fix the bug: 'Uncaught ReferenceError: customerGraphics is not defined' in or related to this line: 'customer.shadow.y = customer.y + customerGraphics.height / 2;' Line Number: 351
User prompt
ensure shadows are correctly positioned
User prompt
clear cache after every level
User prompt
make sure all items required are displayed in the l evel
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'type')' in or related to this line: 'if (currentLevel.items.includes(item.type)) {' Line Number: 429
User prompt
only create items once on game start and reposition or hide depending on the level needs
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of null (setting 'visible')' in or related to this line: 'customer.orderBubble.visible = false;' Line Number: 345
User prompt
reuse customers intead of destroying them
User prompt
remove redundancies
User prompt
fix how items are created each level
User prompt
improve game perfromnace without afecting the core of the game
User prompt
fix items from blinking on every level start
User prompt
Please fix the bug: 'Uncaught RangeError: Maximum call stack size exceeded' in or related to this line: 'createItemsAtBottom();' Line Number: 463
User prompt
refactor how items are created in the bottom of the screen
User prompt
improve game performance by reusing customers
User prompt
imrpove game performance by reusingcustomers
User prompt
make sure shadow is shown under customer
User prompt
Please fix the bug: 'TypeError: Cannot set properties of null (setting 'x')' in or related to this line: 'self.shadow.x = self.x;' Line Number: 54
User prompt
improve performance when a lot of customer are in screen by reusing customer
User prompt
refactor how items are recreated on level up
User prompt
fix items flickering when level up
User prompt
fix game performance
===================================================================
--- original.js
+++ change.js
@@ -286,49 +286,48 @@
// Spin the customer on its axis
var spinInterval = LK.setInterval(function () {
customer.rotation += 0.1;
}, 16.67); // Approximately 60 FPS
- // Wait for one second and then destroy the customer and order bubble
+ // Wait for one second and then reset the customer and order bubble
LK.setTimeout(function () {
LK.clearInterval(spinInterval);
- customer.destroy();
- customer.orderBubble.destroy();
- customer.shadow.destroy();
+ customer.rotation = 0;
+ customer.orderBubble.visible = false;
+ customer.shadow.visible = false;
+ customer.scoreAdded = false;
+ customer.setOrder(['towel', 'umbrella', 'refreshment', 'snack'].sort(function () {
+ return 0.5 - Math.random();
+ }).slice(0, Math.floor(Math.random() * 2) + 1));
+ customer.moveToPosition(Math.random() * (2048 * 0.8) + 2048 * 0.1, Math.random() * (2200 - 646.4) + 646.4);
}, 1000);
}
}
// Function to create a new customer
function createCustomer() {
if (customers.length >= currentLevel.customerCount) {
return;
}
- var customer = new Customer();
- var safeDistance = 500; // Minimum distance between customers
- var validPosition = false;
- while (!validPosition) {
- customer.x = Math.random() * (2048 * 0.8) + 2048 * 0.1; // Spawn customers within the middle 80% of the screen
- customer.y = Math.random() * (2200 - 646.4) + 646.4;
- validPosition = true;
- for (var i = 0; i < customers.length; i++) {
- var distance = Math.sqrt(Math.pow(customers[i].x - customer.x, 2) + Math.pow(customers[i].y - customer.y, 2));
- if (distance < safeDistance) {
- validPosition = false;
- break;
- }
- }
+ var customer = customers.find(function (c) {
+ return !c.visible;
+ });
+ if (!customer) {
+ customer = new Customer();
+ customers.push(customer);
+ game.addChild(customer);
+ game.addChild(customer.shadow);
+ game.addChild(customer.orderBubble);
}
- var order = ['towel', 'umbrella', 'refreshment', 'snack'].sort(function () {
- return 0.5 - Math.random();
- }).slice(0, Math.floor(Math.random() * 2) + 1);
- customer.setOrder(order);
- customers.push(customer);
+ customer.visible = true;
+ customer.shadow.visible = true;
+ customer.orderBubble.visible = false;
customer.rotation = 0;
- game.addChild(customer);
- game.addChild(customer.shadow);
- game.addChild(customer.orderBubble);
customer.x = Math.random() < 0.5 ? -200 : 2048 + 200; // Spawn customers from left or right side of the screen
customer.y = Math.random() * (2200 - 646.4) + 646.4;
customer.moveToPosition(Math.random() * (2048 * 0.8) + 2048 * 0.1, Math.random() * (2200 - 646.4) + 646.4);
+ var order = ['towel', 'umbrella', 'refreshment', 'snack'].sort(function () {
+ return 0.5 - Math.random();
+ }).slice(0, Math.floor(Math.random() * 2) + 1);
+ customer.setOrder(order);
}
// Function to create a new item
function createItem(type, x, y) {
if (!currentLevel.items.includes(type)) {
@@ -351,8 +350,9 @@
// Create initial customers and items
for (var i = 0; i < currentLevel.customerCount; i++) {
createCustomer();
}
+createItemsAtBottom();
// Update function
game.update = function () {
levelTxt.setText('LVL ' + currentLevel.levelNumber);
// Check if all orders are fulfilled
@@ -384,13 +384,17 @@
game.addChild(levelupAsset);
LK.setTimeout(function () {
levelupAsset.destroy();
currentLevel = levels[nextLevelIndex];
- // Clear current customers and items
+ // Hide current customers and items
for (var i = 0; i < customers.length; i++) {
- customers[i].destroy();
+ customers[i].visible = false;
+ customers[i].shadow.visible = false;
+ customers[i].orderBubble.visible = false;
}
- customers = [];
+ for (var i = 0; i < items.length; i++) {
+ items[i].visible = false;
+ }
// Create new customers for the next level
for (var i = 0; i < currentLevel.customerCount; i++) {
createCustomer();
}
@@ -422,8 +426,10 @@
}, 1000);
}, 1000);
}, 1000);
}
+ } else if (LK.ticks % 300 == 0) {
+ createCustomer();
}
};
// Function to create items at the bottom of the screen
function createItemsAtBottom() {
@@ -437,5 +443,19 @@
var spacing = (2048 - totalItems * 200) / (totalItems + 1);
for (var i = 0; i < totalItems; i++) {
createItem(currentLevel.items[i], spacing + i * (200 + spacing) + 100, 2732 - 200);
}
-}
\ No newline at end of file
+}
+var backgroundBottom = LK.getAsset('backgroundBottom', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 2048 / 2,
+ y: 2732
+});
+game.addChildAt(backgroundBottom, 0);
+var backgroundTop = LK.getAsset('backgroundTop', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: 2048 / 2,
+ y: 0
+});
+game.addChildAt(backgroundTop, 0);
\ No newline at end of file
8bit. cartoon. icecream. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon and 8 bit message. reads: Time's Up!. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8bit. cartoon. palm tree.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.