Code edit (14 edits merged)
Please save this source code
User prompt
Please fix the bug: 'timeout callback must be a function' in or related to this line: 'LK.setTimeout(60, showNoCandlesMessage);' Line Number: 573
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
after the topdecoration layer has been added, drop 10 candles down from the top of the screen and onto the topdecoration layer in an elliptical pattern.
Code edit (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: TopDecoration is not defined' in or related to this line: 'var newLayer = new TopDecoration(currentCakeHeight);' Line Number: 446
Code edit (2 edits merged)
Please save this source code
User prompt
where it says "scoreLabel.flash(red);" in the code, please make the scorelabel actualy flash in a red color
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: stars is not defined' in or related to this line: 'for (var i = stars.length - 1; i >= 0; i--) {' Line Number: 401
User prompt
add the stars to the stars array and update them from game tick function.
User prompt
the stars should explode upwards in all directions and then drop down while they fade out and disappear
User prompt
whenever score increases, create a particle explosion of stars around the scorelabel
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
in the handleButtons function, add a copy of the button clicked to the latest cakelayer added.
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: button.parent.numChildren is not a function' in or related to this line: 'console.log('button.parent.children.length - 1: ' + button.parent.numChildren() - 1);' Line Number: 358
Code edit (1 edits merged)
Please save this source code
User prompt
show a scorelabel center top
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Error: The supplied index is out of bounds' in or related to this line: 'button.parent.setChildIndex(button, button.parent.getChildIndex(latestCakeLayer) + 1);' Line Number: 356
User prompt
in handlebuttons, also move the pressed button to a layer above the latest cake layer.
===================================================================
--- original.js
+++ change.js
@@ -57,11 +57,22 @@
var candleGraphic = self.attachAsset('candle', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 5;
+ self.targetY = 0;
+ self.speed = 60;
+ self.delay = 0;
+ self.waited = 0;
self.move = function () {
- self.y += self.speed;
+ if (self.waited < self.delay) {
+ self.waited++;
+ } else {
+ if (self.y < self.targetY) {
+ self.y += self.speed;
+ } else {
+ self.y = self.targetY;
+ }
+ }
};
});
// Filling class
var Filling = Container.expand(function (type) {
@@ -311,8 +322,9 @@
return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
}
var cakeLayers = [];
var fillings = [];
+var candles = [];
var currentCakeHeight = 0;
var score = 0;
var stars = []; // Define stars array to track star particles
// Create a draggable cake base
@@ -430,8 +442,34 @@
}
}
}
;
+function showGameOverMessage() {
+ console.log('showgameovermessage');
+ var msgLabel = new Text2('Congratulations!\nYou added ' + score + ' fillings to your cake\nAnd got ' + score + ' candles', {
+ size: 200,
+ fill: "#ffffff",
+ align: "center"
+ });
+ msgLabel.x = game.width / 2;
+ msgLabel.y = 1200;
+ msgLabel.anchor.set(0.5, 0);
+ game.addChild(msgLabel);
+}
+;
+function showNoCandlesMessage() {
+ console.log('shownocandlesmessage');
+ var msgLabel = new Text2('You added the wrong fillings to your cake.\nPlease try again for a better result.', {
+ size: 200,
+ fill: "#ffffff",
+ align: "center"
+ });
+ msgLabel.x = game.width / 2;
+ msgLabel.y = 1200;
+ msgLabel.anchor.set(0.5, 0);
+ game.addChild(msgLabel);
+}
+;
var scoreLabel = new Text2('0', {
size: 200,
fill: "#ffffff",
align: "center"
@@ -464,8 +502,11 @@
cakeLayers[i].destroy();
cakeLayers.splice(i, 1);
}*/
}
+ for (var i = candles.length - 1; i >= 0; i--) {
+ candles[i].move();
+ }
// Spawn cake layers and fillings
if (LK.ticks % 180 === 0 && currentCakeHeight < 1200) {
var newLayer = new CakeLayer(currentCakeHeight);
newLayer.x = game.width / 2;
@@ -473,24 +514,41 @@
cakeLayers.push(newLayer);
game.addChild(newLayer);
currentCakeHeight += currentCakeHeight == 0 ? 1 : 150;
} else if (LK.ticks % 180 === 0 && currentCakeHeight > 1200 && currentCakeHeight < 1300) {
+ //remove buttons for fillings
+ goodFill.forEach(function (i) {
+ i.y = 4000;
+ });
+ badFill.forEach(function (i) {
+ i.y = 4000;
+ });
+ //create the final top layer of the cake
var newLayer = new TopDecoration(currentCakeHeight);
newLayer.x = game.width / 2;
newLayer.y = -newLayer.height / 2;
cakeLayers.push(newLayer);
game.addChild(newLayer);
currentCakeHeight += 150;
- // Drop candles in an elliptical pattern on the top decoration layer
- var ellipseCenterX = game.width / 2;
- var ellipseCenterY = newLayer.y + 800;
- var ellipseRadiusX = newLayer.width; // Ellipse width
- var ellipseRadiusY = 300; // Ellipse height, smaller for a flatter ellipse
- for (var i = 0; i < 10; i++) {
- var angle = i / 10 * 2 * Math.PI; // Distribute candles evenly in a circle
- var candle = new Candle();
- candle.x = ellipseCenterX + ellipseRadiusX * Math.cos(angle);
- candle.y = ellipseCenterY + ellipseRadiusY * Math.sin(angle) - candle.height / 2; // Adjust for candle height
- game.addChild(candle);
+ if (score > 0) {
+ // Drop candles in an elliptical pattern on the top decoration layer, after a delay.
+ var ellipseCenterX = game.width / 2;
+ var ellipseCenterY = newLayer.y + 1000;
+ var ellipseRadiusX = newLayer.width / 2.5; // Ellipse width
+ var ellipseRadiusY = 50; // Ellipse height, smaller for a flatter ellipse
+ for (var i = 0; i < score; i++) {
+ var angle = i / score * 2 * Math.PI; // Distribute candles evenly in a circle
+ var candle = new Candle();
+ candle.x = ellipseCenterX + ellipseRadiusX * Math.cos(angle);
+ candle.targetY = ellipseCenterY + ellipseRadiusY * Math.sin(angle) - candle.height / 2; // Adjust for candle height
+ candle.y = -1000;
+ candle.delay = 60 + 15 * i;
+ game.addChild(candle);
+ candles.push(candle);
+ }
+ LK.setTimeout(60 + 15 * score + 10, showGameOverMessage);
+ } else {
+ //no candles
+ LK.setTimeout(showNoCandlesMessage, 60);
}
}
});
\ No newline at end of file
a dark wooden kitchen table with a serving plate.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A bakery wall with shelves full of cakes, toppings, berries. Rich game illustration style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A swirl of delicious whipped cream. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A small pile of delicious blueberries. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A few delicious red raspberries, cleaned.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Lush, mature strawberries, cleaned and slices and ready for use in bakery or for decoration.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A little green frog. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cute little goldfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A golden star.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A pile of pieces of milk chocolate. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.