Code edit (1 edits merged)
Please save this source code
User prompt
Puppet Show Theater
Initial prompt
Toca puppet show 2 (2006). The powerpuff girls are inside the puppet show. Tap on the red curtain to make it go up for the beginning, they be Cody fox 🦊 and Lily fish 🐟 puppets scene at scene 1 twilight sparkle puppet scene at scene 2 pj masks puppets scene at scene 3 princess sofia puppet scene at scene 4 blossom bubbles and buttercup puppets scene at scene 5 so much Christmas text with snowfall and glitter sparkles scene at scene 6
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Puppet = Container.expand(function (assetId, startX, startY) { var self = Container.call(this); var puppetGraphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 1.0 }); self.x = startX; self.y = startY; self.alpha = 0; self.scaleX = 0.8; self.scaleY = 0.8; self.appear = function () { tween(self, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 800, easing: tween.easeOut }); }; self.bobAnimation = function () { tween(self, { y: self.y - 30 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { y: self.y + 30 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { if (self.parent) { self.bobAnimation(); } } }); } }); }; self.disappear = function () { tween(self, { alpha: 0, scaleX: 0.8, scaleY: 0.8 }, { duration: 500, easing: tween.easeIn }); }; return self; }); var Snowflake = Container.expand(function () { var self = Container.call(this); var snowGraphics = self.attachAsset('snowflake', { anchorX: 0.5, anchorY: 0.5 }); self.x = Math.random() * 2048; self.y = -50; self.speed = 2 + Math.random() * 3; self.sway = Math.random() * 2 - 1; self.update = function () { self.y += self.speed; self.x += self.sway; if (self.y > 2732 + 50) { self.y = -50; self.x = Math.random() * 2048; } }; return self; }); var Sparkle = Container.expand(function () { var self = Container.call(this); var sparkleGraphics = self.attachAsset('sparkle', { anchorX: 0.5, anchorY: 0.5 }); self.x = Math.random() * 2048; self.y = Math.random() * 2732; self.alpha = 0; self.scaleX = 0.5; self.scaleY = 0.5; self.sparkle = function () { tween(self, { alpha: 1, scaleX: 2, scaleY: 2 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { alpha: 0, scaleX: 0.5, scaleY: 0.5 }, { duration: 500, easing: tween.easeIn }); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2F1B14 }); /**** * Game Code ****/ var currentScene = 0; var maxScenes = 6; var sceneTimer = 0; var sceneActive = false; var curtainRaised = false; var puppets = []; var snowflakes = []; var sparkles = []; // Create theater stage var stage = game.addChild(LK.getAsset('stage', { anchorX: 0.5, anchorY: 1.0, x: 1024, y: 2200 })); // Create curtain var curtain = game.addChild(LK.getAsset('curtain', { anchorX: 0.5, anchorY: 0.0, x: 1024, y: 900 })); // Create curtain rope var curtainRope = game.addChild(LK.getAsset('curtainRope', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 880 })); // Create title text var titleText = new Text2('Puppet Show Theater', { size: 120, fill: 0xFFD700 }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 400; game.addChild(titleText); // Create tap instruction var tapText = new Text2('Tap the red curtain to begin!', { size: 80, fill: 0xFFFFFF }); tapText.anchor.set(0.5, 0.5); tapText.x = 1024; tapText.y = 600; game.addChild(tapText); // Create scene text var sceneText = new Text2('', { size: 100, fill: 0xFFFFFF }); sceneText.anchor.set(0.5, 0.5); sceneText.x = 1024; sceneText.y = 700; sceneText.alpha = 0; game.addChild(sceneText); function raiseCurtain() { if (!curtainRaised) { curtainRaised = true; LK.getSound('curtainUp').play(); tapText.alpha = 0; tween(curtain, { y: 600 }, { duration: 1500, easing: tween.easeOut, onFinish: function onFinish() { startScene(); } }); tween(curtainRope, { y: 580 }, { duration: 1500, easing: tween.easeOut }); } } function startScene() { sceneActive = true; sceneTimer = 0; // Clear previous puppets for (var i = 0; i < puppets.length; i++) { puppets[i].destroy(); } puppets = []; // Clear previous effects for (var i = 0; i < snowflakes.length; i++) { snowflakes[i].destroy(); } snowflakes = []; for (var i = 0; i < sparkles.length; i++) { sparkles[i].destroy(); } sparkles = []; LK.getSound('sceneChange').play(); switch (currentScene) { case 0: showScene1(); break; case 1: showScene2(); break; case 2: showScene3(); break; case 3: showScene4(); break; case 4: showScene5(); break; case 5: showScene6(); break; } } function showScene1() { sceneText.setText('Cody Fox & Lily Fish'); tween(sceneText, { alpha: 1 }, { duration: 500 }); var codfox = new Puppet('codfox', 800, 1600); var lilyfish = new Puppet('lilyfish', 1200, 1600); puppets.push(codfox); puppets.push(lilyfish); game.addChild(codfox); game.addChild(lilyfish); LK.setTimeout(function () { codfox.appear(); codfox.bobAnimation(); }, 500); LK.setTimeout(function () { lilyfish.appear(); lilyfish.bobAnimation(); }, 1000); } function showScene2() { sceneText.setText('Twilight Sparkle'); tween(sceneText, { alpha: 1 }, { duration: 500 }); var twilight = new Puppet('twilight', 1024, 1600); puppets.push(twilight); game.addChild(twilight); LK.setTimeout(function () { twilight.appear(); twilight.bobAnimation(); }, 500); } function showScene3() { sceneText.setText('PJ Masks Heroes'); tween(sceneText, { alpha: 1 }, { duration: 500 }); var catboy = new Puppet('catboy', 700, 1600); var owlette = new Puppet('owlette', 1024, 1600); var gekko = new Puppet('gekko', 1300, 1600); puppets.push(catboy); puppets.push(owlette); puppets.push(gekko); game.addChild(catboy); game.addChild(owlette); game.addChild(gekko); LK.setTimeout(function () { catboy.appear(); catboy.bobAnimation(); }, 300); LK.setTimeout(function () { owlette.appear(); owlette.bobAnimation(); }, 600); LK.setTimeout(function () { gekko.appear(); gekko.bobAnimation(); }, 900); } function showScene4() { sceneText.setText('Princess Sofia'); tween(sceneText, { alpha: 1 }, { duration: 500 }); var sofia = new Puppet('sofia', 1024, 1600); puppets.push(sofia); game.addChild(sofia); LK.setTimeout(function () { sofia.appear(); sofia.bobAnimation(); }, 500); } function showScene5() { sceneText.setText('Powerpuff Girls'); tween(sceneText, { alpha: 1 }, { duration: 500 }); var blossom = new Puppet('blossom', 700, 1600); var bubbles = new Puppet('bubbles', 1024, 1600); var buttercup = new Puppet('buttercup', 1300, 1600); puppets.push(blossom); puppets.push(bubbles); puppets.push(buttercup); game.addChild(blossom); game.addChild(bubbles); game.addChild(buttercup); LK.setTimeout(function () { blossom.appear(); blossom.bobAnimation(); }, 300); LK.setTimeout(function () { bubbles.appear(); bubbles.bobAnimation(); }, 600); LK.setTimeout(function () { buttercup.appear(); buttercup.bobAnimation(); }, 900); } function showScene6() { sceneText.setText('So Much Christmas'); tween(sceneText, { alpha: 1 }, { duration: 500 }); LK.getSound('christmas').play(); // Create snowfall for (var i = 0; i < 30; i++) { var snowflake = new Snowflake(); snowflake.y = Math.random() * 2732; snowflakes.push(snowflake); game.addChild(snowflake); } // Create sparkles for (var i = 0; i < 20; i++) { var sparkle = new Sparkle(); sparkles.push(sparkle); game.addChild(sparkle); LK.setTimeout(function () { for (var j = 0; j < sparkles.length; j++) { if (sparkles[j].parent) { sparkles[j].sparkle(); } } }, i * 200); } } function nextScene() { if (sceneActive) { sceneActive = false; // Hide scene text tween(sceneText, { alpha: 0 }, { duration: 500 }); // Hide puppets for (var i = 0; i < puppets.length; i++) { puppets[i].disappear(); } currentScene++; if (currentScene >= maxScenes) { currentScene = 0; } LK.setTimeout(function () { startScene(); }, 1000); } } game.down = function (x, y, obj) { if (!curtainRaised) { raiseCurtain(); } else { nextScene(); } }; game.update = function () { if (sceneActive) { sceneTimer++; // Auto advance scenes after 4 seconds if (sceneTimer >= 240) { nextScene(); } } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,421 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Puppet = Container.expand(function (assetId, startX, startY) {
+ var self = Container.call(this);
+ var puppetGraphics = self.attachAsset(assetId, {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ self.x = startX;
+ self.y = startY;
+ self.alpha = 0;
+ self.scaleX = 0.8;
+ self.scaleY = 0.8;
+ self.appear = function () {
+ tween(self, {
+ alpha: 1,
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 800,
+ easing: tween.easeOut
+ });
+ };
+ self.bobAnimation = function () {
+ tween(self, {
+ y: self.y - 30
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ y: self.y + 30
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ if (self.parent) {
+ self.bobAnimation();
+ }
+ }
+ });
+ }
+ });
+ };
+ self.disappear = function () {
+ tween(self, {
+ alpha: 0,
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 500,
+ easing: tween.easeIn
+ });
+ };
+ return self;
+});
+var Snowflake = Container.expand(function () {
+ var self = Container.call(this);
+ var snowGraphics = self.attachAsset('snowflake', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.x = Math.random() * 2048;
+ self.y = -50;
+ self.speed = 2 + Math.random() * 3;
+ self.sway = Math.random() * 2 - 1;
+ self.update = function () {
+ self.y += self.speed;
+ self.x += self.sway;
+ if (self.y > 2732 + 50) {
+ self.y = -50;
+ self.x = Math.random() * 2048;
+ }
+ };
+ return self;
+});
+var Sparkle = Container.expand(function () {
+ var self = Container.call(this);
+ var sparkleGraphics = self.attachAsset('sparkle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.x = Math.random() * 2048;
+ self.y = Math.random() * 2732;
+ self.alpha = 0;
+ self.scaleX = 0.5;
+ self.scaleY = 0.5;
+ self.sparkle = function () {
+ tween(self, {
+ alpha: 1,
+ scaleX: 2,
+ scaleY: 2
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ alpha: 0,
+ scaleX: 0.5,
+ scaleY: 0.5
+ }, {
+ duration: 500,
+ easing: tween.easeIn
+ });
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2F1B14
+});
+
+/****
+* Game Code
+****/
+var currentScene = 0;
+var maxScenes = 6;
+var sceneTimer = 0;
+var sceneActive = false;
+var curtainRaised = false;
+var puppets = [];
+var snowflakes = [];
+var sparkles = [];
+// Create theater stage
+var stage = game.addChild(LK.getAsset('stage', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 1024,
+ y: 2200
+}));
+// Create curtain
+var curtain = game.addChild(LK.getAsset('curtain', {
+ anchorX: 0.5,
+ anchorY: 0.0,
+ x: 1024,
+ y: 900
+}));
+// Create curtain rope
+var curtainRope = game.addChild(LK.getAsset('curtainRope', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 880
+}));
+// Create title text
+var titleText = new Text2('Puppet Show Theater', {
+ size: 120,
+ fill: 0xFFD700
+});
+titleText.anchor.set(0.5, 0.5);
+titleText.x = 1024;
+titleText.y = 400;
+game.addChild(titleText);
+// Create tap instruction
+var tapText = new Text2('Tap the red curtain to begin!', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+tapText.anchor.set(0.5, 0.5);
+tapText.x = 1024;
+tapText.y = 600;
+game.addChild(tapText);
+// Create scene text
+var sceneText = new Text2('', {
+ size: 100,
+ fill: 0xFFFFFF
+});
+sceneText.anchor.set(0.5, 0.5);
+sceneText.x = 1024;
+sceneText.y = 700;
+sceneText.alpha = 0;
+game.addChild(sceneText);
+function raiseCurtain() {
+ if (!curtainRaised) {
+ curtainRaised = true;
+ LK.getSound('curtainUp').play();
+ tapText.alpha = 0;
+ tween(curtain, {
+ y: 600
+ }, {
+ duration: 1500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ startScene();
+ }
+ });
+ tween(curtainRope, {
+ y: 580
+ }, {
+ duration: 1500,
+ easing: tween.easeOut
+ });
+ }
+}
+function startScene() {
+ sceneActive = true;
+ sceneTimer = 0;
+ // Clear previous puppets
+ for (var i = 0; i < puppets.length; i++) {
+ puppets[i].destroy();
+ }
+ puppets = [];
+ // Clear previous effects
+ for (var i = 0; i < snowflakes.length; i++) {
+ snowflakes[i].destroy();
+ }
+ snowflakes = [];
+ for (var i = 0; i < sparkles.length; i++) {
+ sparkles[i].destroy();
+ }
+ sparkles = [];
+ LK.getSound('sceneChange').play();
+ switch (currentScene) {
+ case 0:
+ showScene1();
+ break;
+ case 1:
+ showScene2();
+ break;
+ case 2:
+ showScene3();
+ break;
+ case 3:
+ showScene4();
+ break;
+ case 4:
+ showScene5();
+ break;
+ case 5:
+ showScene6();
+ break;
+ }
+}
+function showScene1() {
+ sceneText.setText('Cody Fox & Lily Fish');
+ tween(sceneText, {
+ alpha: 1
+ }, {
+ duration: 500
+ });
+ var codfox = new Puppet('codfox', 800, 1600);
+ var lilyfish = new Puppet('lilyfish', 1200, 1600);
+ puppets.push(codfox);
+ puppets.push(lilyfish);
+ game.addChild(codfox);
+ game.addChild(lilyfish);
+ LK.setTimeout(function () {
+ codfox.appear();
+ codfox.bobAnimation();
+ }, 500);
+ LK.setTimeout(function () {
+ lilyfish.appear();
+ lilyfish.bobAnimation();
+ }, 1000);
+}
+function showScene2() {
+ sceneText.setText('Twilight Sparkle');
+ tween(sceneText, {
+ alpha: 1
+ }, {
+ duration: 500
+ });
+ var twilight = new Puppet('twilight', 1024, 1600);
+ puppets.push(twilight);
+ game.addChild(twilight);
+ LK.setTimeout(function () {
+ twilight.appear();
+ twilight.bobAnimation();
+ }, 500);
+}
+function showScene3() {
+ sceneText.setText('PJ Masks Heroes');
+ tween(sceneText, {
+ alpha: 1
+ }, {
+ duration: 500
+ });
+ var catboy = new Puppet('catboy', 700, 1600);
+ var owlette = new Puppet('owlette', 1024, 1600);
+ var gekko = new Puppet('gekko', 1300, 1600);
+ puppets.push(catboy);
+ puppets.push(owlette);
+ puppets.push(gekko);
+ game.addChild(catboy);
+ game.addChild(owlette);
+ game.addChild(gekko);
+ LK.setTimeout(function () {
+ catboy.appear();
+ catboy.bobAnimation();
+ }, 300);
+ LK.setTimeout(function () {
+ owlette.appear();
+ owlette.bobAnimation();
+ }, 600);
+ LK.setTimeout(function () {
+ gekko.appear();
+ gekko.bobAnimation();
+ }, 900);
+}
+function showScene4() {
+ sceneText.setText('Princess Sofia');
+ tween(sceneText, {
+ alpha: 1
+ }, {
+ duration: 500
+ });
+ var sofia = new Puppet('sofia', 1024, 1600);
+ puppets.push(sofia);
+ game.addChild(sofia);
+ LK.setTimeout(function () {
+ sofia.appear();
+ sofia.bobAnimation();
+ }, 500);
+}
+function showScene5() {
+ sceneText.setText('Powerpuff Girls');
+ tween(sceneText, {
+ alpha: 1
+ }, {
+ duration: 500
+ });
+ var blossom = new Puppet('blossom', 700, 1600);
+ var bubbles = new Puppet('bubbles', 1024, 1600);
+ var buttercup = new Puppet('buttercup', 1300, 1600);
+ puppets.push(blossom);
+ puppets.push(bubbles);
+ puppets.push(buttercup);
+ game.addChild(blossom);
+ game.addChild(bubbles);
+ game.addChild(buttercup);
+ LK.setTimeout(function () {
+ blossom.appear();
+ blossom.bobAnimation();
+ }, 300);
+ LK.setTimeout(function () {
+ bubbles.appear();
+ bubbles.bobAnimation();
+ }, 600);
+ LK.setTimeout(function () {
+ buttercup.appear();
+ buttercup.bobAnimation();
+ }, 900);
+}
+function showScene6() {
+ sceneText.setText('So Much Christmas');
+ tween(sceneText, {
+ alpha: 1
+ }, {
+ duration: 500
+ });
+ LK.getSound('christmas').play();
+ // Create snowfall
+ for (var i = 0; i < 30; i++) {
+ var snowflake = new Snowflake();
+ snowflake.y = Math.random() * 2732;
+ snowflakes.push(snowflake);
+ game.addChild(snowflake);
+ }
+ // Create sparkles
+ for (var i = 0; i < 20; i++) {
+ var sparkle = new Sparkle();
+ sparkles.push(sparkle);
+ game.addChild(sparkle);
+ LK.setTimeout(function () {
+ for (var j = 0; j < sparkles.length; j++) {
+ if (sparkles[j].parent) {
+ sparkles[j].sparkle();
+ }
+ }
+ }, i * 200);
+ }
+}
+function nextScene() {
+ if (sceneActive) {
+ sceneActive = false;
+ // Hide scene text
+ tween(sceneText, {
+ alpha: 0
+ }, {
+ duration: 500
+ });
+ // Hide puppets
+ for (var i = 0; i < puppets.length; i++) {
+ puppets[i].disappear();
+ }
+ currentScene++;
+ if (currentScene >= maxScenes) {
+ currentScene = 0;
+ }
+ LK.setTimeout(function () {
+ startScene();
+ }, 1000);
+ }
+}
+game.down = function (x, y, obj) {
+ if (!curtainRaised) {
+ raiseCurtain();
+ } else {
+ nextScene();
+ }
+};
+game.update = function () {
+ if (sceneActive) {
+ sceneTimer++;
+ // Auto advance scenes after 4 seconds
+ if (sceneTimer >= 240) {
+ nextScene();
+ }
+ }
+};
\ No newline at end of file