Code edit (5 edits merged)
Please save this source code
User prompt
create a class and asset for GreenCheckmark
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'speechBubble = LK.getAsset('speechBubble', {' Line Number: 724
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (13 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: instructionTxt is not defined' in or related to this line: 'instructionTxt.setText('Tap to throw the javelin');' Line Number: 65
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (15 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'self.x += queueSpeed;' Line Number: 591
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
when a customer has received their drink, three little hearts should rise above their heads and disappear
Code edit (4 edits merged)
Please save this source code
User prompt
after speechBubble is destroyed and the itemsprite is set, move the itemsprite towards the rightmost customer while scaling it down to 0.2 over 1 second
Code edit (4 edits merged)
Please save this source code
User prompt
in createStarExplosion, please set the stars vx and vy to a uniform circular spread
Code edit (6 edits merged)
Please save this source code
User prompt
create a star explosions after emptyglass.destroy()
/****
* Classes
****/
// Customer1 class
var Customer1 = Container.expand(function () {
var self = Container.call(this);
var customer1Graphics = self.attachAsset('customer1', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Customer2 class
var Customer2 = Container.expand(function () {
var self = Container.call(this);
var customer2Graphics = self.attachAsset('customer2', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Customer2 specific update logic
};
});
// Customer3 class
var Customer3 = Container.expand(function () {
var self = Container.call(this);
var customer3Graphics = self.attachAsset('customer3', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Customer3 specific update logic
};
});
// Customer4 class
var Customer4 = Container.expand(function () {
var self = Container.call(this);
var customer4Graphics = self.attachAsset('customer4', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Customer4 specific update logic
};
});
// Customer5 class
var Customer5 = Container.expand(function () {
var self = Container.call(this);
var customer5Graphics = self.attachAsset('customer5', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Customer5 specific update logic
};
});
// Customer6 class
var Customer6 = Container.expand(function () {
var self = Container.call(this);
var customer6Graphics = self.attachAsset('customer6', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Customer6 specific update logic
};
});
// Customer7 class
var Customer7 = Container.expand(function () {
var self = Container.call(this);
var customer7Graphics = self.attachAsset('customer7', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Customer6 specific update logic
};
});
// Customer8 class
var Customer8 = Container.expand(function () {
var self = Container.call(this);
var customer8Graphics = self.attachAsset('customer8', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Customer6 specific update logic
};
});
// EmptyGlass class
var EmptyGlass = Container.expand(function () {
var self = Container.call(this);
var emptyGlassGraphics = self.attachAsset('emptyGlass', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.5
});
/*
var fillGlassGraphics = self.attachAsset('emptyGlass', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 1,
tint: '0xffff00'
});*/
var fullText = new Text2('0%', {
size: 100,
fill: "#ffffff",
stroke: '#000000',
strokeThickness: 10,
weight: 300,
anchorX: 0.5,
anchorY: 0.5
});
fullText.x = -50;
fullText.y = -50;
self.addChild(fullText);
self.update = function () {
// EmptyGlass specific update logic
};
self.updateText = function (i) {
fullText.setText(i + '%');
fullText.x = -50 - fullText.width / 4;
};
});
// Girl class
var Girl = Container.expand(function () {
var self = Container.call(this);
var girlGraphics = self.attachAsset('girl', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Girl specific update logic
};
});
// Ice class
var Ice = Container.expand(function () {
var self = Container.call(this);
var iceGraphics = self.attachAsset('ice', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Ice specific update logic
};
});
// IngredientButton class
var IngredientButton = Container.expand(function (i, k) {
var self = Container.call(this);
var ingredientButtonGraphics = self.attachAsset('ingredientButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.75,
scaleY: 0.75
//x: i * 400 //(i - item.ingredients.length / 2) * 400
});
var ingredientSprite = LK.getAsset('' + k, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.75,
scaleY: 0.75
//x: ingredientButton.x //i * 400 //(i - item.ingredients.length / 2) * 400
});
self.addChild(ingredientSprite);
self.moveTo = function (targetX, targetY, duration) {
var startX = self.x;
var startY = self.y;
var bezierPoints = generateBezierPoints({
x: startX,
y: startY
}, {
x: targetX,
y: targetY
}, {
x: 400,
//(startX + targetX) / 2,
y: 200 //startY - 200
}, {
x: 1600,
//(startX + targetX) / 2,
y: 200 //targetY + 200
}, duration * 60);
var currentTick = 0;
self.update = function () {
if (currentTick < bezierPoints.length) {
self.x = bezierPoints[currentTick].x;
self.y = bezierPoints[currentTick].y;
self.scale.x -= 0.003;
self.scale.y -= 0.003;
currentTick++;
} else {
self.x = targetX;
self.y = targetY;
// Stop updating once the target is reached
self.update = null;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
emptyGlass.updateText(Math.floor(100 * currentOrderedItemCompletion / currentOrderedItemSize));
// Check if drink is ready. (Todo: maybe wait a second while it mixes before removing it all.)
if (currentOrderedItemCompletion == currentOrderedItemSize) {
// Remove emptyGlass and ingredients and replace with the drink.
emptyGlass.destroy();
createStarExplosion(emptyGlass.x, emptyGlass.y);
for (var i = 0; i < ingredientButtons.length; i++) {
ingredientButtons[i].destroy();
}
ingredientButtons = [];
// Also remove the speechBubble here.
speechBubble.destroy();
// But we can maybe reuse the itemSprite instead of destroying.
itemSprite.x = 1500;
itemSprite.y = 1400;
itemSprite.scale.x = 2.2;
itemSprite.scale.y = 2.2;
// TODO: there could be a particle explosion here when the finished drink is revealed.
// TODO: Here, the itemSprite should animate to customer and scale down.
// TODO: Here a few coins should flip from customer to girl and money label be upgraded
//itemSprite.update = globalMoveTo;
}
}
};
};
// Event handler called when a press happens on element.
self.down = function (x, y, obj) {
// Code to execute when ingredientButton is pressed
//self.alpha = 0;
//self.update = self.moveToGlass();
//console.log(emptyGlass.x, emptyGlass.y);
ingredientButtonGraphics.alpha = 0;
currentOrderedItemCompletion++;
//self.moveTo(emptyGlass.x, emptyGlass.y, 1);
// Try to move the completion status of current order to give a Y position of theingredient in the glass
//var destY = currentOrderedItemCompletion * 200; // currentOrderedItemSize
var destY = emptyGlass.y + emptyGlass.height / 2 - currentOrderedItemCompletion * 150;
//self.moveTo(emptyGlass.x, emptyGlass.y + emptyGlass.height / 2 - destY, 1);
// Also try to give the X position a bit of variation / alternation.
var destX = currentOrderedItemCompletion % 2 == 0 ? 25 : -25;
self.moveTo(emptyGlass.x + destX, destY, 1);
self.down = null;
};
});
//<Assets used in the game will automatically appear here>
// Lemon class
var Lemon = Container.expand(function () {
var self = Container.call(this);
var lemonGraphics = self.attachAsset('lemon', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Lemon specific update logic
};
});
// LemonadeStand class
var LemonadeStand = Container.expand(function () {
var self = Container.call(this);
var standGraphics = self.attachAsset('stand', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Lemonade stand specific update logic
};
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.vx = 0;
self.vy = 0;
self.lifetime = 0;
self.update = function () {
self.x += self.vx;
self.y += self.vy;
self.lifetime--;
if (self.lifetime <= 0) {
self.destroy();
}
};
});
// Sugar class
var Sugar = Container.expand(function () {
var self = Container.call(this);
var sugarGraphics = self.attachAsset('sugar', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Sugar specific update logic
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Init game with sky blue background
});
/****
* Game Code
****/
/**
* Creates a star explosion effect at the specified coordinates.
*
* @param {Number} x - The x-coordinate of the explosion center.
* @param {Number} y - The y-coordinate of the explosion center.
*/
function createStarExplosion(x, y) {
var starCount = 20;
var starSpeed = 5;
var starLifetime = 60; // frames
for (var i = 0; i < starCount; i++) {
var star = new Star();
star.x = x;
star.y = y;
star.vx = starSpeed * (Math.random() - 0.5);
star.vy = starSpeed * (Math.random() - 0.5);
star.lifetime = starLifetime;
game.addChild(star);
}
}
function globalMoveTo() {
self.x--;
}
;
var lemonadeStand;
var scoreTxt;
var score = 0;
var background = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1,
x: 1024,
y: 2732 / 2
}));
function easeOutBounce(x) {
var n1 = 7.5625;
var d1 = 2.75;
if (x < 1 / d1) {
return n1 * x * x;
} else if (x < 2 / d1) {
return n1 * (x -= 1.5 / d1) * x + 0.75;
} else if (x < 2.5 / d1) {
return n1 * (x -= 2.25 / d1) * x + 0.9375;
} else {
return n1 * (x -= 2.625 / d1) * x + 0.984375;
}
}
;
function easeOutElastic(x) {
//var c4 = 2 * Math.PI / 3;
var c4 = 2 * Math.PI / .3;
//return x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
//return x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
return x === 0 ? 0 : x === 1 ? 1 : 0.25 * Math.pow(2, -5 * x) * Math.cos((x * 10 - 0.75) * c4) + 1;
}
// Initialize game elements
function initGameElements() {
// Create and position girl
var girl = new Girl();
girl.x = 2048 / 2;
girl.y = 2732 - 1150;
game.addChild(girl);
// Create and position lemonade stand
lemonadeStand = new LemonadeStand();
lemonadeStand.x = 2048 / 2;
lemonadeStand.y = 2732 - 1100;
game.addChild(lemonadeStand);
// Create and position score text
scoreTxt = new Text2('Score: 0', {
size: 100,
fill: "#ffffff",
stroke: '#000000',
strokeThickness: 10,
weight: 300
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
}
// Update score
function updateScore() {
scoreTxt.setText('Score: ' + score);
}
var customerTypes = [Customer1, Customer2, Customer3, Customer4, Customer5, Customer6, Customer7, Customer8];
var customers = [];
for (var i = 0; i < 7; i++) {
var t = new customerTypes[Math.floor(Math.random() * customerTypes.length)]();
t.y = 1800;
t.x = 500 - 250 * i - 50;
t.anchorY = 2;
game.addChild(t);
customers.push(t);
}
// Initialize game elements
initGameElements();
var backgroundOverlay = game.addChild(LK.getAsset('backgroundOverlay', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1,
x: 1024,
y: 2732 / 2
}));
var lemonade = {
sprite: 'lemonade',
offsetX: 25,
offsetY: -300,
ingredients: ['lemon', 'sugar', 'water'],
price: 5
};
var availableItems = [lemonade];
var currentOrder;
var currentOrderedItemSize = 0;
var currentOrderedItemCompletion = 0;
var ingredientButtons = [];
var speecBubble;
var itemSprite;
function orderSomething(obj) {
var item = availableItems[Math.floor(Math.random() * availableItems.length)];
currentOrder = item; // just to have a reference in the gobal scope.
speechBubble = LK.getAsset('speechBubble', {
anchorX: 0.5,
anchorY: 1,
scaleX: 0.5,
scaleY: 0.5,
x: obj.x - 250,
y: obj.y - obj.height / 2 - 50,
rotation: 0.12,
alpha: 0.9
});
game.addChild(speechBubble);
// Add the sprite of the ordered item inside the speech bubble
itemSprite = LK.getAsset(item.sprite, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1,
x: speechBubble.x + item.offsetX,
y: speechBubble.y + item.offsetY
});
game.addChild(itemSprite);
// Display the ingredients of the ordered item at the bottom center of the screen
/*ingredientsContainer = new Container();
ingredientsContainer.x = 2048 / 2;
ingredientsContainer.y = 2732 - 400;
game.addChild(ingredientsContainer);
game.addChild(ingredientsContainer);*/
currentOrderedItemCompletion = 0;
currentOrderedItemSize = item.ingredients.length;
for (var i = 0; i < currentOrderedItemSize; i++) {
var ingredientButton = new IngredientButton(i, item.ingredients[i]);
ingredientButton.x = i * 400;
ingredientButton.y = 2732 - 400;
//ingredientsContainer.addChild(ingredientButton);
game.addChild(ingredientButton);
ingredientButton.x += 400 * currentOrderedItemSize / 2;
ingredientButtons.push(ingredientButton);
}
//ingredientsContainer.x = 1024; //(2048 - ingredientsContainer.width) / 2;
//ingredientsContainer.x -= ingredientsContainer.width / 2 - 200;
// Add an empty glass
emptyGlass = new EmptyGlass();
game.addChild(emptyGlass);
emptyGlass.x = 1600;
emptyGlass.y = 1400;
}
/**
* Generates an array of points along a two-point Bezier curve.
*
* @param {Object} start - The starting point of the curve {x: Number, y: Number}.
* @param {Object} end - The ending point of the curve {x: Number, y: Number}.
* @param {Object} anchor1 - The first anchor point of the curve {x: Number, y: Number}.
* @param {Object} anchor2 - The second anchor point of the curve {x: Number, y: Number}.
* @param {Number} n - The number of points to generate along the curve.
* @returns {Array} - An array of points along the Bezier curve.
*/
function generateBezierPoints(start, end, anchor1, anchor2, n) {
var points = [];
for (var i = 0; i <= n; i++) {
var t = i / n;
var x = Math.pow(1 - t, 3) * start.x + 3 * Math.pow(1 - t, 2) * t * anchor1.x + 3 * (1 - t) * Math.pow(t, 2) * anchor2.x + Math.pow(t, 3) * end.x;
var y = Math.pow(1 - t, 3) * start.y + 3 * Math.pow(1 - t, 2) * t * anchor1.y + 3 * (1 - t) * Math.pow(t, 2) * anchor2.y + Math.pow(t, 3) * end.y;
points.push({
x: x,
y: y
});
}
return points;
}
;
var emptyGlass;
//var harvestedCounter = 0;
var queueSpeed = 3;
var queueUpdateCounter = 0;
var queueUpdateMax = 200 / queueSpeed;
var orderPlaced = false;
function updateCustomers() {
if (queueUpdateCounter < queueUpdateMax) {
queueUpdateCounter++;
for (var i = 0; i < customers.length; i++) {
customers[i].x += queueSpeed;
customers[i].y += Math.cos(LK.ticks / 2) * 15 * (Math.random() * 0.3 + 0.7);
customers[i].rotation += 0.05 - Math.random() * 0.1;
//customers[i].rotation += LK.ticks % 6 < 3 ? 0.05 : -0.05;
}
} else if (queueUpdateCounter >= queueUpdateMax && !orderPlaced) {
for (var i = 0; i < customers.length; i++) {
customers[i].rotation = 0;
customers[i].y = 1800;
}
orderSomething(customers[0]);
orderPlaced = true;
}
}
;
game.update = function () {
updateCustomers();
//itemSprite.update();
};
A beautiful scenery looking out to sea from an empty beach side promenade on a bright summer day. Happy game illustration style for a casual family friendly game.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
remove the glass and the crate of lemons from the table.
A simple, elegant white speech bubble.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A lemon with a few slices cut off.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A bag of white sugar, open and with a pile of the sugar in front of it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A pitcher full of nice fresh water and ice cubes.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round white button for an interface element.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An empty drinking glass.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A yellow star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A red heart. simple.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A nice glass of watermelon and strawberry slushice. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A nice glass of banana milkshake. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A nice glass of pina colada. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A nice glass of mango lassie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An orange. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A couple of blueberries. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A couple of bananas. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A bottle of milk. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A watermelon and some pieces of watermelon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A mango and a few slices of mango. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A pineapple with a few slices of pineapple in front. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A fullscreen background gui element for an in-game shop. It should be mostly blanks space, but along the edges there could be some structure or decorative vines and items, mostly related to fruits, berries, cocktails in a summer theme.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A modern dream of a sailing boat. game illustration.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A bold green checkmark.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An idyllic llustration of a beach cove where a blnd girl in a strawhat i en joying an enormous strawberry drink on her sailing boat as the sun sets. Clean game art illustration style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An idyllic llustration of a beach cove where a blond girl in a straw hat is enjoying an large strawberry drink on the deck of her sailing boat as the sun sets. Clean game illustration style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.