User prompt
add customers one by one to make sure they keep distance between them
User prompt
add a gauge bar, below each player. it will decrease by time
User prompt
Please fix the bug: 'ReferenceError: safeDistance is not defined' in or related to this line: 'if (distance < safeDistance) {' Line Number: 68
User prompt
if a customer is too close to another customer when they stop moving, move it further
User prompt
mke sure there is more space between customers
User prompt
sun should move even slower
User prompt
add sun that slowly moves from right to left or left to right in the top of the screen
User prompt
for customer use randomly any of the customer assets
User prompt
create level 8 to 18 and all should be like level 7
User prompt
level 8 and up, will be the same as level 7, but will have 1 less second in the timer. So level 8 will have 19 seconds, level 9 18 seconds and so on.
User prompt
when level 7 is complete, restart level one but only with 10 seconds
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'orderAsset1')' in or related to this line: 'if (customers[i].orderBubble.orderAsset1 && customers[i].orderBubble.orderAsset1.alpha === 1) {' Line Number: 424
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'orderAsset1')' in or related to this line: 'if (customers[i].orderBubble.orderAsset1 && customers[i].orderBubble.orderAsset1.alpha === 1) {' Line Number: 424
User prompt
Reuse customer to improve performmnace
User prompt
Improve game performannce
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of null (setting 'visible')' in or related to this line: 'customer.orderBubble.visible = true;' Line Number: 353
User prompt
instead of destroying customer, re used them, and just make them invisible and have them start eh next level with ne requests
Code edit (1 edits merged)
Please save this source code
User prompt
make level up perfomnce better
User prompt
if customer dont need one of the items ,black it ouot
User prompt
Please fix the bug: 'ReferenceError: customer is not defined' in or related to this line: 'customer.levelTransitionStart = LK.ticks;' Line Number: 431
User prompt
iproove logic for interval an timwout calls
User prompt
stop timer when last customer order is complete
User prompt
do not remoe items from bottom on new level
===================================================================
--- original.js
+++ change.js
@@ -35,25 +35,17 @@
self.y = y;
self.orderBubble.alpha = 0;
LK.setTimeout(function () {
self.orderBubble.visible = true;
- self.orderBubble.alpha = 0;
- self.fadeInStart = LK.ticks;
- self.update = function () {
- var elapsed = LK.ticks - self.fadeInStart;
- if (elapsed < 10) {
- self.orderBubble.alpha = elapsed / 10;
- } else {
+ var fadeInInterval = LK.setInterval(function () {
+ if (self.orderBubble.alpha < 1) {
+ self.orderBubble.alpha += 0.1;
+ }
+ if (self.orderBubble.alpha >= 1) {
self.orderBubble.alpha = 1;
- self.update = function () {
- self.y += Math.sin(LK.ticks / 10) * 0.5;
- self.shadow.x = self.x;
- self.shadow.y = self.y + customerGraphics.height / 2;
- self.orderBubble.x = self.x;
- self.orderBubble.y = self.y - self.height / 2 - self.orderBubble.height / 2;
- };
+ LK.clearInterval(fadeInInterval);
}
- };
+ }, 100);
}, 500);
self.update = function () {
// Add small up and down movement to the customers
self.y += Math.sin(LK.ticks / 10) * 0.5;
@@ -292,19 +284,18 @@
scoreTxt.setText(score);
customer.scoreAdded = true; // Mark that score has been added for this customer
}
// Spin the customer on its axis
- customer.spinStart = LK.ticks;
- customer.update = function () {
- var elapsed = LK.ticks - customer.spinStart;
- if (elapsed < 60) {
- customer.rotation += 0.1;
- } else {
- customer.destroy();
- customer.orderBubble.destroy();
- customer.shadow.destroy();
- }
- };
+ 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
+ LK.setTimeout(function () {
+ LK.clearInterval(spinInterval);
+ customer.destroy();
+ customer.orderBubble.destroy();
+ customer.shadow.destroy();
+ }, 1000);
// Check if all orders are fulfilled
var allOrdersFulfilled = true;
for (var i = 0; i < customers.length; i++) {
if (customers[i].orderBubble.orderAsset1 && customers[i].orderBubble.orderAsset1.alpha === 1) {
@@ -352,10 +343,17 @@
return invItem.getType() === item;
});
if (inventoryItem) {
inventoryItem.visible = true;
+ inventoryItem.alpha = 1; // Make the item fully visible
}
});
+ // Black out items that are not needed by any customer
+ inventory.forEach(function (invItem) {
+ if (!order.includes(invItem.getType())) {
+ invItem.alpha = 0.5; // Dim the item
+ }
+ });
customers.push(customer);
customer.rotation = 0;
game.addChild(customer);
game.addChild(customer.shadow);
@@ -403,81 +401,83 @@
// If all orders are fulfilled, move to the next level
if (allOrdersFulfilled) {
var nextLevelIndex = levels.indexOf(currentLevel) + 1;
if (nextLevelIndex < levels.length) {
- var customer = customers[0]; // Define customer variable
- customer.levelTransitionStart = LK.ticks;
- customer.update = function () {
- var elapsed = LK.ticks - customer.levelTransitionStart;
- if (elapsed < 60) {
- if (elapsed === 1) {
- LK.getSound('nextlevel').play();
+ LK.setTimeout(function () {
+ LK.getSound('nextlevel').play(); // Play next level sound when moving to the next level
+ }, 1000);
+ LK.setTimeout(function () {
+ var levelupAsset = LK.getAsset('levelup', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+ });
+ game.addChild(levelupAsset);
+ LK.setTimeout(function () {
+ levelupAsset.destroy();
+ currentLevel = levels[nextLevelIndex];
+ // Clear current customers and items
+ for (var i = 0; i < customers.length; i++) {
+ customers[i].destroy();
}
- } else if (elapsed < 120) {
- if (elapsed === 60) {
- var levelupAsset = LK.getAsset('levelup', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 / 2,
- y: 2732 / 2
- });
- game.addChild(levelupAsset);
+ customers = [];
+ // Ensure items are always visible at the bottom of the screen
+ for (var i = 0; i < items.length; i++) {
+ items[i].visible = true;
}
- } else if (elapsed < 180) {
- if (elapsed === 120) {
- levelupAsset.destroy();
- currentLevel = levels[nextLevelIndex];
- // Clear current customers and items
- for (var i = 0; i < customers.length; i++) {
- customers[i].destroy();
- }
- customers = [];
- // Ensure items are always visible at the bottom of the screen
- for (var i = 0; i < items.length; i++) {
- items[i].visible = true;
- }
- // Create new customers for the next level
- for (var i = 0; i < currentLevel.customerCount; i++) {
- createCustomer();
- }
- // Ensure items are made visible if any customer needs that item
- customers.forEach(function (customer) {
- customer.getOrder().forEach(function (item) {
- var inventoryItem = inventory.find(function (invItem) {
- return invItem.getType() === item;
- });
- if (inventoryItem) {
- inventoryItem.visible = true;
- }
+ // Create new customers for the next level
+ for (var i = 0; i < currentLevel.customerCount; i++) {
+ createCustomer();
+ }
+ // Ensure items are made visible if any customer needs that item
+ customers.forEach(function (customer) {
+ customer.getOrder().forEach(function (item) {
+ var inventoryItem = inventory.find(function (invItem) {
+ return invItem.getType() === item;
});
- });
- // Reset timer for the new level
- levelTimer = 20;
- timeTxt.setText('Time: ' + levelTimer);
- LK.clearInterval(timerInterval);
- timerInterval = LK.setInterval(function () {
- if (levelTimer > 0) {
- levelTimer--;
- timeTxt.setText('Time: ' + levelTimer);
- } else {
- // Handle level timeout (e.g., end game or move to next level)
- LK.clearInterval(timerInterval);
- var timesupAsset = LK.getAsset('timesup', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 / 2,
- y: 2732 / 2
- });
- game.addChild(timesupAsset);
- LK.setTimeout(function () {
- timesupAsset.destroy();
- LK.showGameOver();
- }, 1000);
+ if (inventoryItem) {
+ inventoryItem.visible = true;
+ inventoryItem.alpha = 1; // Make the item fully visible
}
- }, 1000);
- }
- }
- };
+ });
+ });
+ // Black out items that are not needed by any customer
+ inventory.forEach(function (invItem) {
+ var needed = customers.some(function (customer) {
+ return customer.getOrder().includes(invItem.getType());
+ });
+ if (!needed) {
+ invItem.alpha = 0.5; // Dim the item
+ }
+ });
+ // Ensure items are always visible at the bottom of the screen
+ // Reset timer for the new level
+ levelTimer = 20;
+ timeTxt.setText('Time: ' + levelTimer);
+ LK.clearInterval(timerInterval);
+ timerInterval = LK.setInterval(function () {
+ if (levelTimer > 0) {
+ levelTimer--;
+ timeTxt.setText('Time: ' + levelTimer);
+ } else {
+ // Handle level timeout (e.g., end game or move to next level)
+ LK.clearInterval(timerInterval);
+ var timesupAsset = LK.getAsset('timesup', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+ });
+ game.addChild(timesupAsset);
+ LK.setTimeout(function () {
+ timesupAsset.destroy();
+ LK.showGameOver();
+ }, 1000);
+ }
+ }, 1000);
+ }, 1000);
+ }, 1000);
}
} else if (LK.ticks % 300 == 0) {
createCustomer();
}
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.