User prompt
wait for 1 second before showing levelup asset
User prompt
do not flicker items on bottom when a level starts
User prompt
add level up asset for 2 seconds when level up
User prompt
add alpha to bckgourund
User prompt
when level up wait for one second before playing music
Code edit (1 edits merged)
Please save this source code
User prompt
make icons int he bottom of the screen 30% bigger
Code edit (1 edits merged)
Please save this source code
User prompt
use game over sound when times up is shown
User prompt
show times up message for 2 seconds before game over. also when times up message is on, customers are not clickable anymore
User prompt
disable touch on screen when time is up
User prompt
if game over because time is over, then show asset timesup for one second and then game over
User prompt
set initial timer to 20
User prompt
time should start at 20 seconds
User prompt
make font more square
User prompt
remove background music
User prompt
play next level sound when moving to next level
User prompt
play backgroundmusic on game start
User prompt
play ordercomplete sound when an order is complete
User prompt
play tap sound when the customer or items are touched
User prompt
Please fix the bug: 'ReferenceError: backgroundMusic is not defined' in or related to this line: 'if (!backgroundMusic.playing) {' Line Number: 218
Code edit (1 edits merged)
Please save this source code
User prompt
make sure items in the bottom are equidistant from each other and the edge of the screen
User prompt
instead of diming an item when is selected in the bottom of the screen, increase its size
User prompt
items should not be dimmed
/**** * Classes ****/ // Customer class var Customer = Container.expand(function () { var self = Container.call(this); var customerGraphics = self.attachAsset('customer', { anchorX: 0.5, anchorY: 0.5 }); self.shadow = LK.getAsset('shadow', { anchorX: 0.5, anchorY: 0 }); self.shadow.y = customerGraphics.height / 2; self.shadow.alpha = 0.5; self.orderBubble = null; self.gaugeBar = null; self.moveToPosition = function (x, y) { var distance = Math.sqrt(Math.pow(self.x - x, 2) + Math.pow(self.y - y, 2)); var speed = distance / 120; // 60 frames per second var dx = (x - self.x) / distance * speed; var dy = (y - self.y) / distance * speed; self.update = function () { if (Math.abs(self.x - x) > speed || Math.abs(self.y - y) > speed) { self.x += dx; self.y += dy; self.orderBubble.visible = false; 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; } else { self.x = x; self.y = y; self.orderBubble.alpha = 0; LK.setTimeout(function () { self.orderBubble.visible = true; var fadeInInterval = LK.setInterval(function () { if (self.orderBubble.alpha < 1) { self.orderBubble.alpha += 0.1; } if (self.orderBubble.alpha >= 1) { self.orderBubble.alpha = 1; 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; 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; }; } }; }; self.setOrder = function (order) { if (self.orderBubble) { self.removeChild(self.orderBubble); } // Filter the order to only include items available in the current level self.order = Array.isArray(order) ? order.filter(function (item) { return currentLevel.items.includes(item); }) : [order]; // Ensure that all customers have at least one item in their order if (self.order.length === 0) { self.order.push(currentLevel.items[Math.floor(Math.random() * currentLevel.items.length)]); } self.orderBubble = new OrderBubble(self.order); self.orderBubble.x = 0; self.orderBubble.y = -self.height / 2 - self.orderBubble.height / 2; if (!self.orderBubble.visible) { self.orderBubble.visible = false; // Hide order bubble on game start } self.addChild(self.orderBubble); self.update = function () { // Add small up and down movement to the customers self.y += Math.sin(LK.ticks / 10) * 0.5; }; }; self.getOrder = function () { return self.order; }; self.on('down', function (x, y, obj) { if (self.orderBubble && !self.orderBubble.visible) { self.orderBubble.visible = true; } if (selectedItem && self.order.includes(selectedItem.getType())) { // Dim the item in the order bubble // if (self.orderBubble.orderAsset1 && self.orderBubble.orderAsset1.type === selectedItem.getType()) { // self.orderBubble.orderAsset1.alpha = 0.5; // } // if (self.orderBubble.orderAsset2 && self.orderBubble.orderAsset2.type === selectedItem.getType()) { // self.orderBubble.orderAsset2.alpha = 0.5; // } // Check if the order is fulfilled checkOrderFulfillment(self); } }); }); // Item class var Item = Container.expand(function (type) { var self = Container.call(this); var itemGraphics = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5 }); self.type = type; self.getType = function () { return self.type; }; // self.alpha = 0.5; // Start items as dimmed self.on('down', function (x, y, obj) { if (selectedItem) { selectedItem.scaleX = 1; selectedItem.scaleY = 1; // selectedItem.alpha = 0.5; // Dim the previously selected item } selectedItem = self; console.log("Item selected:", self.type); self.scaleX = 1.2; self.scaleY = 1.2; // self.alpha = 1; // Undim the selected item }); }); // OrderBubble class var OrderBubble = Container.expand(function (order) { var self = Container.call(this); var bubbleGraphics = self.attachAsset('bubble', { anchorX: 0.5, anchorY: 0.5 }); self.order = order; if (Array.isArray(order)) { if (order.length > 0) { self.orderAsset1 = self.attachAsset(order[0], { anchorX: 0.5, anchorY: 0.5 }); self.orderAsset1.type = order[0]; self.orderAsset1.x = order.length > 1 ? -60 : 0; self.orderAsset1.y -= 20; } if (order.length > 1) { self.orderAsset2 = self.attachAsset(order[1], { anchorX: 0.5, anchorY: 0.5 }); self.orderAsset2.type = order[1]; self.orderAsset2.x = 60; self.orderAsset2.y -= 20; } } else { self.orderAsset = self.attachAsset(order, { anchorX: 0.5, anchorY: 0.5 }); self.orderAsset.x = 0; self.orderAsset.y -= 20; } }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Init game with sky blue background }); /**** * Game Code ****/ var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(background); var backgroundTop = LK.getAsset('backgroundTop', { anchorX: 0.5, anchorY: 0, x: 2048 / 2, y: 0, alpha: 0.5 // Set alpha to 0.5 }); game.addChild(backgroundTop); var backgroundBottom = LK.getAsset('backgroundBottom', { anchorX: 0.5, anchorY: 1, x: 2048 / 2, y: 2732, alpha: 0.5 // Set alpha to 0.5 }); game.addChild(backgroundBottom); // Level class //<Assets used in the game will automatically appear here> // Initialize arrays and variables var Level = function Level(levelNumber, customerCount, items) { this.levelNumber = levelNumber; this.customerCount = customerCount; this.items = items; }; var selectedItem = null; // Variable to track the currently selected item var currentLevel = null; // Variable to track the current level var customers = []; var items = []; var inventory = []; // Inventory array to hold all items from the bar var score = 0; var scoreTxt = new Text2('0', { size: 90, fill: "#ffffff", stroke: "#000000", strokeThickness: 5 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var levelTxt = new Text2('LVL 1', { size: 80, fill: "#ffffff", stroke: "#000000", strokeThickness: 5 }); levelTxt.anchor.set(0, 0); LK.gui.topLeft.addChild(levelTxt); var timeTxt = new Text2('Time: 60', { size: 80, fill: "#ffffff", stroke: "#000000", strokeThickness: 5 }); timeTxt.anchor.set(1, 0); LK.gui.topRight.addChild(timeTxt); var levelTimer = 60; // Initialize level timer to 60 seconds var 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); LK.showGameOver(); } }, 1000); // Function to check if all items of an order are delivered function checkOrderFulfillment(customer) { // Check if all items are dimmed var allDimmed = true; if (customer.orderBubble.orderAsset1 && customer.orderBubble.orderAsset1.alpha === 1) { allDimmed = false; } if (customer.orderBubble.orderAsset2 && customer.orderBubble.orderAsset2.alpha === 1) { allDimmed = false; } if (allDimmed) { // Increase score only if it hasn't been increased for this customer if (!customer.scoreAdded) { score += 10; scoreTxt.setText(score); customer.scoreAdded = true; // Mark that score has been added for this customer } // 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 LK.setTimeout(function () { LK.clearInterval(spinInterval); customer.destroy(); customer.orderBubble.destroy(); customer.shadow.destroy(); }, 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 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.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); } // Function to create a new item function createItem(type, x, y) { if (!currentLevel.items.includes(type)) { return; } var item = new Item(type); item.x = x; item.y = y; item.width = 200; item.height = 200; items.push(item); inventory.push(item); // Add item to inventory array item.visible = true; // Show item on game start game.addChild(item); } // Initialize level data var levels = [new Level(1, 3, ['towel', 'umbrella']), new Level(2, 4, ['towel', 'umbrella', 'refreshment']), new Level(3, 5, ['towel', 'umbrella', 'refreshment', 'snack']), new Level(4, 6, ['towel', 'umbrella', 'refreshment', 'snack']), new Level(5, 7, ['towel', 'umbrella', 'refreshment', 'snack']), new Level(6, 8, ['towel', 'umbrella', 'refreshment', 'snack']), new Level(7, 9, ['towel', 'umbrella', 'refreshment', 'snack'])]; currentLevel = levels[0]; // Create initial customers for (var i = 0; i < currentLevel.customerCount; i++) { createCustomer(); } // Update function game.update = function () { levelTxt.setText('LVL ' + currentLevel.levelNumber); // 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) { allOrdersFulfilled = false; break; } if (customers[i].orderBubble.orderAsset2 && customers[i].orderBubble.orderAsset2.alpha === 1) { allOrdersFulfilled = false; break; } } // If all orders are fulfilled, move to the next level if (allOrdersFulfilled) { var nextLevelIndex = levels.indexOf(currentLevel) + 1; if (nextLevelIndex < levels.length) { LK.setTimeout(function () { currentLevel = levels[nextLevelIndex]; // Clear current customers and items for (var i = 0; i < customers.length; i++) { customers[i].destroy(); } customers = []; for (var i = 0; i < items.length; i++) { items[i].destroy(); } items = []; // Create new customers and items for the next level for (var i = 0; i < currentLevel.customerCount; i++) { createCustomer(); } var totalItems = currentLevel.items.length; var startingPoint = (2048 - totalItems * 250) / 2; for (var i = 0; i < totalItems; i++) { createItem(currentLevel.items[i], startingPoint + i * 250, 2732 - 200); } // Reset timer for the new level levelTimer = 60; 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); LK.showGameOver(); } }, 1000); }, 1000); } } else if (LK.ticks % 300 == 0) { createCustomer(); } }; // Create initial items for (var i = 0; i < currentLevel.items.length; i++) { createItem(currentLevel.items[i], 2048 / 2 - 500 + i * 250, 2732 - 200); } 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);
/****
* Classes
****/
// Customer class
var Customer = Container.expand(function () {
var self = Container.call(this);
var customerGraphics = self.attachAsset('customer', {
anchorX: 0.5,
anchorY: 0.5
});
self.shadow = LK.getAsset('shadow', {
anchorX: 0.5,
anchorY: 0
});
self.shadow.y = customerGraphics.height / 2;
self.shadow.alpha = 0.5;
self.orderBubble = null;
self.gaugeBar = null;
self.moveToPosition = function (x, y) {
var distance = Math.sqrt(Math.pow(self.x - x, 2) + Math.pow(self.y - y, 2));
var speed = distance / 120; // 60 frames per second
var dx = (x - self.x) / distance * speed;
var dy = (y - self.y) / distance * speed;
self.update = function () {
if (Math.abs(self.x - x) > speed || Math.abs(self.y - y) > speed) {
self.x += dx;
self.y += dy;
self.orderBubble.visible = false;
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;
} else {
self.x = x;
self.y = y;
self.orderBubble.alpha = 0;
LK.setTimeout(function () {
self.orderBubble.visible = true;
var fadeInInterval = LK.setInterval(function () {
if (self.orderBubble.alpha < 1) {
self.orderBubble.alpha += 0.1;
}
if (self.orderBubble.alpha >= 1) {
self.orderBubble.alpha = 1;
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;
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;
};
}
};
};
self.setOrder = function (order) {
if (self.orderBubble) {
self.removeChild(self.orderBubble);
}
// Filter the order to only include items available in the current level
self.order = Array.isArray(order) ? order.filter(function (item) {
return currentLevel.items.includes(item);
}) : [order];
// Ensure that all customers have at least one item in their order
if (self.order.length === 0) {
self.order.push(currentLevel.items[Math.floor(Math.random() * currentLevel.items.length)]);
}
self.orderBubble = new OrderBubble(self.order);
self.orderBubble.x = 0;
self.orderBubble.y = -self.height / 2 - self.orderBubble.height / 2;
if (!self.orderBubble.visible) {
self.orderBubble.visible = false; // Hide order bubble on game start
}
self.addChild(self.orderBubble);
self.update = function () {
// Add small up and down movement to the customers
self.y += Math.sin(LK.ticks / 10) * 0.5;
};
};
self.getOrder = function () {
return self.order;
};
self.on('down', function (x, y, obj) {
if (self.orderBubble && !self.orderBubble.visible) {
self.orderBubble.visible = true;
}
if (selectedItem && self.order.includes(selectedItem.getType())) {
// Dim the item in the order bubble
// if (self.orderBubble.orderAsset1 && self.orderBubble.orderAsset1.type === selectedItem.getType()) {
// self.orderBubble.orderAsset1.alpha = 0.5;
// }
// if (self.orderBubble.orderAsset2 && self.orderBubble.orderAsset2.type === selectedItem.getType()) {
// self.orderBubble.orderAsset2.alpha = 0.5;
// }
// Check if the order is fulfilled
checkOrderFulfillment(self);
}
});
});
// Item class
var Item = Container.expand(function (type) {
var self = Container.call(this);
var itemGraphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.type = type;
self.getType = function () {
return self.type;
};
// self.alpha = 0.5; // Start items as dimmed
self.on('down', function (x, y, obj) {
if (selectedItem) {
selectedItem.scaleX = 1;
selectedItem.scaleY = 1;
// selectedItem.alpha = 0.5; // Dim the previously selected item
}
selectedItem = self;
console.log("Item selected:", self.type);
self.scaleX = 1.2;
self.scaleY = 1.2;
// self.alpha = 1; // Undim the selected item
});
});
// OrderBubble class
var OrderBubble = Container.expand(function (order) {
var self = Container.call(this);
var bubbleGraphics = self.attachAsset('bubble', {
anchorX: 0.5,
anchorY: 0.5
});
self.order = order;
if (Array.isArray(order)) {
if (order.length > 0) {
self.orderAsset1 = self.attachAsset(order[0], {
anchorX: 0.5,
anchorY: 0.5
});
self.orderAsset1.type = order[0];
self.orderAsset1.x = order.length > 1 ? -60 : 0;
self.orderAsset1.y -= 20;
}
if (order.length > 1) {
self.orderAsset2 = self.attachAsset(order[1], {
anchorX: 0.5,
anchorY: 0.5
});
self.orderAsset2.type = order[1];
self.orderAsset2.x = 60;
self.orderAsset2.y -= 20;
}
} else {
self.orderAsset = self.attachAsset(order, {
anchorX: 0.5,
anchorY: 0.5
});
self.orderAsset.x = 0;
self.orderAsset.y -= 20;
}
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Init game with sky blue background
});
/****
* Game Code
****/
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
game.addChild(background);
var backgroundTop = LK.getAsset('backgroundTop', {
anchorX: 0.5,
anchorY: 0,
x: 2048 / 2,
y: 0,
alpha: 0.5 // Set alpha to 0.5
});
game.addChild(backgroundTop);
var backgroundBottom = LK.getAsset('backgroundBottom', {
anchorX: 0.5,
anchorY: 1,
x: 2048 / 2,
y: 2732,
alpha: 0.5 // Set alpha to 0.5
});
game.addChild(backgroundBottom);
// Level class
//<Assets used in the game will automatically appear here>
// Initialize arrays and variables
var Level = function Level(levelNumber, customerCount, items) {
this.levelNumber = levelNumber;
this.customerCount = customerCount;
this.items = items;
};
var selectedItem = null; // Variable to track the currently selected item
var currentLevel = null; // Variable to track the current level
var customers = [];
var items = [];
var inventory = []; // Inventory array to hold all items from the bar
var score = 0;
var scoreTxt = new Text2('0', {
size: 90,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 5
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var levelTxt = new Text2('LVL 1', {
size: 80,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 5
});
levelTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(levelTxt);
var timeTxt = new Text2('Time: 60', {
size: 80,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 5
});
timeTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(timeTxt);
var levelTimer = 60; // Initialize level timer to 60 seconds
var 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);
LK.showGameOver();
}
}, 1000);
// Function to check if all items of an order are delivered
function checkOrderFulfillment(customer) {
// Check if all items are dimmed
var allDimmed = true;
if (customer.orderBubble.orderAsset1 && customer.orderBubble.orderAsset1.alpha === 1) {
allDimmed = false;
}
if (customer.orderBubble.orderAsset2 && customer.orderBubble.orderAsset2.alpha === 1) {
allDimmed = false;
}
if (allDimmed) {
// Increase score only if it hasn't been increased for this customer
if (!customer.scoreAdded) {
score += 10;
scoreTxt.setText(score);
customer.scoreAdded = true; // Mark that score has been added for this customer
}
// 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
LK.setTimeout(function () {
LK.clearInterval(spinInterval);
customer.destroy();
customer.orderBubble.destroy();
customer.shadow.destroy();
}, 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 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.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);
}
// Function to create a new item
function createItem(type, x, y) {
if (!currentLevel.items.includes(type)) {
return;
}
var item = new Item(type);
item.x = x;
item.y = y;
item.width = 200;
item.height = 200;
items.push(item);
inventory.push(item); // Add item to inventory array
item.visible = true; // Show item on game start
game.addChild(item);
}
// Initialize level data
var levels = [new Level(1, 3, ['towel', 'umbrella']), new Level(2, 4, ['towel', 'umbrella', 'refreshment']), new Level(3, 5, ['towel', 'umbrella', 'refreshment', 'snack']), new Level(4, 6, ['towel', 'umbrella', 'refreshment', 'snack']), new Level(5, 7, ['towel', 'umbrella', 'refreshment', 'snack']), new Level(6, 8, ['towel', 'umbrella', 'refreshment', 'snack']), new Level(7, 9, ['towel', 'umbrella', 'refreshment', 'snack'])];
currentLevel = levels[0];
// Create initial customers
for (var i = 0; i < currentLevel.customerCount; i++) {
createCustomer();
}
// Update function
game.update = function () {
levelTxt.setText('LVL ' + currentLevel.levelNumber);
// 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) {
allOrdersFulfilled = false;
break;
}
if (customers[i].orderBubble.orderAsset2 && customers[i].orderBubble.orderAsset2.alpha === 1) {
allOrdersFulfilled = false;
break;
}
}
// If all orders are fulfilled, move to the next level
if (allOrdersFulfilled) {
var nextLevelIndex = levels.indexOf(currentLevel) + 1;
if (nextLevelIndex < levels.length) {
LK.setTimeout(function () {
currentLevel = levels[nextLevelIndex];
// Clear current customers and items
for (var i = 0; i < customers.length; i++) {
customers[i].destroy();
}
customers = [];
for (var i = 0; i < items.length; i++) {
items[i].destroy();
}
items = [];
// Create new customers and items for the next level
for (var i = 0; i < currentLevel.customerCount; i++) {
createCustomer();
}
var totalItems = currentLevel.items.length;
var startingPoint = (2048 - totalItems * 250) / 2;
for (var i = 0; i < totalItems; i++) {
createItem(currentLevel.items[i], startingPoint + i * 250, 2732 - 200);
}
// Reset timer for the new level
levelTimer = 60;
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);
LK.showGameOver();
}
}, 1000);
}, 1000);
}
} else if (LK.ticks % 300 == 0) {
createCustomer();
}
};
// Create initial items
for (var i = 0; i < currentLevel.items.length; i++) {
createItem(currentLevel.items[i], 2048 / 2 - 500 + i * 250, 2732 - 200);
}
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);
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.