Code edit (9 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: easeOutElastic is not defined' in this line: 'var newPos = easeOutElastic(currentTime, start, delta, duration);' Line Number: 69
User prompt
the elastic tween should have both easein and easeout
User prompt
cookie flying should be an elastic tween
User prompt
each spawned cookie should fly to a random positionon top half of screen
Code edit (5 edits merged)
Please save this source code
User prompt
when player clicks on a bowl that has both sugar, egg, and butter, create a cookie
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: self.unpack is not a function' in this line: 'self.unpack();' Line Number: 63
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in this line: 'self.x = bowl.x + bowl.width / 2;' Line Number: 30
Code edit (3 edits merged)
Please save this source code
User prompt
all eggs should spawn at x 200 to 1800
User prompt
all butters should spawn at x 200 to 1800
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: sugars is not defined' in this line: 'var bowlIndex = sugars.indexOf(self);' Line Number: 27
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: sugars is not defined' in this line: 'var bowlIndex = sugars.indexOf(self);' Line Number: 27
User prompt
Fix Bug: 'ReferenceError: sugars is not defined' in this line: 'var bowlIndex = sugars.indexOf(self);' Line Number: 27
User prompt
Fix Bug: 'ReferenceError: sugars is not defined' in this line: 'var bowlIndex = sugars.indexOf(self);' Line Number: 27
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: sugars is not defined' in this line: 'var bowlIndex = sugars.indexOf(self);' Line Number: 27
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: sugars is not defined' in this line: 'var bowlIndex = sugars.indexOf(self);' Line Number: 27
===================================================================
--- original.js
+++ change.js
@@ -3,8 +3,14 @@
var bowlGraphics = self.createAsset('bowl', 'Bowl Graphics', 0, 1);
self.width = bowlGraphics.width;
self.x = 0;
self.y = 2732 - bowlGraphics.height;
+ self.containsPoint = function (point) {
+ return point.x >= this.x && point.x <= this.x + this.width && point.y >= this.y && point.y <= this.y + this.height;
+ };
+ self.hasEgg = false;
+ self.hasSugar = false;
+ self.hasButter = false;
});
var Egg = Container.expand(function () {
var self = Container.call(this);
var eggGraphics = self.createAsset('egg', 'Egg Graphics', .5, .5);
@@ -49,29 +55,42 @@
var Game = Container.expand(function () {
var self = Container.call(this);
stage.on('down', function (obj) {
var pos = obj.event.getLocalPosition(self);
+ bowls.forEach(function (bowl, index) {
+ if (bowl.containsPoint(pos) && bowl.hasEgg && bowl.hasSugar && bowl.hasButter) {
+ var cookie = new Cookie();
+ cookie.x = bowl.x + bowl.width / 2;
+ cookie.y = bowl.y - cookie.height / 2;
+ self.addChild(cookie);
+ cookies.push(cookie);
+ }
+ });
eggs.forEach(function (egg, index) {
if (egg.containsPoint(pos)) {
egg.crack();
- egg.x = bowls[index % bowls.length].x + bowls[index % bowls.length].width / 2;
- egg.y = bowls[index % bowls.length].y - egg.height - 50;
+ var targetBowl = bowls[index % bowls.length];
+ egg.x = targetBowl.x + targetBowl.width / 2 + 60;
+ egg.y = targetBowl.y - egg.height - 50;
+ targetBowl.hasEgg = true;
}
});
butters.forEach(function (butter, index) {
if (butter.containsPoint(pos)) {
var targetBowl = bowls[index % bowls.length];
butter.unpack(targetBowl);
- butter.x = targetBowl.x + targetBowl.width / 2;
- butter.y = targetBowl.y - butter.height;
+ butter.x = targetBowl.x + targetBowl.width / 2 - 60;
+ butter.y = targetBowl.y - butter.height - 50;
+ targetBowl.hasButter = true;
}
});
sugars.forEach(function (sugar, index) {
if (sugar.containsPoint(pos)) {
var targetBowl = bowls[index % bowls.length];
sugar.pour();
sugar.x = targetBowl.x + targetBowl.width / 2;
sugar.y = targetBowl.y - sugar.height;
+ targetBowl.hasSugar = true;
}
});
});
var bowls = [];
@@ -83,18 +102,18 @@
var bowl = new Bowl();
bowl.x = i * (bowl.width + 10);
bowls.push(bowl);
self.addChild(bowl);
- var butter = new Butter();
- butter.x = 200 + Math.random() * 1600;
- butter.y = 200 + Math.random() * 2032;
- butters.push(butter);
- self.addChild(butter);
var sugar = new Sugar();
sugar.x = 200 + Math.random() * 1600;
sugar.y = 200 + Math.random() * 2032;
sugars.push(sugar);
self.addChild(sugar);
+ var butter = new Butter();
+ butter.x = 200 + Math.random() * 1600;
+ butter.y = 200 + Math.random() * 2032;
+ butters.push(butter);
+ self.addChild(butter);
var egg = new Egg();
egg.x = 200 + Math.random() * 1600;
egg.y = 200 + Math.random() * 2032;
eggs.push(egg);
egg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
sugar in a bag. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a butter stik in its wrapper. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a pink kithen bowl. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pile of sugar. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cracked egg white and yolk seeping. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
soft butter stick. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A delicious plain vanilla cookie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A delicious plain vanilla cookie, where three bites have been taken. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cute kawaian bakery interior with strawberry tiles. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cute girl happily eating way too many vanilla cookies. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.