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()
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
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,26 @@
/****
* 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: 0,
+ y: 800
+ });
+ 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, {
@@ -39,9 +58,9 @@
anchorX: 0.5,
anchorY: 0.5,
alpha: 1,
tint: '0xffff00'
- });*/
+ });*/
var fullText = new Text2('0%', {
size: 100,
fill: "#ffffff",
stroke: '#000000',
@@ -152,10 +171,10 @@
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());
+ //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.
@@ -174,8 +193,11 @@
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();
@@ -236,8 +258,218 @@
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
+ });
+ var nameTxt = new Text2('', {
+ size: 38,
+ fill: "#ffffff",
+ dropShadow: true,
+ dropShadowColor: '#000000',
+ dropShadowAngle: Math.PI / 6,
+ dropShadowDistance: 5
+ });
+ if (self.id == 'shopItem1') {
+ nameTxt.setText(' Strength \n Increases your\n throw distance');
+ } else if (self.id == 'shopItem2') {
+ nameTxt.setText(' Mana \n More wandering\n stars appear');
+ } else if (self.id == 'shopItem3') {
+ nameTxt.setText(' Signals\n Summon the\n unknown');
+ }
+ nameTxt.x = -self.width / 2;
+ nameTxt.y = -self.height / 2 - nameTxt.height;
+ self.addChild(nameTxt);
+ var costTxt = new Text2('', {
+ size: 38,
+ fill: "#ffffff",
+ dropShadow: true,
+ dropShadowColor: '#000000',
+ dropShadowAngle: Math.PI / 6,
+ dropShadowDistance: 5
+ });
+ 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: 32,
+ fill: "#ffffff",
+ dropShadow: true,
+ dropShadowColor: '#000000',
+ dropShadowAngle: Math.PI / 6,
+ dropShadowDistance: 5
+ });
+ bTxt.setText('UPGRADE');
+ bTxt.x = -64;
+ bTxt.y = self.height / 2 - 62;
+ if (self.id == 'shopItem3') {
+ bTxt.x = -30;
+ bTxt.setText('BUY');
+ }
+ 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
+ });
+ self.addChild(backgroundGraphic);
+ var item1 = new ShopItem('shopItem1', 10);
+ item1.x = -280;
+ item1.y = -20;
+ var item2 = new ShopItem('shopItem2', 15);
+ item2.x = 0;
+ item2.y = -20;
+ var item3 = new ShopItem('shopItem3', 100);
+ item3.x = 280;
+ item3.y = -20;
+ self.addChild(item1);
+ self.addChild(item2);
+ self.addChild(item3);
+ 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;
+ }
+ item1.updateCost();
+ updateCoinsText();
+ midSpeed += 0.004;
+ radiusUpdates++;
+ }
+ };
+ 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;
+ }
+ item2.updateCost();
+ updateCoinsText();
+ for (var i = 0; i < 5; i++) {
+ var starPowerup = new StarPowerup();
+ starpowerups.push(starPowerup);
+ game.addChild(starPowerup);
+ }
+ game.addChild(shop); // Ensure shop layer is on top of the new starpowerups
+ }
+ };
+ item3.down = function (x, y, obj) {
+ if (coins >= item3.price && !item3.maxed) {
+ coins -= item3.price;
+ item3.maxed = true;
+ item3.updateCost();
+ updateCoinsText();
+ /*
+ UFO_ON = true;
+ var ufo = new Ufo();
+ ufo.x = 1000;
+ ufo.y = 1300;
+ game.addChild(ufo);
+ */
+ createUfo();
+ game.addChild(shop); // Ensure shop layer is on top of the new starpowerups
+ }
+ };
+ var shopTxt = new Text2('SHOP\nHere you can spend the Star Coins you earned.', {
+ size: 80,
+ fill: "#ffffff",
+ dropShadow: true,
+ dropShadowColor: '#000000',
+ dropShadowAngle: Math.PI / 6,
+ dropShadowDistance: 5,
+ align: 'center'
+ });
+ shopTxt.anchor.set(0.5, 0.5); // Sets anchor to the center of the bottom edge of the text.
+ shopTxt.y = -self.height / 2 + 50;
+ 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,
@@ -273,8 +505,12 @@
/****
* Game Code
****/
+function updateCoinsText() {
+ coinsTxt.setText('Star Coins: ' + coins);
+}
+var coins = 0;
function createHeartExplosion(x, y) {
y -= 50;
var heartCount = 5;
var heartSpeed = 6;
@@ -359,11 +595,11 @@
lemonadeStand.x = 2048 / 2;
lemonadeStand.y = 2732 - 1100;
game.addChild(lemonadeStand);
// Create and position score text
- scoreTxt = new Text2('Score: 0', {
+ scoreTxt = new Text2('$ 0', {
size: 100,
- fill: "#ffffff",
+ fill: "#33ee33",
stroke: '#000000',
strokeThickness: 10,
weight: 300
});
@@ -371,9 +607,9 @@
LK.gui.top.addChild(scoreTxt);
}
// Update score
function updateScore() {
- scoreTxt.setText('Score: ' + score);
+ scoreTxt.setText('$ ' + score);
}
// Initialize game elements
initGameElements();
var customerTypes = [CustomerBase]; //[Customer1, Customer2, Customer3, Customer4, Customer5, Customer6, Customer7, Customer8];
@@ -445,16 +681,16 @@
price: 25
};
var mangoLassie = {
sprite: 'mangoLassie',
- offsetX: 25,
+ 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 = [berriesDrink]; //[lemonade];
+var availableItems = [mangoLassie]; //[lemonade];
var currentOrder;
var currentOrderedItemSize = 0;
var currentOrderedItemCompletion = 0;
var ingredientButtons = [];
@@ -540,8 +776,9 @@
}
return points;
}
;
+var totalEarned = 0;
var emptyGlass;
//var harvestedCounter = 0;
var queueSpeed = 3;
var queueUpdateCounter = 0;
@@ -568,8 +805,11 @@
}
}
}
;
+var shop = new ShopWindow();
+game.addChild(shop);
+//game.addChild(shop);
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.