Code edit (1 edits merged)
Please save this source code
User prompt
Magical Tea Party
Initial prompt
Toca tea party 🫖☕️ (2011). Help blossom 🩷, bubbles 💙, and buttercup 💚 have a tea party 🫖? Tap on the cake to eat it, tap on the teapot to pour tea for the cups, tap on the gift to open it, they be party horns, kazoos, and a doll inside gifts
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Cake = Container.expand(function () {
var self = Container.call(this);
var cakeGraphics = self.attachAsset('cake', {
anchorX: 0.5,
anchorY: 0.5
});
self.eaten = false;
self.down = function (x, y, obj) {
if (self.eaten) return;
self.eaten = true;
LK.getSound('eat').play();
tween(cakeGraphics, {
scaleX: 0,
scaleY: 0,
alpha: 0
}, {
duration: 500,
easing: tween.easeIn,
onFinish: function onFinish() {
self.eaten = false;
cakeGraphics.scaleX = 1;
cakeGraphics.scaleY = 1;
cakeGraphics.alpha = 1;
}
});
// Make nearest character eat
var nearestCharacter = null;
var minDistance = Infinity;
for (var i = 0; i < characters.length; i++) {
var character = characters[i];
var distance = Math.sqrt(Math.pow(character.x - self.x, 2) + Math.pow(character.y - self.y, 2));
if (distance < minDistance) {
minDistance = distance;
nearestCharacter = character;
}
}
if (nearestCharacter) {
nearestCharacter.playEatAnimation();
}
};
return self;
});
var Character = Container.expand(function (characterColor, name) {
var self = Container.call(this);
var body = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 1,
color: characterColor
});
self.name = name;
self.isEating = false;
self.playEatAnimation = function () {
if (self.isEating) return;
self.isEating = true;
tween(body, {
scaleY: 0.8
}, {
duration: 200,
easing: tween.easeInOut
});
tween(body, {
scaleY: 1
}, {
duration: 200,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.isEating = false;
}
});
LK.getSound('cheer').play();
};
return self;
});
var GiftBox = Container.expand(function () {
var self = Container.call(this);
var boxGraphics = self.attachAsset('giftbox', {
anchorX: 0.5,
anchorY: 0.5
});
self.opened = false;
self.down = function (x, y, obj) {
if (self.opened) return;
self.opened = true;
LK.getSound('unwrap').play();
// Box opening animation
tween(boxGraphics, {
scaleY: 0.1,
alpha: 0.5
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
// Create random gift
var giftTypes = ['horn', 'kazoo', 'doll'];
var randomGift = giftTypes[Math.floor(Math.random() * giftTypes.length)];
var gift = self.addChild(LK.getAsset(randomGift, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0,
scaleY: 0
}));
// Gift pop-out animation
tween(gift, {
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.bounceOut
});
// Reset box after delay
LK.setTimeout(function () {
gift.destroy();
self.opened = false;
boxGraphics.scaleY = 1;
boxGraphics.alpha = 1;
}, 3000);
}
});
};
return self;
});
var TeaCup = Container.expand(function () {
var self = Container.call(this);
var cupGraphics = self.attachAsset('teacup', {
anchorX: 0.5,
anchorY: 0.5
});
self.filled = false;
self.tea = null;
self.steamParticles = [];
self.fill = function () {
if (self.filled) return;
self.filled = true;
// Add tea inside cup
self.tea = self.addChild(LK.getAsset('teacup', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.3,
y: 10,
tint: 0x8B4513
}));
// Add steam effect
for (var i = 0; i < 3; i++) {
var steam = self.addChild(LK.getAsset('steam', {
anchorX: 0.5,
anchorY: 0.5,
x: (i - 1) * 15,
y: -20,
alpha: 0.7
}));
self.steamParticles.push(steam);
// Animate steam
var _animateSteam = function animateSteam(steamObj) {
tween(steamObj, {
y: steamObj.y - 50,
alpha: 0
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
steamObj.y = -20;
steamObj.alpha = 0.7;
_animateSteam(steamObj);
}
});
};
_animateSteam(steam);
}
};
return self;
});
var TeaPot = Container.expand(function () {
var self = Container.call(this);
var potGraphics = self.attachAsset('teapot', {
anchorX: 0.5,
anchorY: 0.5
});
self.pouring = false;
self.down = function (x, y, obj) {
if (self.pouring) return;
self.pouring = true;
LK.getSound('pour').play();
tween(potGraphics, {
rotation: 0.5
}, {
duration: 300,
easing: tween.easeOut
});
tween(potGraphics, {
rotation: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
self.pouring = false;
}
});
// Fill nearby empty cups
for (var i = 0; i < teacups.length; i++) {
var cup = teacups[i];
if (!cup.filled) {
cup.fill();
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var characters = [];
var cakes = [];
var teacups = [];
var giftboxes = [];
// Create table
var table = game.addChild(LK.getAsset('table', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400
}));
var tablecloth = game.addChild(LK.getAsset('tablecloth', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400
}));
// Create chairs and characters
var chairPositions = [{
x: 1024,
y: 1800
},
// Bottom
{
x: 600,
y: 1200
},
// Left
{
x: 1448,
y: 1200
} // Right
];
var characterColors = [0xFF69B4, 0x98FB98, 0xFFB6C1];
var characterNames = ['Blossom', 'Bubbles', 'Buttercup'];
for (var i = 0; i < 3; i++) {
var chair = game.addChild(LK.getAsset('chair', {
anchorX: 0.5,
anchorY: 0.5,
x: chairPositions[i].x,
y: chairPositions[i].y
}));
var character = game.addChild(new Character(characterColors[i], characterNames[i]));
character.x = chairPositions[i].x;
character.y = chairPositions[i].y - 50;
characters.push(character);
}
// Create teapot at center of table
var teapot = game.addChild(new TeaPot());
teapot.x = 1024;
teapot.y = 1300;
// Create teacups around table
var cupPositions = [{
x: 900,
y: 1200
}, {
x: 1148,
y: 1200
}, {
x: 1024,
y: 1500
}];
for (var i = 0; i < 3; i++) {
var teacup = game.addChild(new TeaCup());
teacup.x = cupPositions[i].x;
teacup.y = cupPositions[i].y;
teacups.push(teacup);
}
// Create cakes on table
var cakePositions = [{
x: 800,
y: 1350
}, {
x: 1248,
y: 1350
}, {
x: 1024,
y: 1200
}];
for (var i = 0; i < 3; i++) {
var cake = game.addChild(new Cake());
cake.x = cakePositions[i].x;
cake.y = cakePositions[i].y;
cakes.push(cake);
}
// Create gift boxes around the scene
var giftPositions = [{
x: 300,
y: 1600
}, {
x: 1748,
y: 1600
}, {
x: 1024,
y: 2200
}, {
x: 200,
y: 1000
}, {
x: 1848,
y: 1000
}];
for (var i = 0; i < 5; i++) {
var giftbox = game.addChild(new GiftBox());
giftbox.x = giftPositions[i].x;
giftbox.y = giftPositions[i].y;
giftboxes.push(giftbox);
}
// Add title text
var titleText = new Text2('Magical Tea Party', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
LK.gui.top.addChild(titleText);
titleText.y = 100;
game.update = function () {
// Game runs continuously without win/lose conditions
// All interactions are handled by individual object event handlers
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,347 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Cake = Container.expand(function () {
+ var self = Container.call(this);
+ var cakeGraphics = self.attachAsset('cake', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.eaten = false;
+ self.down = function (x, y, obj) {
+ if (self.eaten) return;
+ self.eaten = true;
+ LK.getSound('eat').play();
+ tween(cakeGraphics, {
+ scaleX: 0,
+ scaleY: 0,
+ alpha: 0
+ }, {
+ duration: 500,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.eaten = false;
+ cakeGraphics.scaleX = 1;
+ cakeGraphics.scaleY = 1;
+ cakeGraphics.alpha = 1;
+ }
+ });
+ // Make nearest character eat
+ var nearestCharacter = null;
+ var minDistance = Infinity;
+ for (var i = 0; i < characters.length; i++) {
+ var character = characters[i];
+ var distance = Math.sqrt(Math.pow(character.x - self.x, 2) + Math.pow(character.y - self.y, 2));
+ if (distance < minDistance) {
+ minDistance = distance;
+ nearestCharacter = character;
+ }
+ }
+ if (nearestCharacter) {
+ nearestCharacter.playEatAnimation();
+ }
+ };
+ return self;
+});
+var Character = Container.expand(function (characterColor, name) {
+ var self = Container.call(this);
+ var body = self.attachAsset('character', {
+ anchorX: 0.5,
+ anchorY: 1,
+ color: characterColor
+ });
+ self.name = name;
+ self.isEating = false;
+ self.playEatAnimation = function () {
+ if (self.isEating) return;
+ self.isEating = true;
+ tween(body, {
+ scaleY: 0.8
+ }, {
+ duration: 200,
+ easing: tween.easeInOut
+ });
+ tween(body, {
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ self.isEating = false;
+ }
+ });
+ LK.getSound('cheer').play();
+ };
+ return self;
+});
+var GiftBox = Container.expand(function () {
+ var self = Container.call(this);
+ var boxGraphics = self.attachAsset('giftbox', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.opened = false;
+ self.down = function (x, y, obj) {
+ if (self.opened) return;
+ self.opened = true;
+ LK.getSound('unwrap').play();
+ // Box opening animation
+ tween(boxGraphics, {
+ scaleY: 0.1,
+ alpha: 0.5
+ }, {
+ duration: 300,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ // Create random gift
+ var giftTypes = ['horn', 'kazoo', 'doll'];
+ var randomGift = giftTypes[Math.floor(Math.random() * giftTypes.length)];
+ var gift = self.addChild(LK.getAsset(randomGift, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0,
+ scaleY: 0
+ }));
+ // Gift pop-out animation
+ tween(gift, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 500,
+ easing: tween.bounceOut
+ });
+ // Reset box after delay
+ LK.setTimeout(function () {
+ gift.destroy();
+ self.opened = false;
+ boxGraphics.scaleY = 1;
+ boxGraphics.alpha = 1;
+ }, 3000);
+ }
+ });
+ };
+ return self;
+});
+var TeaCup = Container.expand(function () {
+ var self = Container.call(this);
+ var cupGraphics = self.attachAsset('teacup', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.filled = false;
+ self.tea = null;
+ self.steamParticles = [];
+ self.fill = function () {
+ if (self.filled) return;
+ self.filled = true;
+ // Add tea inside cup
+ self.tea = self.addChild(LK.getAsset('teacup', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.8,
+ scaleY: 0.3,
+ y: 10,
+ tint: 0x8B4513
+ }));
+ // Add steam effect
+ for (var i = 0; i < 3; i++) {
+ var steam = self.addChild(LK.getAsset('steam', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: (i - 1) * 15,
+ y: -20,
+ alpha: 0.7
+ }));
+ self.steamParticles.push(steam);
+ // Animate steam
+ var _animateSteam = function animateSteam(steamObj) {
+ tween(steamObj, {
+ y: steamObj.y - 50,
+ alpha: 0
+ }, {
+ duration: 2000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ steamObj.y = -20;
+ steamObj.alpha = 0.7;
+ _animateSteam(steamObj);
+ }
+ });
+ };
+ _animateSteam(steam);
+ }
+ };
+ return self;
+});
+var TeaPot = Container.expand(function () {
+ var self = Container.call(this);
+ var potGraphics = self.attachAsset('teapot', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.pouring = false;
+ self.down = function (x, y, obj) {
+ if (self.pouring) return;
+ self.pouring = true;
+ LK.getSound('pour').play();
+ tween(potGraphics, {
+ rotation: 0.5
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ tween(potGraphics, {
+ rotation: 0
+ }, {
+ duration: 300,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.pouring = false;
+ }
+ });
+ // Fill nearby empty cups
+ for (var i = 0; i < teacups.length; i++) {
+ var cup = teacups[i];
+ if (!cup.filled) {
+ cup.fill();
+ }
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+var characters = [];
+var cakes = [];
+var teacups = [];
+var giftboxes = [];
+// Create table
+var table = game.addChild(LK.getAsset('table', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1400
+}));
+var tablecloth = game.addChild(LK.getAsset('tablecloth', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1400
+}));
+// Create chairs and characters
+var chairPositions = [{
+ x: 1024,
+ y: 1800
+},
+// Bottom
+{
+ x: 600,
+ y: 1200
+},
+// Left
+{
+ x: 1448,
+ y: 1200
+} // Right
+];
+var characterColors = [0xFF69B4, 0x98FB98, 0xFFB6C1];
+var characterNames = ['Blossom', 'Bubbles', 'Buttercup'];
+for (var i = 0; i < 3; i++) {
+ var chair = game.addChild(LK.getAsset('chair', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: chairPositions[i].x,
+ y: chairPositions[i].y
+ }));
+ var character = game.addChild(new Character(characterColors[i], characterNames[i]));
+ character.x = chairPositions[i].x;
+ character.y = chairPositions[i].y - 50;
+ characters.push(character);
+}
+// Create teapot at center of table
+var teapot = game.addChild(new TeaPot());
+teapot.x = 1024;
+teapot.y = 1300;
+// Create teacups around table
+var cupPositions = [{
+ x: 900,
+ y: 1200
+}, {
+ x: 1148,
+ y: 1200
+}, {
+ x: 1024,
+ y: 1500
+}];
+for (var i = 0; i < 3; i++) {
+ var teacup = game.addChild(new TeaCup());
+ teacup.x = cupPositions[i].x;
+ teacup.y = cupPositions[i].y;
+ teacups.push(teacup);
+}
+// Create cakes on table
+var cakePositions = [{
+ x: 800,
+ y: 1350
+}, {
+ x: 1248,
+ y: 1350
+}, {
+ x: 1024,
+ y: 1200
+}];
+for (var i = 0; i < 3; i++) {
+ var cake = game.addChild(new Cake());
+ cake.x = cakePositions[i].x;
+ cake.y = cakePositions[i].y;
+ cakes.push(cake);
+}
+// Create gift boxes around the scene
+var giftPositions = [{
+ x: 300,
+ y: 1600
+}, {
+ x: 1748,
+ y: 1600
+}, {
+ x: 1024,
+ y: 2200
+}, {
+ x: 200,
+ y: 1000
+}, {
+ x: 1848,
+ y: 1000
+}];
+for (var i = 0; i < 5; i++) {
+ var giftbox = game.addChild(new GiftBox());
+ giftbox.x = giftPositions[i].x;
+ giftbox.y = giftPositions[i].y;
+ giftboxes.push(giftbox);
+}
+// Add title text
+var titleText = new Text2('Magical Tea Party', {
+ size: 120,
+ fill: 0xFFFFFF
+});
+titleText.anchor.set(0.5, 0);
+LK.gui.top.addChild(titleText);
+titleText.y = 100;
+game.update = function () {
+ // Game runs continuously without win/lose conditions
+ // All interactions are handled by individual object event handlers
+};
\ No newline at end of file