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()
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
the emptyGlass' updateText function should make the fullText label display i as passed in parameter
Code edit (1 edits merged)
Please save this source code
User prompt
now use the beziercurve function to generate an overarching path from each ingredient to the center of the glass
User prompt
cool, please add the function to the game, soI can use it
/**** * Classes ****/ var CloseButton = Container.expand(function (shopInstance) { var self = Container.call(this); self.shopInstance = shopInstance; var itemBg = self.attachAsset('closeButton', { anchorX: 0.5, anchorY: 0.5, x: 740, y: -780 }); self.down = function (x, y, obj) { //shop.hide(); //console.log('closebutton clicked, shopInstance is: ' + self.shopInstance); //self.shopInstance.hide(); shop.visible = false; instructionTxt.setText('Tap to throw the javelin'); instructionTxt.alpha = 1; //self.shopInstance.hide(); }; }); var CustomerBase = Container.expand(function () { var self = Container.call(this); var sprite = 'customer' + Math.ceil(Math.random() * 8); var customerGraphics = self.attachAsset(sprite, { anchorX: 0.5, anchorY: 0.5 }); self.anchorX = 0.5; self.anchorY = 0.5; self.done = false; self.delay = 0; self.update = function () { if (self.done) { if (self.delay-- <= 0) { self.x += queueSpeed * 8; self.y += Math.cos(LK.ticks / 2) * 15 * (Math.random() * 0.3 + 0.7); self.rotation += 0.05 - Math.random() * 0.1; if (self.x > 2300) { self.destroy(); } } } }; }); // Customer1 class // 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 }; }); var Heart = Container.expand(function () { var self = Container.call(this); var heartGraphics = self.attachAsset('heart', { anchorX: 0.5, anchorY: 0.5 }); self.vx = 0; self.vy = 0; self.lifetime = 0; self.delay = 0; self.update = function () { if (self.delay-- <= 0) { self.x += self.vx; self.y += self.vy; self.lifetime--; if (self.lifetime <= 0) { self.destroy(); } } }; }); // 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 - 100, 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; // Move itemSprite to the rightmost customer and scale it down var rightmostCustomer = customers[0]; //customers[customers.length - 1]; moveDrinkToCustomer(itemSprite, rightmostCustomer.x, rightmostCustomer.y, 1); LK.setScore(LK.getScore() + currentOrder.price); scoreTxt.setText('$ ' + LK.getScore()); totalEarned += currentOrder.price; // TODO: Here a few coins should flip from customer to girl and money label be upgraded //customers[0].addChild(itemSprite); //waitCounter = 100; //itemSprite.destroy(); /* var customerDrink = LK.getAsset(currentOrder.sprite, { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.3, x: 50, y: 50 }); customers[0].addChild(customerDrink); */ /* customers[0].done = true; customers.splice(0, 1); // This causes the updateCustomers in game.update() to advance the queue. queueUpdateCounter = 0; orderPlaced = false; */ } } }; }; // 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 }); }); // LemonadeStand class var LemonadeStand = Container.expand(function () { var self = Container.call(this); var standGraphics = self.attachAsset('stand', { anchorX: 0.5, anchorY: 0.5 }); }); var ShopItem = Container.expand(function (id, price) { var self = Container.call(this); // Initialize shop item properties self.id = id; self.price = price; self.purchased = false; self.maxed = false; var itemBg = self.attachAsset('shopItemBackground', { anchorX: 0.5, anchorY: 0.5 }); // Attach asset based on the item id var itemGraphic = self.attachAsset(self.id, { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5 }); var nameTxt = new Text2('', { size: 38, fill: "#ffffff", stroke: 1, strokeColor: '#444444', align: 'center', anchorX: 0.5 }); //orangeJuice, strawberryDrink, watermelonDrink, bananaMilkshake, berriesDrink, pinaDrink, mangoLassie if (self.id == 'orangeJuice') { nameTxt.setText('Orange Juice'); } else if (self.id == 'strawberryDrink') { nameTxt.setText('Strawbery Daiquiry'); } else if (self.id == 'watermelonDrink') { nameTxt.setText('Melon Slush'); } else if (self.id == 'bananaMilkshake') { nameTxt.setText('Banana Milkshake'); } else if (self.id == 'berriesDrink') { nameTxt.setText('Berries Lemonade'); } else if (self.id == 'pinaDrink') { nameTxt.setText('PiƱa Colada'); } else if (self.id == 'mangoLassie') { nameTxt.setText('Mango Lassie'); } else if (self.id == 'yacht') { nameTxt.setText('Dream Boat'); } nameTxt.x = -self.width / 2; nameTxt.y = -self.height / 2 - nameTxt.height; self.addChild(nameTxt); var costTxt = new Text2('', { size: 38, fill: "#ffffff", stroke: 1, strokeColor: '#444444' }); costTxt.setText('' + self.price); costTxt.x = -30; costTxt.y = self.height / 2 - 65; self.addChild(costTxt); var upgradeButton = self.attachAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5 }); upgradeButton.scale.x = upgradeButton.scale.y = 0.9; upgradeButton.y = 275; var bTxt = new Text2('', { size: 42, fill: "#ffffff", stroke: 1, strokeColor: '#444444' }); bTxt.setText('Buy'); bTxt.x = -25; bTxt.y = self.height / 2 - 36; self.addChild(bTxt); // Add a click or tap event listener to handle item purchase /* self.down = function (x, y, obj) { if (!self.purchased && coins >= self.price) { coins -= self.price; self.purchased = true; // Logic to apply the purchased item effect console.log(self.id + " purchased!"); // Optionally, update the item's appearance to indicate it's purchased } else { console.log("Not enough coins or item already purchased."); } };*/ // Method to reset the item's purchase state (optional, depending on game design) self.reset = function () { self.purchased = false; // Optionally, update the item's appearance to indicate it's not purchased }; self.updateCost = function () { //console.log('updateCost called'); if (self.maxed) { costTxt.setText('MAX'); upgradeButton.destroy(); bTxt.destroy(); } else { costTxt.setText('' + self.price); if (coins < self.price) { //todo: maybe grey out. } } }; }); var ShopWindow = Container.expand(function () { var self = Container.call(this); // Initialize shop window properties and background graphic self.items = []; // Array to hold shop items self.x = 1024; // Center horizontally self.y = 1360; //1566; // Center vertically //self.visible = false; // Initially hidden self.scale.x = 1.0; self.scale.y = 1.0; // Add background graphic to shop window var backgroundGraphic = self.attachAsset('shopBackground', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); // [orangeJuice, strawberryDrink, watermelonDrink, bananaMilkshake, berriesDrink, pinaDrink, mangoLassie] // 7,10,12,15,20,25,30 self.addChild(backgroundGraphic); var item1 = new ShopItem('orangeJuice', 30); item1.x = -450; item1.y = -400; var item2 = new ShopItem('strawberryDrink', 50); item2.x = -150; item2.y = -400; var item3 = new ShopItem('watermelonDrink', 75); item3.x = 150; item3.y = -400; var item4 = new ShopItem('bananaMilkshake', 100); item4.x = 450; item4.y = -400; var item5 = new ShopItem('berriesDrink', 150); item5.x = -450; item5.y = 200; var item6 = new ShopItem('pinaDrink', 200); item6.x = -150; item6.y = 200; var item7 = new ShopItem('mangoLassie', 300); item7.x = 150; item7.y = 200; var item8 = new ShopItem('yacht', 1000); item8.x = 450; item8.y = 200; self.addChild(item1); self.addChild(item2); self.addChild(item3); self.addChild(item4); self.addChild(item5); self.addChild(item6); self.addChild(item7); self.addChild(item8); item1.down = function (x, y, obj) { //console.log('item1 clicked, price =', item1.price); if (coins >= item1.price && !item1.maxed) { coins -= item1.price; item1.price *= 2; if (item1.price >= 640) { item1.maxed = true; } //updateCoinsText(); } }; item2.down = function (x, y, obj) { //console.log('item2 clicked, price =', item2.price); if (coins >= item2.price && !item2.maxed) { coins -= item2.price; item2.price *= 2; if (item2.price >= 240) { item2.maxed = true; } //updateCoinsText(); //game.addChild(shop); } }; item3.down = function (x, y, obj) { if (coins >= item3.price && !item3.maxed) { coins -= item3.price; item3.maxed = true; updateCoinsText(); } }; var shopTxt = new Text2('Time to shop for new recipies', { size: 80, fill: "#ffffff", stroke: "#000000", strokeThickness: 10, align: 'center', weight: 800 }); shopTxt.anchor.set(0.5, 0.5); // Sets anchor to the center of the bottom edge of the text. shopTxt.y = -self.height / 2 + 700; self.addChild(shopTxt); var closeButton = new CloseButton(self); /*var closeButton = self.attachAsset('closeButton', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 800 });*/ self.addChild(closeButton); //closeButton.down = function (x, y, obj) { // Method to show the shop window self.show = function () { self.visible = true; // Additional logic to animate the shop window appearance could be added here }; // Method to hide the shop window self.hide = function () { self.visible = false; // Additional logic to animate the shop window disappearance could be added here }; }); 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 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Init game with sky blue background }); /**** * Game Code ****/ var instructionTxt; function updateCoinsText() { coinsTxt.setText('Star Coins: ' + coins); } var coins = 0; function createHeartExplosion(x, y) { y -= 50; var heartCount = 5; var heartSpeed = 6; var heartLifetime = 60; // frames for (var i = 0; i < heartCount; i++) { var heart = new Heart(); heart.x = x; heart.y = y; // - 30 * i; heart.delay = i * 6; heart.vx = (Math.random() - 0.5) * heartSpeed * 0.2; heart.vy = -heartSpeed; //-Math.random() * heartSpeed; heart.lifetime = heartLifetime; game.addChild(heart); } } /** * 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 = 30; var starLifetime = 120; // frames for (var i = 0; i < starCount; i++) { var star = new Star(); star.x = x; star.y = y; var angle = i / starCount * 2 * Math.PI; star.vx = starSpeed * Math.cos(angle); star.vy = starSpeed * Math.sin(angle); 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('$ 0', { size: 100, fill: "#33ee33", stroke: '#000000', strokeThickness: 10, weight: 300 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); } // Update score function updateScore() { scoreTxt.setText('$ ' + score); } // Initialize game elements initGameElements(); var customerTypes = [CustomerBase]; //[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)](); var t = new CustomerBase(); t.y = 1800; t.x = 500 - 250 * i - 50; t.anchorY = 2; game.addChild(t); customers.push(t); } 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 orangeJuice = { sprite: 'orangeJuice', offsetX: 60, offsetY: -300, ingredients: ['orange', 'water'], price: 7 }; var strawberryDrink = { sprite: 'strawberryDrink', offsetX: 25, offsetY: -300, ingredients: ['strawberry', 'sugar', 'water'], price: 10 }; var watermelonDrink = { sprite: 'watermelonDrink', offsetX: 45, offsetY: -320, ingredients: ['watermelon', 'strawberry', 'water'], price: 12 }; var bananaMilkshake = { sprite: 'bananaMilkshake', offsetX: 45, offsetY: -300, ingredients: ['banana', 'milk', 'water'], price: 15 }; var berriesDrink = { sprite: 'berriesDrink', offsetX: 45, offsetY: -300, ingredients: ['strawberry', 'blueberry', 'sugar', 'water'], price: 20 }; var pinaDrink = { sprite: 'pinaDrink', offsetX: 25, offsetY: -300, ingredients: ['coconut', 'pineapple', 'milk'], price: 25 }; var mangoLassie = { sprite: 'mangoLassie', offsetX: 45, offsetY: -300, ingredients: ['mango', 'sugar', 'milk'], price: 30 }; var allIngredients = ['orange', 'coconut', 'pineapple', 'milk', 'blueberry', 'strawberry', 'watermelon', 'banana', 'sugar', 'water']; var lockedItems = [orangeJuice, strawberryDrink, watermelonDrink, bananaMilkshake, berriesDrink, pinaDrink, mangoLassie]; var availableItems = [mangoLassie]; //[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 - 500; //ingredientsContainer.addChild(ingredientButton); game.addChild(ingredientButton); //ingredientButton.x += 400 * currentOrderedItemSize / 2; //ingredientButton.x += 400 * currentOrderedItemSize / 2; if (currentOrderedItemSize == 2) { ingredientButton.x += 800; } else if (currentOrderedItemSize == 3) { ingredientButton.x += 600; } else if (currentOrderedItemSize == 4) { ingredientButton.x += 400; // += 200; } 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 totalEarned = 0; var emptyGlass; //var harvestedCounter = 0; var queueSpeed = 3; var queueUpdateCounter = 0; var queueUpdateMax = 240 / queueSpeed; var orderPlaced = false; var waitCounter = 0; function updateCustomers() { if (waitCounter-- > 0) {} else { 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; } } } ; var shop = new ShopWindow(); game.addChild(shop); //game.addChild(shop); game.update = function () { updateCustomers(); //itemSprite.update(); }; function moveDrinkToCustomer(sprite, targetX, targetY, duration) { targetX += 50; targetY += 50; var startX = sprite.x; var startY = sprite.y; var startScaleX = sprite.scale.x; var startScaleY = sprite.scale.y; var endScale = 0.3; var bezierPoints = generateBezierPoints({ x: startX, y: startY }, { x: targetX, y: targetY }, { x: (startX + targetX) / 2, y: startY - 200 }, { x: (startX + targetX) / 2, y: targetY + 200 }, duration * 60); var currentTick = 0; sprite.update = function () { if (currentTick < bezierPoints.length) { sprite.x = bezierPoints[currentTick].x; sprite.y = bezierPoints[currentTick].y; sprite.scale.x = startScaleX - (startScaleX - endScale) * (currentTick / bezierPoints.length); sprite.scale.y = startScaleY - (startScaleY - endScale) * (currentTick / bezierPoints.length); currentTick++; } else { sprite.x = 3000; sprite.y = targetY; sprite.scale.x = endScale; sprite.scale.y = endScale; sprite.update = null; createHeartExplosion(targetX, targetY - 100); var customerDrink = LK.getAsset(currentOrder.sprite, { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.3, x: 50, y: 50 }); customers[0].addChild(customerDrink); customers[0].done = true; customers.splice(0, 1); // This causes the updateCustomers in game.update() to advance the queue. queueUpdateCounter = 0; orderPlaced = false; } }; }
===================================================================
--- original.js
+++ change.js
@@ -322,22 +322,16 @@
});
upgradeButton.scale.x = upgradeButton.scale.y = 0.9;
upgradeButton.y = 275;
var bTxt = new Text2('', {
- size: 32,
+ size: 42,
fill: "#ffffff",
- dropShadow: true,
- dropShadowColor: '#000000',
- dropShadowAngle: Math.PI / 6,
- dropShadowDistance: 5
+ stroke: 1,
+ strokeColor: '#444444'
});
- bTxt.setText('UPGRADE');
- bTxt.x = -64;
- bTxt.y = self.height / 2 - 62;
- if (self.id == 'shopItem3') {
- bTxt.x = -30;
- bTxt.setText('BUY');
- }
+ bTxt.setText('Buy');
+ bTxt.x = -25;
+ bTxt.y = self.height / 2 - 36;
self.addChild(bTxt);
// Add a click or tap event listener to handle item purchase
/*
self.down = function (x, y, obj) {
@@ -386,31 +380,32 @@
x: 0,
y: 0
});
// [orangeJuice, strawberryDrink, watermelonDrink, bananaMilkshake, berriesDrink, pinaDrink, mangoLassie]
+ // 7,10,12,15,20,25,30
self.addChild(backgroundGraphic);
- var item1 = new ShopItem('orangeJuice', 10);
+ var item1 = new ShopItem('orangeJuice', 30);
item1.x = -450;
item1.y = -400;
- var item2 = new ShopItem('strawberryDrink', 15);
+ var item2 = new ShopItem('strawberryDrink', 50);
item2.x = -150;
item2.y = -400;
- var item3 = new ShopItem('watermelonDrink', 100);
+ var item3 = new ShopItem('watermelonDrink', 75);
item3.x = 150;
item3.y = -400;
- var item4 = new ShopItem('bananaMilkshake', 10);
+ var item4 = new ShopItem('bananaMilkshake', 100);
item4.x = 450;
item4.y = -400;
- var item5 = new ShopItem('berriesDrink', 15);
+ var item5 = new ShopItem('berriesDrink', 150);
item5.x = -450;
item5.y = 200;
- var item6 = new ShopItem('pinaDrink', 100);
+ var item6 = new ShopItem('pinaDrink', 200);
item6.x = -150;
item6.y = 200;
- var item7 = new ShopItem('mangoLassie', 10);
+ var item7 = new ShopItem('mangoLassie', 300);
item7.x = 150;
item7.y = 200;
- var item8 = new ShopItem('yacht', 15);
+ var item8 = new ShopItem('yacht', 1000);
item8.x = 450;
item8.y = 200;
self.addChild(item1);
self.addChild(item2);
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.