User prompt
Fix Bug: 'ReferenceError: toppings is not defined' in this line: 'for (var a = toppings.length - 1; a >= 0; a--) {' Line Number: 46
User prompt
game mechanics: player uses mouse to move the cup at the bottom of the screen. toppings 1, 2, and 3 fall at random from the top of the screen. The combination of toppings caught in the cup must match the order
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'move')' in this line: 'ingredients[a].move();' Line Number: 37
User prompt
Fix Bug: 'TypeError: ingredient.update is not a function' in this line: 'ingredient.update();' Line Number: 36
User prompt
Fix Bug: 'TypeError: bubbleTea.update is not a function' in this line: 'bubbleTea.update();' Line Number: 36
Initial prompt
Bubble Tea Bistro
var BubbleTea = Container.expand(function () { var self = Container.call(this); var teaGraphics = self.createAsset('bubbleTea', 'Bubble Tea', .5, .5); self.move = function (x) { self.x = x; }; self.catch = function (topping) { if (self.intersects(topping)) { self.addChild(topping); topping.x = 0; topping.y = 0; } }; }); var Topping = Container.expand(function () { var self = Container.call(this); var toppingGraphics = self.createAsset('topping', 'Topping', .5, .5); self.speed = Math.random() * 5 + 1; self.move = function () { self.y += self.speed; }; }); var Game = Container.expand(function () { var self = Container.call(this); var bubbleTeas = []; var ingredients = []; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); var bubbleTea = self.addChild(new BubbleTea()); bubbleTea.x = 2048 / 2; bubbleTea.y = 2732 / 2; bubbleTea.on('down', function (obj) { console.log('Bubble tea was pressed'); }); bubbleTea.x = 2048 / 2; bubbleTea.y = 2732 - bubbleTea.height / 2; stage.on('move', function (obj) { var pos = obj.event.getLocalPosition(self); bubbleTea.move(pos.x); }); LK.on('tick', function () { for (var a = ingredients.length - 1; a >= 0; a--) { if (ingredients[a]) { ingredients[a].move(); bubbleTea.catch(ingredients[a]); if (ingredients[a].y > 2732) { ingredients[a].destroy(); ingredients.splice(a, 1); } } } if (LK.ticks % 60 == 0) { var newTopping = new Topping(); newTopping.x = Math.random() * 2048; newTopping.y = 0; ingredients.push(newTopping); self.addChild(newTopping); } }); });
===================================================================
--- original.js
+++ change.js
@@ -42,23 +42,23 @@
var pos = obj.event.getLocalPosition(self);
bubbleTea.move(pos.x);
});
LK.on('tick', function () {
- for (var a = toppings.length - 1; a >= 0; a--) {
- if (toppings[a]) {
- toppings[a].move();
- bubbleTea.catch(toppings[a]);
- if (toppings[a].y > 2732) {
- toppings[a].destroy();
- toppings.splice(a, 1);
+ for (var a = ingredients.length - 1; a >= 0; a--) {
+ if (ingredients[a]) {
+ ingredients[a].move();
+ bubbleTea.catch(ingredients[a]);
+ if (ingredients[a].y > 2732) {
+ ingredients[a].destroy();
+ ingredients.splice(a, 1);
}
}
}
if (LK.ticks % 60 == 0) {
var newTopping = new Topping();
newTopping.x = Math.random() * 2048;
newTopping.y = 0;
- toppings.push(newTopping);
+ ingredients.push(newTopping);
self.addChild(newTopping);
}
});
});
Fruit jelly boba pearls, no cup Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pile of Fruit jelly boba pearls, no cup Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
kawaii harajuku customer, mask, Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
fruit shiny anime, no face Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
boba pearls, pile, no cup, shiny anime Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
red bean, shiny anime, pile no cup Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
shiny plastic cup, no lid, anime, empty Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
whipped milk foam, creamy fluff, anime, Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
flan pudding, shiny, anime Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
anime angry lines, red cross Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
boba tea shop logo, kawaii anime, circular logo Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Tea shop interior, anime cafe Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Speech bubble 💬, "don't drop!" Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
UI point box, white square Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.