User prompt
in the middle of the screen add a counter that starts from 3 till it reaches 1. Once it reaches one the counter on the top right corner starts counting
User prompt
make the numbers pixelated
User prompt
on the top right corner add a counter that starts from 120 and counts down till it reaches zero.
User prompt
the background fills the whole screen
User prompt
add a background
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: ingredientGraphics.setTexture is not a function' in this line: 'ingredientGraphics.setTexture(LK.getAsset('ingredient_' + type));' Line Number: 11
User prompt
Fix Bug: 'TypeError: ingredientGraphics.setTextureFromAsset is not a function' in this line: 'ingredientGraphics.setTextureFromAsset('ingredient_' + type);' Line Number: 11
User prompt
Fix Bug: 'TypeError: ingredientGraphics.setTexture is not a function' in this line: 'ingredientGraphics.setTexture('ingredient_' + type);' Line Number: 11
User prompt
Fix Bug: 'ReferenceError: ingredientGraphics is not defined' in this line: 'self.y = -ingredientGraphics.height;' Line Number: 13
User prompt
delete all the assets
User prompt
Fix Bug: 'TypeError: ingredientGraphics.setTexture is not a function' in this line: 'ingredientGraphics.setTexture('ingredient_' + type);' Line Number: 11
User prompt
Fix Bug: 'TypeError: ingredientGraphics.setTextureFromAsset is not a function' in this line: 'ingredientGraphics.setTextureFromAsset('ingredient_' + type);' Line Number: 11
User prompt
Fix Bug: 'TypeError: ingredientGraphics.setTexture is not a function' in this line: 'ingredientGraphics.setTexture('ingredient_' + type);' Line Number: 11
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'Button')' in this line: 'var spawnPattyButton = new LK.UI.Button({' Line Number: 119
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'Button')' in this line: 'var spawnPattyButton = new LK.UI.Button({' Line Number: 119
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'Button')' in this line: 'var spawnPattyButton = new LK.UI.Button({' Line Number: 119
User prompt
run the game, fix bugs
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'Button')' in this line: 'var spawnPattyButton = new LK.UI.Button({' Line Number: 117
User prompt
on the bottom left add a button. Once the button has been clicked a burger patty with the bottom part appears and falls on a table. The table is a stopping point for the patty. then once the button is clicked again another patty falls and stacks on top of the other. then a round button in the right middle appears saying, next order.
User prompt
Fix Bug: 'TypeError: ingredientGraphics.setTexture is not a function' in this line: 'ingredientGraphics.setTexture('ingredient_' + type);' Line Number: 11
Initial prompt
Burger Time !
/**** * Classes ****/ // Burger ingredient class var Ingredient = Container.expand(function () { var self = Container.call(this); var ingredientGraphics = self.createAsset('ingredient', 'Burger ingredient', 0.5, 0.5); self.type = ''; self.setIngredientType = function (type) { self.type = type; ingredientGraphics.texture = LK.getAsset('ingredient_' + type); }; self.resetPosition = function () { self.x = game.width / 2; self.y = -ingredientGraphics.height; }; self.drop = function () { self.y += 5; }; self.isOffScreen = function () { return self.y > game.height; }; }); // Burger stack class var BurgerStack = Container.expand(function () { var self = Container.call(this); self.ingredients = []; self.height = 0; self.addIngredient = function (ingredient) { ingredient.y = game.height - self.height - ingredient.height / 2; ingredient.x = game.width / 2; self.height += ingredient.height; self.ingredients.push(ingredient); game.addChild(ingredient); }; self.reset = function () { self.ingredients.forEach(function (ingredient) { ingredient.destroy(); }); self.ingredients = []; self.height = 0; }; }); // Table class to stop falling ingredients var Table = Container.expand(function () { var self = Container.call(this); var tableGraphics = self.createAsset('table', 'Table to stop ingredients', 0.5, 1); self.x = game.width / 2; self.y = game.height - tableGraphics.height / 2; game.addChild(self); self.stopIngredient = function (ingredient) { if (ingredient.y + ingredient.height / 2 >= self.y - tableGraphics.height / 2) { ingredient.y = self.y - tableGraphics.height / 2 - ingredient.height / 2; return true; } return false; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize burger stack var burgerStack = new BurgerStack(); // Initialize available ingredients var availableIngredients = ['lettuce', 'tomato', 'cheese', 'patty', 'bun_top', 'bun_bottom']; var currentIngredient = null; // Function to create a new ingredient of a specific type function spawnIngredient(type) { if (currentIngredient && !currentIngredient.isOffScreen()) { return; // Don't spawn a new ingredient if the current one is still on screen } currentIngredient = new Ingredient(); currentIngredient.setIngredientType(type); currentIngredient.resetPosition(); game.addChild(currentIngredient); } // Function to handle ingredient drop function dropIngredient() { if (currentIngredient) { burgerStack.addIngredient(currentIngredient); currentIngredient = null; } } // Touch event to drop ingredient game.on('down', function (obj) { dropIngredient(); }); // Game tick event LK.on('tick', function () { if (currentIngredient) { currentIngredient.drop(); if (table.stopIngredient(currentIngredient)) { currentIngredient = null; } else if (currentIngredient.isOffScreen()) { currentIngredient.destroy(); currentIngredient = null; } } }); // Reset game function resetGame() { burgerStack.reset(); if (currentIngredient) { currentIngredient.destroy(); currentIngredient = null; } } // Create a button to spawn patties var spawnPattyButton = new LK.UI.Button({ label: 'Add Patty', width: 200, height: 100, onRelease: function onRelease() { spawnIngredient('patty'); } }); spawnPattyButton.x = 10; spawnPattyButton.y = game.height - spawnPattyButton.height - 10; LK.gui.bottomLeft.addChild(spawnPattyButton); // Game over condition function checkGameOver() { if (burgerStack.height > game.height) { LK.showGameOver(); resetGame(); } } // Update game every tick LK.on('tick', function () { checkGameOver(); }); // Add a 'Next Order' button on the right middle of the screen var nextOrderButton = new LK.UI.Button({ label: 'Next Order', width: 200, height: 100, onRelease: function onRelease() { resetGame(); } }); nextOrderButton.x = game.width - nextOrderButton.width - 10; nextOrderButton.y = game.height / 2 - nextOrderButton.height / 2; LK.gui.right.addChild(nextOrderButton);
===================================================================
--- original.js
+++ change.js
@@ -40,8 +40,23 @@
self.ingredients = [];
self.height = 0;
};
});
+// Table class to stop falling ingredients
+var Table = Container.expand(function () {
+ var self = Container.call(this);
+ var tableGraphics = self.createAsset('table', 'Table to stop ingredients', 0.5, 1);
+ self.x = game.width / 2;
+ self.y = game.height - tableGraphics.height / 2;
+ game.addChild(self);
+ self.stopIngredient = function (ingredient) {
+ if (ingredient.y + ingredient.height / 2 >= self.y - tableGraphics.height / 2) {
+ ingredient.y = self.y - tableGraphics.height / 2 - ingredient.height / 2;
+ return true;
+ }
+ return false;
+ };
+});
/****
* Initialize Game
****/
@@ -56,14 +71,13 @@
var burgerStack = new BurgerStack();
// Initialize available ingredients
var availableIngredients = ['lettuce', 'tomato', 'cheese', 'patty', 'bun_top', 'bun_bottom'];
var currentIngredient = null;
-// Function to create a new ingredient
-function spawnIngredient() {
+// Function to create a new ingredient of a specific type
+function spawnIngredient(type) {
if (currentIngredient && !currentIngredient.isOffScreen()) {
return; // Don't spawn a new ingredient if the current one is still on screen
}
- var type = availableIngredients[Math.floor(Math.random() * availableIngredients.length)];
currentIngredient = new Ingredient();
currentIngredient.setIngredientType(type);
currentIngredient.resetPosition();
game.addChild(currentIngredient);
@@ -82,14 +96,14 @@
// Game tick event
LK.on('tick', function () {
if (currentIngredient) {
currentIngredient.drop();
- if (currentIngredient.isOffScreen()) {
+ if (table.stopIngredient(currentIngredient)) {
+ currentIngredient = null;
+ } else if (currentIngredient.isOffScreen()) {
currentIngredient.destroy();
currentIngredient = null;
}
- } else {
- spawnIngredient();
}
});
// Reset game
function resetGame() {
@@ -98,8 +112,20 @@
currentIngredient.destroy();
currentIngredient = null;
}
}
+// Create a button to spawn patties
+var spawnPattyButton = new LK.UI.Button({
+ label: 'Add Patty',
+ width: 200,
+ height: 100,
+ onRelease: function onRelease() {
+ spawnIngredient('patty');
+ }
+});
+spawnPattyButton.x = 10;
+spawnPattyButton.y = game.height - spawnPattyButton.height - 10;
+LK.gui.bottomLeft.addChild(spawnPattyButton);
// Game over condition
function checkGameOver() {
if (burgerStack.height > game.height) {
LK.showGameOver();
@@ -108,5 +134,16 @@
}
// Update game every tick
LK.on('tick', function () {
checkGameOver();
-});
\ No newline at end of file
+}); // Add a 'Next Order' button on the right middle of the screen
+var nextOrderButton = new LK.UI.Button({
+ label: 'Next Order',
+ width: 200,
+ height: 100,
+ onRelease: function onRelease() {
+ resetGame();
+ }
+});
+nextOrderButton.x = game.width - nextOrderButton.width - 10;
+nextOrderButton.y = game.height / 2 - nextOrderButton.height / 2;
+LK.gui.right.addChild(nextOrderButton);
\ No newline at end of file
pixel butterfly. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel butterfly looking left, showing the left profile. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Remove it and make it transparent
pixel sunny field height is bigger than width.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.