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
@@ -53,20 +53,33 @@
self.bake = function () {};
self.flyToRandomPosition = function () {
var randomX = Math.random() * 2048;
var randomY = Math.random() * (2732 / 2);
- LK.on('tick', function () {
- if (self.y > randomY) {
- self.y -= 10;
- } else if (self.y < randomY) {
- self.y += 10;
+ self.elasticTween = function (start, end, duration, callback) {
+ var delta = end - start;
+ var startTime = LK.ticks;
+ function easeOutElastic(t, b, c, d) {
+ var ts = (t /= d) * t;
+ var tc = ts * t;
+ return b + c * (33 * tc * ts + -59 * ts * ts + 32 * tc + -5 * ts);
}
- if (self.x > randomX) {
- self.x -= 10;
- } else if (self.x < randomX) {
- self.x += 10;
- }
+ LK.on('tick', function () {
+ var currentTime = LK.ticks - startTime;
+ if (currentTime < duration) {
+ var newPos = easeOutElastic(currentTime, start, delta, duration);
+ callback(newPos);
+ } else {
+ callback(end);
+ LK.off('tick', this);
+ }
+ });
+ };
+ self.elasticTween(self.y, randomY, 120, function (newY) {
+ self.y = newY;
});
+ self.elasticTween(self.x, randomX, 120, function (newX) {
+ self.x = newX;
+ });
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
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.