User prompt
Fix Bug: 'TypeError: null is not an object (evaluating 'customer.x')' in this line: 'customer.x += 20;' Line Number: 168
User prompt
Fix Bug: 'TypeError: customer is null' in this line: 'customer.x += 20;' Line Number: 168
User prompt
Fix Bug: 'TypeError: customer is null' in this line: 'customer.x += 20;' Line Number: 168
User prompt
Fix Bug: 'TypeError: customer is null' in this line: 'customer.x += 20;' Line Number: 166
User prompt
Fix Bug: 'TypeError: customer is null' in this line: 'customer.x += 20;' Line Number: 167
User prompt
Fix Bug: 'TypeError: customer is null' in this line: 'customer.x += 20;' Line Number: 167
var Order = Container.expand(function () {
var self = Container.call(this);
self.ingredients = [];
for (var i = 0; i < 3; i++) {
self.ingredients.push(Math.floor(Math.random() * 5));
}
});
var SpeechBubble = Container.expand(function (text) {
var self = Container.call(this);
var bubbleGraphics = self.createAsset('speechBubble', 'Speech Bubble', .5, .5);
var maxIngredients = Math.floor(bubbleGraphics.width / 50);
for (var i = 0; i < Math.min(text.length, maxIngredients); i++) {
var ingredientGraphic = self.createAsset('ingredient' + text[i], 'Ingredient', .5, .5);
ingredientGraphic.scale.set(0.5);
ingredientGraphic.x = i * ((bubbleGraphics.width + 10) / maxIngredients) + i * 10 + ingredientGraphic.width / 2 - 100 + i * 10;
self.addChild(ingredientGraphic);
}
});
var Customer1 = Container.expand(function () {
var self = Container.call(this);
var customerGraphics = self.createAsset('customer1', 'Customer1', .5, .5);
self.order = new Order();
if (self.speechBubble) {
self.speechBubble.destroy();
}
self.speechBubble = self.addChild(new SpeechBubble(self.order.ingredients));
self.speechBubble.y = -self.speechBubble.height - 30;
self.speechBubble.x += 100;
});
var Customer2 = Container.expand(function () {
var self = Container.call(this);
var customerGraphics = self.createAsset('customer2', 'Customer2', .5, .5);
self.order = new Order();
if (self.speechBubble) {
self.speechBubble.destroy();
}
self.speechBubble = self.addChild(new SpeechBubble(self.order.ingredients));
self.speechBubble.y = -self.speechBubble.height - 30;
self.speechBubble.x += 100;
});
var Customer3 = Container.expand(function () {
var self = Container.call(this);
var customerGraphics = self.createAsset('customer3', 'Customer3', .5, .5);
self.order = new Order();
if (self.speechBubble) {
self.speechBubble.destroy();
}
self.speechBubble = self.addChild(new SpeechBubble(self.order.ingredients));
self.speechBubble.y = -self.speechBubble.height - 30;
self.speechBubble.x += 100;
});
var BubbleTea = Container.expand(function () {
var self = Container.call(this);
var teaGraphics = self.createAsset('bubbleTea', 'Bubble Tea', .5, .5);
self.ingredients = [];
self.speed = 10;
self.catch = function (ingredient) {
self.ingredients.push(ingredient);
};
self.move = function (direction) {
self.x += self.speed * direction;
if (self.x < teaGraphics.width / 2) self.x = teaGraphics.width / 2;
if (self.x > 2048 - teaGraphics.width / 2) self.x = 2048 - teaGraphics.width / 2;
if (self.y < teaGraphics.height / 2) self.y = teaGraphics.height / 2;
if (self.y > 2732 - teaGraphics.height / 2) self.y = 2732 - teaGraphics.height / 2;
};
});
var Ingredient = Container.expand(function (id) {
var self = Container.call(this);
self.id = id;
self.speed = Math.random() * 10 + 6;
var ingredientGraphics = self.createAsset('ingredient' + id, 'Ingredient', .5, .5);
self.move = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
if (self.x < ingredientGraphics.width / 2) self.x = ingredientGraphics.width / 2;
if (self.x > 2048 - ingredientGraphics.width / 2) self.x = 2048 - ingredientGraphics.width / 2;
};
self.add = function () {};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var score = 0;
var scoreTxt = new Text2(score.toString(), {
size: 100,
fill: '#FFA500'
});
scoreTxt.anchor.set(0.5, 0.5);
var scoreBox = LK.getAsset('scoreBox', 'Score Box', 0, 0);
scoreBox.width = 200;
scoreBox.height = 100;
scoreBox.x = 2048 - scoreBox.width / 2;
scoreBox.y = 2732 - scoreBox.height / 2;
self.addChild(scoreBox);
scoreBox.addChild(scoreTxt);
scoreTxt.x = scoreBox.width / 2;
scoreTxt.y = scoreBox.height / 2;
self.updateScore = function (newScore) {
score = newScore;
scoreTxt.setText(score.toString());
};
var background = self.createAsset('background', 'Game Background', 0.5, 0.5);
self.addChild(background);
background.width = 2048;
background.height = 2732;
background.x = 2048 / 2;
background.y = 2732 / 2;
var ingredients = [];
var customer;
var bubbleTea = self.addChild(new BubbleTea());
bubbleTea.x = 2048 / 2;
bubbleTea.y = 2732 - bubbleTea.height / 2;
LK.on('tick', function () {
if (!customer && !self.bufferTime) {
var CustomerClass = [Customer1, Customer2, Customer3][Math.floor(Math.random() * 3)];
customer = self.addChild(new CustomerClass());
customer.x = -customer.width;
customer.y = 2732 - customer.height / 2;
self.bufferTime = LK.ticks + 60;
} else if (self.bufferTime && LK.ticks < self.bufferTime) {
return;
} else if (self.bufferTime && LK.ticks >= self.bufferTime) {
self.bufferTime = null;
}
if (customer) {
if (customer.x < 0) {
customer.x += 20;
} else if (bubbleTea.ingredients.length == customer.order.ingredients.length && bubbleTea.ingredients.sort().join() === customer.order.ingredients.sort().join()) {
if (customer) {
customer.x += 20;
if (customer && customer.x > 2048 + customer.width && (bubbleTea.ingredients.length == customer.order.ingredients.length && bubbleTea.ingredients.sort().join() === customer.order.ingredients.sort().join())) {
customer.destroy();
customer = null;
bubbleTea.ingredients = [];
}
}
} else if (customer && bubbleTea.ingredients.length != customer.order.ingredients.length && customer.x > 0) {
customer.x -= 20;
} else if (customer && customer.x > 2048 + customer.width) {
customer.x = 2048 + customer.width;
customer = null;
bubbleTea.ingredients = [];
}
}
});
stage.on('move', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
bubbleTea.x = pos.x;
});
LK.on('tick', function () {
for (var a = ingredients.length - 1; a >= 0; a--) {
ingredients[a].move();
if (bubbleTea.intersects(ingredients[a])) {
if (customer && customer.order.ingredients.includes(ingredients[a].id) && !bubbleTea.ingredients.includes(ingredients[a].id)) {
bubbleTea.catch(ingredients[a].id);
ingredients[a].destroy();
ingredients.splice(a, 1);
self.updateScore(score + ingredients[a].speed);
if (bubbleTea.ingredients.sort().every((val, index) => val === customer.order.ingredients.sort()[index])) {
customer.destroy();
customer = null;
bubbleTea.ingredients = [];
}
} else {
customer.x += 20;
if (customer.x > 2048 + customer.width) {
customer = null;
bubbleTea.ingredients = [];
}
}
}
}
if (LK.ticks % 60 == 0) {
var newIngredient = new Ingredient(Math.floor(Math.random() * 5));
newIngredient.x = Math.random() * 2048;
newIngredient.y = -newIngredient.height;
ingredients.push(newIngredient);
self.addChild(newIngredient);
}
});
});
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.