Code edit (1 edits merged)
Please save this source code
User prompt
Pango's Birthday Party
Initial prompt
Pango the blue raccoon stories 💙: it’s skunk’s 9th birthday 🖤. And Pango 💙 had some breakfast 🥐 and a card 🦖. Tap on skunk 🖤 to make her eat her breakfast 🥐, rabbit 🤍, fox 🧡, squirrel 💛, and piggy 🩷 are here but the lightswitch is off. Tap on the lightswitch to turn it on till balloons fly and confetti fall.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Balloon = Container.expand(function () { var self = Container.call(this); var balloonGraphics = self.attachAsset('balloon', { anchorX: 0.5, anchorY: 0.5 }); var colors = [0xFF69B4, 0x00CED1, 0xFFD700, 0xFF6347, 0x9370DB, 0x32CD32]; balloonGraphics.tint = colors[Math.floor(Math.random() * colors.length)]; self.floatSpeed = -2 - Math.random() * 3; self.update = function () { self.y += self.floatSpeed; self.x += Math.sin(self.y * 0.01) * 0.5; if (self.y < -150) { self.destroy(); } }; return self; }); var Character = Container.expand(function () { var self = Container.call(this); var characterGraphics = self.attachAsset('skunk', { anchorX: 0.5, anchorY: 0.5 }); self.isEating = false; self.originalScale = 1; self.eat = function () { if (!self.isEating) { self.isEating = true; LK.getSound('eat').play(); tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { scaleX: self.originalScale, scaleY: self.originalScale }, { duration: 200, easing: tween.easeIn, onFinish: function onFinish() { self.isEating = false; } }); } }); } }; self.down = function (x, y, obj) { if (!lightsOn) { self.eat(); } }; return self; }); var Confetti = Container.expand(function () { var self = Container.call(this); var confettiGraphics = self.attachAsset('confetti', { anchorX: 0.5, anchorY: 0.5 }); var colors = [0xFF69B4, 0x00CED1, 0xFFD700, 0xFF6347, 0x9370DB, 0x32CD32, 0xFF1493, 0x00FF7F]; confettiGraphics.tint = colors[Math.floor(Math.random() * colors.length)]; self.fallSpeed = 3 + Math.random() * 4; self.rotationSpeed = (Math.random() - 0.5) * 0.2; self.update = function () { self.y += self.fallSpeed; self.rotation += self.rotationSpeed; if (self.y > 2800) { self.destroy(); } }; return self; }); var LightSwitch = Container.expand(function () { var self = Container.call(this); var switchGraphics = self.attachAsset('lightswitch', { anchorX: 0.5, anchorY: 0.5 }); self.isOn = false; self.toggle = function () { if (!self.isOn) { self.isOn = true; LK.getSound('switch').play(); tween(switchGraphics, { tint: 0xFFFF00 }, { duration: 300, easing: tween.easeOut }); turnOnLights(); } }; self.down = function (x, y, obj) { if (!lightsOn) { self.toggle(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2d2d2d }); /**** * Game Code ****/ var lightsOn = false; var balloons = []; var confettiPieces = []; var characters = []; var partyStarted = false; // Create room var wall = game.addChild(LK.getAsset('wall', { x: 0, y: 0 })); var floor = game.addChild(LK.getAsset('floor', { x: 0, y: 2332 })); // Create characters var skunk = game.addChild(new Character()); skunk.x = 1024; skunk.y = 1800; var pango = game.addChild(LK.getAsset('pango', { anchorX: 0.5, anchorY: 0.5, x: 400, y: 1700 })); var rabbit = game.addChild(LK.getAsset('rabbit', { anchorX: 0.5, anchorY: 0.5, x: 1600, y: 1650 })); var fox = game.addChild(LK.getAsset('fox', { anchorX: 0.5, anchorY: 0.5, x: 700, y: 1900 })); var squirrel = game.addChild(LK.getAsset('squirrel', { anchorX: 0.5, anchorY: 0.5, x: 1400, y: 1850 })); var piggy = game.addChild(LK.getAsset('piggy', { anchorX: 0.5, anchorY: 0.5, x: 300, y: 1950 })); // Create food near skunk var food = game.addChild(LK.getAsset('food', { anchorX: 0.5, anchorY: 0.5, x: 1100, y: 1900 })); // Create light switch var lightSwitch = game.addChild(new LightSwitch()); lightSwitch.x = 150; lightSwitch.y = 1200; // Create dark overlay var overlay = game.addChild(LK.getAsset('overlay', { x: 0, y: 0, alpha: 0.85 })); // Store all characters for easy access characters.push(pango, rabbit, fox, squirrel, piggy); // Birthday text var birthdayText = new Text2("Happy 9th Birthday Skunk!", { size: 120, fill: 0xFFD700 }); birthdayText.anchor.set(0.5, 0.5); birthdayText.x = 1024; birthdayText.y = 400; birthdayText.alpha = 0; game.addChild(birthdayText); function turnOnLights() { if (lightsOn) return; lightsOn = true; // Fade out the overlay tween(overlay, { alpha: 0 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { startParty(); } }); // Show birthday text tween(birthdayText, { alpha: 1 }, { duration: 1500, easing: tween.easeOut }); // Animate characters appearing characters.forEach(function (character, index) { tween(character, { scaleX: 1.1, scaleY: 1.1 }, { duration: 300, easing: tween.bounceOut, onFinish: function onFinish() { tween(character, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeIn }); } }); }); } function startParty() { if (partyStarted) return; partyStarted = true; LK.getSound('party').play(); // Start spawning balloons var balloonTimer = LK.setInterval(function () { if (balloons.length < 15) { var balloon = game.addChild(new Balloon()); balloon.x = Math.random() * 1800 + 124; balloon.y = 2800; balloons.push(balloon); } }, 800); // Start spawning confetti var confettiTimer = LK.setInterval(function () { for (var i = 0; i < 3; i++) { var confetti = game.addChild(new Confetti()); confetti.x = Math.random() * 2048; confetti.y = -50; confettiPieces.push(confetti); } }, 100); } game.update = function () { // Clean up destroyed balloons for (var i = balloons.length - 1; i >= 0; i--) { if (balloons[i].destroyed) { balloons.splice(i, 1); } } // Clean up destroyed confetti for (var j = confettiPieces.length - 1; j >= 0; j--) { if (confettiPieces[j].destroyed) { confettiPieces.splice(j, 1); } } // Gentle floating animation for characters when lights are on if (lightsOn) { characters.forEach(function (character, index) { character.y += Math.sin(LK.ticks * 0.02 + index) * 0.3; }); // Gentle floating for skunk too skunk.y += Math.sin(LK.ticks * 0.015) * 0.2; } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,285 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Balloon = Container.expand(function () {
+ var self = Container.call(this);
+ var balloonGraphics = self.attachAsset('balloon', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var colors = [0xFF69B4, 0x00CED1, 0xFFD700, 0xFF6347, 0x9370DB, 0x32CD32];
+ balloonGraphics.tint = colors[Math.floor(Math.random() * colors.length)];
+ self.floatSpeed = -2 - Math.random() * 3;
+ self.update = function () {
+ self.y += self.floatSpeed;
+ self.x += Math.sin(self.y * 0.01) * 0.5;
+ if (self.y < -150) {
+ self.destroy();
+ }
+ };
+ return self;
+});
+var Character = Container.expand(function () {
+ var self = Container.call(this);
+ var characterGraphics = self.attachAsset('skunk', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isEating = false;
+ self.originalScale = 1;
+ self.eat = function () {
+ if (!self.isEating) {
+ self.isEating = true;
+ LK.getSound('eat').play();
+ tween(self, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: self.originalScale,
+ scaleY: self.originalScale
+ }, {
+ duration: 200,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.isEating = false;
+ }
+ });
+ }
+ });
+ }
+ };
+ self.down = function (x, y, obj) {
+ if (!lightsOn) {
+ self.eat();
+ }
+ };
+ return self;
+});
+var Confetti = Container.expand(function () {
+ var self = Container.call(this);
+ var confettiGraphics = self.attachAsset('confetti', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var colors = [0xFF69B4, 0x00CED1, 0xFFD700, 0xFF6347, 0x9370DB, 0x32CD32, 0xFF1493, 0x00FF7F];
+ confettiGraphics.tint = colors[Math.floor(Math.random() * colors.length)];
+ self.fallSpeed = 3 + Math.random() * 4;
+ self.rotationSpeed = (Math.random() - 0.5) * 0.2;
+ self.update = function () {
+ self.y += self.fallSpeed;
+ self.rotation += self.rotationSpeed;
+ if (self.y > 2800) {
+ self.destroy();
+ }
+ };
+ return self;
+});
+var LightSwitch = Container.expand(function () {
+ var self = Container.call(this);
+ var switchGraphics = self.attachAsset('lightswitch', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isOn = false;
+ self.toggle = function () {
+ if (!self.isOn) {
+ self.isOn = true;
+ LK.getSound('switch').play();
+ tween(switchGraphics, {
+ tint: 0xFFFF00
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ turnOnLights();
+ }
+ };
+ self.down = function (x, y, obj) {
+ if (!lightsOn) {
+ self.toggle();
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2d2d2d
+});
+
+/****
+* Game Code
+****/
+var lightsOn = false;
+var balloons = [];
+var confettiPieces = [];
+var characters = [];
+var partyStarted = false;
+// Create room
+var wall = game.addChild(LK.getAsset('wall', {
+ x: 0,
+ y: 0
+}));
+var floor = game.addChild(LK.getAsset('floor', {
+ x: 0,
+ y: 2332
+}));
+// Create characters
+var skunk = game.addChild(new Character());
+skunk.x = 1024;
+skunk.y = 1800;
+var pango = game.addChild(LK.getAsset('pango', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 400,
+ y: 1700
+}));
+var rabbit = game.addChild(LK.getAsset('rabbit', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1600,
+ y: 1650
+}));
+var fox = game.addChild(LK.getAsset('fox', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 700,
+ y: 1900
+}));
+var squirrel = game.addChild(LK.getAsset('squirrel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1400,
+ y: 1850
+}));
+var piggy = game.addChild(LK.getAsset('piggy', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 300,
+ y: 1950
+}));
+// Create food near skunk
+var food = game.addChild(LK.getAsset('food', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1100,
+ y: 1900
+}));
+// Create light switch
+var lightSwitch = game.addChild(new LightSwitch());
+lightSwitch.x = 150;
+lightSwitch.y = 1200;
+// Create dark overlay
+var overlay = game.addChild(LK.getAsset('overlay', {
+ x: 0,
+ y: 0,
+ alpha: 0.85
+}));
+// Store all characters for easy access
+characters.push(pango, rabbit, fox, squirrel, piggy);
+// Birthday text
+var birthdayText = new Text2("Happy 9th Birthday Skunk!", {
+ size: 120,
+ fill: 0xFFD700
+});
+birthdayText.anchor.set(0.5, 0.5);
+birthdayText.x = 1024;
+birthdayText.y = 400;
+birthdayText.alpha = 0;
+game.addChild(birthdayText);
+function turnOnLights() {
+ if (lightsOn) return;
+ lightsOn = true;
+ // Fade out the overlay
+ tween(overlay, {
+ alpha: 0
+ }, {
+ duration: 1000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ startParty();
+ }
+ });
+ // Show birthday text
+ tween(birthdayText, {
+ alpha: 1
+ }, {
+ duration: 1500,
+ easing: tween.easeOut
+ });
+ // Animate characters appearing
+ characters.forEach(function (character, index) {
+ tween(character, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 300,
+ easing: tween.bounceOut,
+ onFinish: function onFinish() {
+ tween(character, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeIn
+ });
+ }
+ });
+ });
+}
+function startParty() {
+ if (partyStarted) return;
+ partyStarted = true;
+ LK.getSound('party').play();
+ // Start spawning balloons
+ var balloonTimer = LK.setInterval(function () {
+ if (balloons.length < 15) {
+ var balloon = game.addChild(new Balloon());
+ balloon.x = Math.random() * 1800 + 124;
+ balloon.y = 2800;
+ balloons.push(balloon);
+ }
+ }, 800);
+ // Start spawning confetti
+ var confettiTimer = LK.setInterval(function () {
+ for (var i = 0; i < 3; i++) {
+ var confetti = game.addChild(new Confetti());
+ confetti.x = Math.random() * 2048;
+ confetti.y = -50;
+ confettiPieces.push(confetti);
+ }
+ }, 100);
+}
+game.update = function () {
+ // Clean up destroyed balloons
+ for (var i = balloons.length - 1; i >= 0; i--) {
+ if (balloons[i].destroyed) {
+ balloons.splice(i, 1);
+ }
+ }
+ // Clean up destroyed confetti
+ for (var j = confettiPieces.length - 1; j >= 0; j--) {
+ if (confettiPieces[j].destroyed) {
+ confettiPieces.splice(j, 1);
+ }
+ }
+ // Gentle floating animation for characters when lights are on
+ if (lightsOn) {
+ characters.forEach(function (character, index) {
+ character.y += Math.sin(LK.ticks * 0.02 + index) * 0.3;
+ });
+ // Gentle floating for skunk too
+ skunk.y += Math.sin(LK.ticks * 0.015) * 0.2;
+ }
+};
\ No newline at end of file