User prompt
Make demons spawn every now-and-thwn
User prompt
Make a shopping demon that tries to attack the cashier, but you can touch him to defeat him before he reaches the cashier
User prompt
Add a lot more new features
User prompt
Add a bunch of new stuff
User prompt
More
User prompt
Instead of automatically completing the level when everything is collected, how about you go to the cashier when everything is collected
User prompt
Make people kill you on contact
User prompt
Make the people walk around more freely ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The list is offscreen can you fix that
Code edit (1 edits merged)
Please save this source code
User prompt
Walmart Dash: Cart Crash
Initial prompt
Walmart Shopping
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Cashier = Container.expand(function () { var self = Container.call(this); // Create cashier visuals - using shopper asset with different tint var cashierGraphics = self.attachAsset('shopper', { anchorX: 0.5, anchorY: 0.5 }); // Make cashier visually distinct cashierGraphics.tint = 0x00AAFF; // Add cashier label var cashierLabel = new Text2("CASHIER", { size: 30, fill: 0x000000 }); cashierLabel.anchor.set(0.5, 0); cashierLabel.y = -120; self.addChild(cashierLabel); // Add visual indicator when all items collected self.showCheckoutReady = function () { var readyText = new Text2("CHECKOUT\nREADY!", { size: 35, fill: 0x00FF00 }); readyText.anchor.set(0.5, 0); readyText.y = -90; self.addChild(readyText); }; return self; }); var Item = Container.expand(function () { var self = Container.call(this); var itemGraphics = self.attachAsset('item', { anchorX: 0.5, anchorY: 0.5 }); self.name = ''; self.price = 0; self.onList = false; self.isSpecial = false; self.collected = false; self.setValue = function (name, price, onList) { self.name = name; self.price = price; self.onList = onList; var nameText = new Text2(name, { size: 22, fill: 0x000000 }); nameText.anchor.set(0.5, 0.5); nameText.y = -40; self.addChild(nameText); var priceText = new Text2('$' + price.toFixed(2), { size: 20, fill: 0x008000 }); priceText.anchor.set(0.5, 0.5); priceText.y = 40; self.addChild(priceText); if (onList) { itemGraphics.tint = 0xFFFF00; // Highlight items on the list } }; self.makeSpecialDeal = function () { if (self.isSpecial) { return; } self.isSpecial = true; // Replace with special deal graphics if (self.children.indexOf(itemGraphics) !== -1) { self.removeChild(itemGraphics); } var dealGraphics = self.attachAsset('specialDeal', { anchorX: 0.5, anchorY: 0.5 }); // Apply discount self.price = Math.round(self.price * 0.5 * 100) / 100; // Update price text for (var i = 0; i < self.children.length; i++) { if (self.children[i] instanceof Text2 && self.children[i].y === 40) { self.children[i].setText('$' + self.price.toFixed(2) + ' 50% OFF!'); self.children[i].tint = 0xFF0000; break; } } }; self.collect = function () { self.collected = true; self.visible = false; }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); var warningText = new Text2('⚠️', { size: 32, fill: 0x000000 }); warningText.anchor.set(0.5, 0.5); self.addChild(warningText); self.duration = 5000; // 5 seconds self.createTime = Date.now(); self.update = function () { // Check if obstacle should be removed if (Date.now() - self.createTime > self.duration) { self.readyToRemove = true; } }; return self; }); var Shopper = Container.expand(function () { var self = Container.call(this); var shopperGraphics = self.attachAsset('shopper', { anchorX: 0.5, anchorY: 0.5 }); self.isMoving = false; self.startX = 0; self.startY = 0; self.targetX = 0; self.targetY = 0; self.lastX = 0; self.lastY = 0; // Initialize shopper movement self.startMoving = function () { // Stop any existing movement tween.stop(self); // Remember starting position self.startX = self.x; self.startY = self.y; self.lastX = self.x; self.lastY = self.y; // Choose a random destination within the aisle area var randomDistance = 100 + Math.random() * 300; var randomAngle = Math.random() * Math.PI * 2; self.targetX = self.x + Math.cos(randomAngle) * randomDistance; self.targetY = self.y + Math.sin(randomAngle) * randomDistance; // Constrain to game boundaries self.targetX = Math.max(100, Math.min(2048 - 100, self.targetX)); self.targetY = Math.max(100, Math.min(2732 - 100, self.targetY)); // Randomize movement duration (2-5 seconds) var duration = 2000 + Math.random() * 3000; // Use tween to smoothly move to the destination tween(self, { x: self.targetX, y: self.targetY }, { duration: duration, easing: tween.easeInOut, onFinish: function onFinish() { // Wait for a moment before moving again LK.setTimeout(function () { self.startMoving(); }, 500 + Math.random() * 1000); } }); self.isMoving = true; }; self.update = function () { // Keep track of last position for intersection detection self.lastX = self.x; self.lastY = self.y; // Start moving if not already moving if (!self.isMoving) { self.startMoving(); } }; return self; }); var ShoppingCart = Container.expand(function () { var self = Container.call(this); var cartGraphics = self.attachAsset('cart', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.budget = 100; self.collectedItems = []; self.isColliding = false; self.setBudget = function (amount) { self.budget = amount; }; self.addItem = function (item) { if (self.budget >= item.price) { self.budget -= item.price; self.collectedItems.push(item.name); return true; } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xFFFFFF // White background }); /**** * Game Code ****/ // Game state variables var gameStarted = false; var timeRemaining = 60; // seconds var level = 1; var shoppingList = []; var aisles = []; var shoppers = []; var items = []; var obstacles = []; var specialDealTimer = null; var cleanupTimer = null; var cart; var gameArea; // UI elements var budgetText, timerText, shoppingListText, levelText, messageText; // Create game area (container for all game elements) gameArea = new Container(); game.addChild(gameArea); // Initialize level function initLevel() { // Clear previous level elements clearLevel(); // Set level properties timeRemaining = 60 + level * 10; // Create aisles (4 aisles) for (var i = 0; i < 5; i++) { var aisle = LK.getAsset('aisle', { anchorX: 0.5, anchorY: 0.5 }); aisle.x = 100 + i * 450; aisle.y = 2732 / 2; gameArea.addChild(aisle); aisles.push(aisle); } // Generate shopping list (3-7 items depending on level) var numItems = 3 + Math.min(level, 4); generateShoppingList(numItems); // Create items in store createStoreItems(); // Create shoppers (obstacles) var numShoppers = 3 + level; createShoppers(numShoppers); // Create player's cart cart = new ShoppingCart(); cart.x = 2048 / 2; cart.y = 2732 - 200; cart.setBudget(100 + level * 20); gameArea.addChild(cart); // Set up timers for special events setupEventTimers(); // Update UI updateUI(); // Create cashier at the bottom of store var cashier = new Cashier(); cashier.x = 2048 / 2; cashier.y = 2732 - 100; gameArea.addChild(cashier); // Start the game gameStarted = true; LK.playMusic('bgmusic'); } function clearLevel() { // Clear all arrays aisles = []; shoppers = []; items = []; obstacles = []; shoppingList = []; // Clear all timers if (specialDealTimer) { LK.clearInterval(specialDealTimer); specialDealTimer = null; } if (cleanupTimer) { LK.clearInterval(cleanupTimer); cleanupTimer = null; } // Remove all children from game area while (gameArea.children.length > 0) { gameArea.removeChild(gameArea.children[0]); } } function generateShoppingList(numItems) { var possibleItems = [{ name: "Milk", price: 3.49 }, { name: "Bread", price: 2.99 }, { name: "Eggs", price: 4.29 }, { name: "Cereal", price: 4.99 }, { name: "Bananas", price: 1.99 }, { name: "Chips", price: 3.79 }, { name: "Soda", price: 5.49 }, { name: "Pizza", price: 7.99 }, { name: "Ice Cream", price: 6.49 }, { name: "Chicken", price: 8.99 }]; // Shuffle array for (var i = possibleItems.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = possibleItems[i]; possibleItems[i] = possibleItems[j]; possibleItems[j] = temp; } // Take first numItems shoppingList = possibleItems.slice(0, numItems); // Update shopping list display updateShoppingListText(); } function createStoreItems() { // Create items from shopping list for (var i = 0; i < shoppingList.length; i++) { var item = new Item(); var aisleIndex = Math.floor(Math.random() * aisles.length); var aisle = aisles[aisleIndex]; item.x = aisle.x + (Math.random() * 200 - 100); item.y = 200 + Math.random() * (2732 - 400); item.setValue(shoppingList[i].name, shoppingList[i].price, true); gameArea.addChild(item); items.push(item); } // Create additional random items not on list var numExtraItems = 10 + level * 2; var possibleItems = [{ name: "Apples", price: 3.99 }, { name: "Soup", price: 2.49 }, { name: "Yogurt", price: 4.79 }, { name: "Coffee", price: 7.99 }, { name: "Pasta", price: 1.99 }, { name: "Candy", price: 3.29 }, { name: "Juice", price: 4.49 }, { name: "Paper", price: 5.99 }, { name: "Soap", price: 3.59 }, { name: "Cookies", price: 4.29 }, { name: "Cheese", price: 5.49 }, { name: "Water", price: 3.99 }, { name: "Tissues", price: 2.79 }, { name: "Detergent", price: 8.99 }, { name: "Toothpaste", price: 3.99 }]; for (var j = 0; j < numExtraItems; j++) { var extraItem = new Item(); var extraAisleIndex = Math.floor(Math.random() * aisles.length); var extraAisle = aisles[extraAisleIndex]; var itemData = possibleItems[Math.floor(Math.random() * possibleItems.length)]; extraItem.x = extraAisle.x + (Math.random() * 200 - 100); extraItem.y = 200 + Math.random() * (2732 - 400); extraItem.setValue(itemData.name, itemData.price, false); gameArea.addChild(extraItem); items.push(extraItem); } } function createShoppers(numShoppers) { for (var i = 0; i < numShoppers; i++) { var shopper = new Shopper(); var aisleIndex = Math.floor(Math.random() * aisles.length); var aisle = aisles[aisleIndex]; shopper.x = aisle.x + (Math.random() * 200 - 100); shopper.y = 200 + Math.random() * (2732 - 400); shopperGraphics = shopper.children[0]; // Randomly rotate the shopper shopperGraphics.rotation = Math.random() * Math.PI * 2; gameArea.addChild(shopper); shoppers.push(shopper); // Stagger the movement starts LK.setTimeout(function (s) { return function () { s.startMoving(); }; }(shopper), i * 300); } } function setupEventTimers() { // Special deals event (every 10-15 seconds) specialDealTimer = LK.setInterval(function () { createSpecialDeal(); }, 10000 + Math.random() * 5000); // Cleanup event (every 15-20 seconds) cleanupTimer = LK.setInterval(function () { createCleanupObstacle(); }, 15000 + Math.random() * 5000); } function createSpecialDeal() { // Pick a random item to make a special deal if (items.length > 0) { var randomIndex = Math.floor(Math.random() * items.length); var item = items[randomIndex]; if (!item.isSpecial && !item.collected) { item.makeSpecialDeal(); // Show flash sale message showMessage("FLASH SALE!", 2000); } } } function createCleanupObstacle() { // Create cleanup on a random aisle var randomAisleIndex = Math.floor(Math.random() * aisles.length); var aisle = aisles[randomAisleIndex]; var obstacle = new Obstacle(); obstacle.x = aisle.x; obstacle.y = 500 + Math.random() * 1500; gameArea.addChild(obstacle); obstacles.push(obstacle); // Show cleanup message showMessage("CLEANUP ON AISLE " + (randomAisleIndex + 1), 2000); } function updateShoppingListText() { var listText = "Shopping List:\n"; var remainingItems = 0; for (var i = 0; i < shoppingList.length; i++) { var collected = false; // Check if item has been collected if (cart && cart.collectedItems) { collected = cart.collectedItems.indexOf(shoppingList[i].name) !== -1; } if (!collected) { remainingItems++; listText += "• " + shoppingList[i].name + " - $" + shoppingList[i].price.toFixed(2) + "\n"; } else { listText += "✓ " + shoppingList[i].name + " - $" + shoppingList[i].price.toFixed(2) + "\n"; } } if (shoppingListText) { shoppingListText.setText(listText); } return remainingItems; } function showMessage(text, duration) { if (messageText) { messageText.setText(text); messageText.visible = true; LK.setTimeout(function () { messageText.visible = false; }, duration); } } function createUI() { // Create budget display budgetText = new Text2("Budget: $0.00", { size: 40, fill: 0x008000 }); budgetText.anchor.set(0, 0); LK.gui.topRight.addChild(budgetText); // Create timer display timerText = new Text2("Time: 0:00", { size: 40, fill: 0xDE2027 }); timerText.anchor.set(0.5, 0); LK.gui.top.addChild(timerText); // Create level display levelText = new Text2("Level: 1", { size: 40, fill: 0x0071CE }); levelText.anchor.set(1, 0); LK.gui.topLeft.addChild(levelText); // Move it a bit to the right to avoid the platform menu levelText.x += 120; // Create shopping list display shoppingListText = new Text2("Shopping List:", { size: 30, fill: 0x000000 }); shoppingListText.anchor.set(1, 0); shoppingListText.x = -20; // Move it a bit to the left to ensure visibility LK.gui.right.addChild(shoppingListText); // Create message text for events messageText = new Text2("", { size: 60, fill: 0xFF0000 }); messageText.anchor.set(0.5, 0.5); messageText.visible = false; LK.gui.center.addChild(messageText); } function updateUI() { if (!cart) { return; } // Update budget display budgetText.setText("Budget: $" + cart.budget.toFixed(2)); // Update timer display var minutes = Math.floor(timeRemaining / 60); var seconds = timeRemaining % 60; timerText.setText("Time: " + minutes + ":" + (seconds < 10 ? "0" : "") + seconds); // Update level display levelText.setText("Level: " + level); // Update shopping list var remainingItems = updateShoppingListText(); // If no items remaining, highlight cashier to indicate checkout if (remainingItems === 0) { // Find cashier and set indicator for (var c = 0; c < gameArea.children.length; c++) { if (gameArea.children[c] instanceof Cashier) { gameArea.children[c].showCheckoutReady(); break; } } // No longer win automatically - need to go to cashier } } // Handle touch/drag controls var dragging = false; function handleMove(x, y, obj) { if (dragging && cart) { // Move the cart to the touch position cart.x = x; cart.y = y; // Keep within game boundaries cart.x = Math.max(cart.width / 2, Math.min(2048 - cart.width / 2, cart.x)); cart.y = Math.max(cart.height / 2, Math.min(2732 - cart.height / 2, cart.y)); } } game.move = handleMove; game.down = function (x, y, obj) { if (!gameStarted) { initLevel(); return; } if (cart && Math.abs(x - cart.x) < cart.width / 2 && Math.abs(y - cart.y) < cart.height / 2) { dragging = true; } handleMove(x, y, obj); }; game.up = function (x, y, obj) { dragging = false; }; // Main game loop var lastSecondTick = 0; game.update = function () { if (!gameStarted) { return; } // Update timer once per second if (LK.ticks % 60 === 0) { timeRemaining--; updateUI(); // Check if time is up if (timeRemaining <= 0) { gameStarted = false; showMessage("TIME'S UP!", 2000); LK.setTimeout(function () { LK.showGameOver(); }, 2000); } } // Update all shoppers for (var i = 0; i < shoppers.length; i++) { shoppers[i].update(); } // Update all obstacles for (var j = obstacles.length - 1; j >= 0; j--) { obstacles[j].update(); if (obstacles[j].readyToRemove) { gameArea.removeChild(obstacles[j]); obstacles.splice(j, 1); } } // Check for collisions with cart if (cart) { // Check for collisions with items for (var k = 0; k < items.length; k++) { var item = items[k]; if (!item.collected && cart.intersects(item)) { if (item.onList) { // Collect item on shopping list if (cart.addItem(item)) { item.collect(); LK.getSound('pickup').play(); LK.setScore(LK.getScore() + 10); updateUI(); } else { // Not enough budget if (!cart.isColliding) { showMessage("Not enough budget!", 1000); cart.isColliding = true; LK.setTimeout(function () { cart.isColliding = false; }, 1000); } } } else if (item.isSpecial) { // Collect special item if (cart.addItem(item)) { item.collect(); LK.getSound('deal').play(); LK.setScore(LK.getScore() + 5); updateUI(); } else { // Not enough budget if (!cart.isColliding) { showMessage("Not enough budget!", 1000); cart.isColliding = true; LK.setTimeout(function () { cart.isColliding = false; }, 1000); } } } } } // Check for collisions with shoppers for (var m = 0; m < shoppers.length; m++) { if (cart.intersects(shoppers[m]) && !cart.isColliding) { // Collision with shopper - Game Over! LK.getSound('collision').play(); LK.effects.flashObject(cart, 0xFF0000, 500); cart.isColliding = true; // Show death message and end game showMessage("GAME OVER! Other shopper crashed into you!", 2000); gameStarted = false; updateUI(); LK.setTimeout(function () { LK.showGameOver(); }, 2000); } } // Check for collisions with obstacles for (var n = 0; n < obstacles.length; n++) { if (cart.intersects(obstacles[n]) && !cart.isColliding) { // Collision with obstacle LK.getSound('collision').play(); LK.effects.flashObject(cart, 0xFF0000, 500); cart.isColliding = true; // Penalty timeRemaining = Math.max(0, timeRemaining - 3); updateUI(); LK.setTimeout(function () { cart.isColliding = false; }, 1000); } } // Check for collision with cashier for level completion for (var c = 0; c < gameArea.children.length; c++) { if (gameArea.children[c] instanceof Cashier && cart.intersects(gameArea.children[c])) { // Check if all items have been collected var remainingItems = updateShoppingListText(); if (remainingItems === 0 && !cart.isColliding) { // Level complete! level++; showMessage("CHECKOUT COMPLETE! LEVEL UP!", 3000); LK.setTimeout(initLevel, 3000); gameStarted = false; // Award bonus points for remaining time var timeBonus = timeRemaining * 2; LK.setScore(LK.getScore() + timeBonus); break; } else if (remainingItems > 0 && !cart.isColliding) { // Still have items to collect showMessage("Finish your shopping first!", 1000); cart.isColliding = true; LK.setTimeout(function () { cart.isColliding = false; }, 1000); } } } } }; // Initialize UI createUI(); // Show start instructions showMessage("TAP TO START SHOPPING!", 0);
===================================================================
--- original.js
+++ change.js
@@ -6,8 +6,37 @@
/****
* Classes
****/
+var Cashier = Container.expand(function () {
+ var self = Container.call(this);
+ // Create cashier visuals - using shopper asset with different tint
+ var cashierGraphics = self.attachAsset('shopper', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Make cashier visually distinct
+ cashierGraphics.tint = 0x00AAFF;
+ // Add cashier label
+ var cashierLabel = new Text2("CASHIER", {
+ size: 30,
+ fill: 0x000000
+ });
+ cashierLabel.anchor.set(0.5, 0);
+ cashierLabel.y = -120;
+ self.addChild(cashierLabel);
+ // Add visual indicator when all items collected
+ self.showCheckoutReady = function () {
+ var readyText = new Text2("CHECKOUT\nREADY!", {
+ size: 35,
+ fill: 0x00FF00
+ });
+ readyText.anchor.set(0.5, 0);
+ readyText.y = -90;
+ self.addChild(readyText);
+ };
+ return self;
+});
var Item = Container.expand(function () {
var self = Container.call(this);
var itemGraphics = self.attachAsset('item', {
anchorX: 0.5,
@@ -237,8 +266,13 @@
// Set up timers for special events
setupEventTimers();
// Update UI
updateUI();
+ // Create cashier at the bottom of store
+ var cashier = new Cashier();
+ cashier.x = 2048 / 2;
+ cashier.y = 2732 - 100;
+ gameArea.addChild(cashier);
// Start the game
gameStarted = true;
LK.playMusic('bgmusic');
}
@@ -517,14 +551,18 @@
// Update level display
levelText.setText("Level: " + level);
// Update shopping list
var remainingItems = updateShoppingListText();
- // Check win condition
+ // If no items remaining, highlight cashier to indicate checkout
if (remainingItems === 0) {
- level++;
- showMessage("LEVEL COMPLETE!", 3000);
- LK.setTimeout(initLevel, 3000);
- gameStarted = false;
+ // Find cashier and set indicator
+ for (var c = 0; c < gameArea.children.length; c++) {
+ if (gameArea.children[c] instanceof Cashier) {
+ gameArea.children[c].showCheckoutReady();
+ break;
+ }
+ }
+ // No longer win automatically - need to go to cashier
}
}
// Handle touch/drag controls
var dragging = false;
@@ -656,8 +694,33 @@
cart.isColliding = false;
}, 1000);
}
}
+ // Check for collision with cashier for level completion
+ for (var c = 0; c < gameArea.children.length; c++) {
+ if (gameArea.children[c] instanceof Cashier && cart.intersects(gameArea.children[c])) {
+ // Check if all items have been collected
+ var remainingItems = updateShoppingListText();
+ if (remainingItems === 0 && !cart.isColliding) {
+ // Level complete!
+ level++;
+ showMessage("CHECKOUT COMPLETE! LEVEL UP!", 3000);
+ LK.setTimeout(initLevel, 3000);
+ gameStarted = false;
+ // Award bonus points for remaining time
+ var timeBonus = timeRemaining * 2;
+ LK.setScore(LK.getScore() + timeBonus);
+ break;
+ } else if (remainingItems > 0 && !cart.isColliding) {
+ // Still have items to collect
+ showMessage("Finish your shopping first!", 1000);
+ cart.isColliding = true;
+ LK.setTimeout(function () {
+ cart.isColliding = false;
+ }, 1000);
+ }
+ }
+ }
}
};
// Initialize UI
createUI();
Top-down image of a shopping cart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Top-down image of a person. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Sale! Sign. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Water spill. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Box of food. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Shield. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Cart with letters saying WALMART DASH!. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows