Code edit (1 edits merged)
Please save this source code
User prompt
Powerpuff TV Movie Night
Initial prompt
Toca movie (2010). The powerpuff girls have a new tv to watch! Tap the play button to make the tv watch, it will be the jungle me 1 movie on the tv. And there’s a Egypt scene at the beginning, onions scene at the middle, and a ballet scene and then seeing the full moon at the end.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BalletScene = Container.expand(function () { var self = Container.call(this); var stage = self.attachAsset('stage', { anchorX: 0.5, anchorY: 1.0, y: 100 }); var leftCurtain = self.attachAsset('curtain', { anchorX: 1.0, anchorY: 0.5, x: -50 }); var rightCurtain = self.attachAsset('curtain', { anchorX: 0.0, anchorY: 0.5, x: 50 }); var dancers = []; for (var i = 0; i < 5; i++) { var dancer = self.attachAsset('dancer', { anchorX: 0.5, anchorY: 1.0, x: (i - 2) * 100, y: 50 }); dancers.push(dancer); } self.animate = function () { tween(leftCurtain, { x: -400 }, { duration: 1000, easing: tween.easeOut }); tween(rightCurtain, { x: 400 }, { duration: 1000, easing: tween.easeOut }); for (var i = 0; i < dancers.length; i++) { var delay = i * 300; tween(dancers[i], { y: dancers[i].y - 30 }, { duration: 800, easing: tween.easeInOut }); tween(dancers[i], { rotation: Math.PI / 4 }, { duration: 1200, easing: tween.easeInOut }); } }; return self; }); var EgyptScene = Container.expand(function () { var self = Container.call(this); var sand = self.attachAsset('sand', { anchorX: 0.5, anchorY: 1.0 }); var pyramid1 = self.attachAsset('pyramid', { anchorX: 0.5, anchorY: 1.0, x: -200, y: -100 }); var pyramid2 = self.attachAsset('pyramid', { anchorX: 0.5, anchorY: 1.0, x: 200, y: -100, scaleX: 0.8, scaleY: 0.8 }); var sun = self.attachAsset('sun', { anchorX: 0.5, anchorY: 0.5, x: 600, y: -300 }); self.animate = function () { tween(sun, { x: 700 }, { duration: 3000, easing: tween.easeInOut }); tween(pyramid1, { y: pyramid1.y - 20 }, { duration: 2000, easing: tween.easeInOut }); tween(pyramid2, { y: pyramid2.y - 15 }, { duration: 2500, easing: tween.easeInOut }); }; return self; }); var MoonScene = Container.expand(function () { var self = Container.call(this); var sky = self.attachAsset('nightSky', { anchorX: 0.5, anchorY: 0.5 }); var moon = self.attachAsset('moon', { anchorX: 0.5, anchorY: 0.5, x: 400, y: -200 }); var stars = []; for (var i = 0; i < 20; i++) { var star = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.5, x: (Math.random() - 0.5) * 1400, y: (Math.random() - 0.5) * 700 }); stars.push(star); } self.animate = function () { tween(moon, { scaleX: 1.2, scaleY: 1.2 }, { duration: 3000, easing: tween.easeInOut }); tween(moon, { tint: 0xffd700 }, { duration: 2000, easing: tween.easeInOut }); for (var i = 0; i < stars.length; i++) { var delay = Math.random() * 1000; tween(stars[i], { alpha: 0.3 }, { duration: 1000 + delay, easing: tween.easeInOut }); tween(stars[i], { alpha: 1.0 }, { duration: 1000 + delay, easing: tween.easeInOut }); } }; return self; }); var OnionScene = Container.expand(function () { var self = Container.call(this); var onions = []; for (var i = 0; i < 8; i++) { var onion = self.attachAsset('onion', { anchorX: 0.5, anchorY: 0.5, x: (i - 4) * 150, y: Math.sin(i) * 50 }); var layer = self.attachAsset('onionLayer', { anchorX: 0.5, anchorY: 0.5, x: (i - 4) * 150, y: Math.sin(i) * 50 }); onions.push({ onion: onion, layer: layer }); } self.animate = function () { for (var i = 0; i < onions.length; i++) { var delay = i * 200; tween(onions[i].onion, { y: onions[i].onion.y - 50 }, { duration: 1500, easing: tween.bounceOut }); tween(onions[i].layer, { y: onions[i].layer.y - 50 }, { duration: 1500, easing: tween.bounceOut }); tween(onions[i].onion, { rotation: Math.PI * 2 }, { duration: 2000, easing: tween.linear }); } }; return self; }); var PowerpuffGirl = Container.expand(function (color) { var self = Container.call(this); var body = self.attachAsset('blossom', { anchorX: 0.5, anchorY: 1.0, tint: color }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ // Scene 4: Full Moon // Scene 3: Ballet // Scene 2: Onions // Scene 1: Egypt // Powerpuff Girls var gameState = 'menu'; // 'menu', 'playing', 'scene1', 'scene2', 'scene3', 'scene4' var currentScene = null; var sceneTimer = 0; var sceneDuration = 4000; // 4 seconds per scene // TV setup var tvFrame = game.addChild(LK.getAsset('tvFrame', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1000 })); var tvScreen = game.addChild(LK.getAsset('tvScreen', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1000 })); // Play button var playButton = game.addChild(LK.getAsset('playButton', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1000 })); var playTriangle = game.addChild(LK.getAsset('playTriangle', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1000 })); // Powerpuff Girls var blossom = game.addChild(new PowerpuffGirl(0xff69b4)); blossom.x = 700; blossom.y = 1600; var bubbles = game.addChild(new PowerpuffGirl(0x87ceeb)); bubbles.x = 1024; bubbles.y = 1600; var buttercup = game.addChild(new PowerpuffGirl(0x90ee90)); buttercup.x = 1348; buttercup.y = 1600; // Title text var titleText = new Text2('Jungle Me 1', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 800; game.addChild(titleText); // Instructions text var instructionText = new Text2('Tap PLAY to start the movie!', { size: 60, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 1200; game.addChild(instructionText); function startScene(sceneNumber) { // Clear previous scene if (currentScene) { currentScene.destroy(); currentScene = null; } // Hide menu elements playButton.visible = false; playTriangle.visible = false; titleText.visible = false; instructionText.visible = false; // Create new scene switch (sceneNumber) { case 1: currentScene = new EgyptScene(); gameState = 'scene1'; break; case 2: currentScene = new OnionScene(); gameState = 'scene2'; break; case 3: currentScene = new BalletScene(); gameState = 'scene3'; break; case 4: currentScene = new MoonScene(); gameState = 'scene4'; break; } if (currentScene) { currentScene.x = 1024; currentScene.y = 1000; tvScreen.addChild(currentScene); currentScene.animate(); LK.getSound('sceneTransition').play(); } sceneTimer = 0; } function showMenu() { gameState = 'menu'; // Clear current scene if (currentScene) { currentScene.destroy(); currentScene = null; } // Show menu elements playButton.visible = true; playTriangle.visible = true; titleText.visible = true; instructionText.visible = true; } // Play button click handler playButton.down = function (x, y, obj) { if (gameState === 'menu') { LK.getSound('click').play(); gameState = 'playing'; startScene(1); } }; playTriangle.down = function (x, y, obj) { if (gameState === 'menu') { LK.getSound('click').play(); gameState = 'playing'; startScene(1); } }; // Skip scene on tap tvScreen.down = function (x, y, obj) { if (gameState !== 'menu') { LK.getSound('click').play(); switch (gameState) { case 'scene1': startScene(2); break; case 'scene2': startScene(3); break; case 'scene3': startScene(4); break; case 'scene4': showMenu(); break; } } }; game.update = function () { if (gameState !== 'menu') { sceneTimer += 16; // Approximately 60 FPS if (sceneTimer >= sceneDuration) { switch (gameState) { case 'scene1': startScene(2); break; case 'scene2': startScene(3); break; case 'scene3': startScene(4); break; case 'scene4': showMenu(); break; } } } // Animate play button if (gameState === 'menu') { playButton.alpha = 0.8 + 0.2 * Math.sin(LK.ticks * 0.1); } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,409 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var BalletScene = Container.expand(function () {
+ var self = Container.call(this);
+ var stage = self.attachAsset('stage', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ y: 100
+ });
+ var leftCurtain = self.attachAsset('curtain', {
+ anchorX: 1.0,
+ anchorY: 0.5,
+ x: -50
+ });
+ var rightCurtain = self.attachAsset('curtain', {
+ anchorX: 0.0,
+ anchorY: 0.5,
+ x: 50
+ });
+ var dancers = [];
+ for (var i = 0; i < 5; i++) {
+ var dancer = self.attachAsset('dancer', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: (i - 2) * 100,
+ y: 50
+ });
+ dancers.push(dancer);
+ }
+ self.animate = function () {
+ tween(leftCurtain, {
+ x: -400
+ }, {
+ duration: 1000,
+ easing: tween.easeOut
+ });
+ tween(rightCurtain, {
+ x: 400
+ }, {
+ duration: 1000,
+ easing: tween.easeOut
+ });
+ for (var i = 0; i < dancers.length; i++) {
+ var delay = i * 300;
+ tween(dancers[i], {
+ y: dancers[i].y - 30
+ }, {
+ duration: 800,
+ easing: tween.easeInOut
+ });
+ tween(dancers[i], {
+ rotation: Math.PI / 4
+ }, {
+ duration: 1200,
+ easing: tween.easeInOut
+ });
+ }
+ };
+ return self;
+});
+var EgyptScene = Container.expand(function () {
+ var self = Container.call(this);
+ var sand = self.attachAsset('sand', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ var pyramid1 = self.attachAsset('pyramid', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: -200,
+ y: -100
+ });
+ var pyramid2 = self.attachAsset('pyramid', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 200,
+ y: -100,
+ scaleX: 0.8,
+ scaleY: 0.8
+ });
+ var sun = self.attachAsset('sun', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 600,
+ y: -300
+ });
+ self.animate = function () {
+ tween(sun, {
+ x: 700
+ }, {
+ duration: 3000,
+ easing: tween.easeInOut
+ });
+ tween(pyramid1, {
+ y: pyramid1.y - 20
+ }, {
+ duration: 2000,
+ easing: tween.easeInOut
+ });
+ tween(pyramid2, {
+ y: pyramid2.y - 15
+ }, {
+ duration: 2500,
+ easing: tween.easeInOut
+ });
+ };
+ return self;
+});
+var MoonScene = Container.expand(function () {
+ var self = Container.call(this);
+ var sky = self.attachAsset('nightSky', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var moon = self.attachAsset('moon', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 400,
+ y: -200
+ });
+ var stars = [];
+ for (var i = 0; i < 20; i++) {
+ var star = self.attachAsset('star', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: (Math.random() - 0.5) * 1400,
+ y: (Math.random() - 0.5) * 700
+ });
+ stars.push(star);
+ }
+ self.animate = function () {
+ tween(moon, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 3000,
+ easing: tween.easeInOut
+ });
+ tween(moon, {
+ tint: 0xffd700
+ }, {
+ duration: 2000,
+ easing: tween.easeInOut
+ });
+ for (var i = 0; i < stars.length; i++) {
+ var delay = Math.random() * 1000;
+ tween(stars[i], {
+ alpha: 0.3
+ }, {
+ duration: 1000 + delay,
+ easing: tween.easeInOut
+ });
+ tween(stars[i], {
+ alpha: 1.0
+ }, {
+ duration: 1000 + delay,
+ easing: tween.easeInOut
+ });
+ }
+ };
+ return self;
+});
+var OnionScene = Container.expand(function () {
+ var self = Container.call(this);
+ var onions = [];
+ for (var i = 0; i < 8; i++) {
+ var onion = self.attachAsset('onion', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: (i - 4) * 150,
+ y: Math.sin(i) * 50
+ });
+ var layer = self.attachAsset('onionLayer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: (i - 4) * 150,
+ y: Math.sin(i) * 50
+ });
+ onions.push({
+ onion: onion,
+ layer: layer
+ });
+ }
+ self.animate = function () {
+ for (var i = 0; i < onions.length; i++) {
+ var delay = i * 200;
+ tween(onions[i].onion, {
+ y: onions[i].onion.y - 50
+ }, {
+ duration: 1500,
+ easing: tween.bounceOut
+ });
+ tween(onions[i].layer, {
+ y: onions[i].layer.y - 50
+ }, {
+ duration: 1500,
+ easing: tween.bounceOut
+ });
+ tween(onions[i].onion, {
+ rotation: Math.PI * 2
+ }, {
+ duration: 2000,
+ easing: tween.linear
+ });
+ }
+ };
+ return self;
+});
+var PowerpuffGirl = Container.expand(function (color) {
+ var self = Container.call(this);
+ var body = self.attachAsset('blossom', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ tint: color
+ });
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+// Scene 4: Full Moon
+// Scene 3: Ballet
+// Scene 2: Onions
+// Scene 1: Egypt
+// Powerpuff Girls
+var gameState = 'menu'; // 'menu', 'playing', 'scene1', 'scene2', 'scene3', 'scene4'
+var currentScene = null;
+var sceneTimer = 0;
+var sceneDuration = 4000; // 4 seconds per scene
+// TV setup
+var tvFrame = game.addChild(LK.getAsset('tvFrame', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1000
+}));
+var tvScreen = game.addChild(LK.getAsset('tvScreen', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1000
+}));
+// Play button
+var playButton = game.addChild(LK.getAsset('playButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1000
+}));
+var playTriangle = game.addChild(LK.getAsset('playTriangle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1000
+}));
+// Powerpuff Girls
+var blossom = game.addChild(new PowerpuffGirl(0xff69b4));
+blossom.x = 700;
+blossom.y = 1600;
+var bubbles = game.addChild(new PowerpuffGirl(0x87ceeb));
+bubbles.x = 1024;
+bubbles.y = 1600;
+var buttercup = game.addChild(new PowerpuffGirl(0x90ee90));
+buttercup.x = 1348;
+buttercup.y = 1600;
+// Title text
+var titleText = new Text2('Jungle Me 1', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+titleText.anchor.set(0.5, 0.5);
+titleText.x = 1024;
+titleText.y = 800;
+game.addChild(titleText);
+// Instructions text
+var instructionText = new Text2('Tap PLAY to start the movie!', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+instructionText.anchor.set(0.5, 0.5);
+instructionText.x = 1024;
+instructionText.y = 1200;
+game.addChild(instructionText);
+function startScene(sceneNumber) {
+ // Clear previous scene
+ if (currentScene) {
+ currentScene.destroy();
+ currentScene = null;
+ }
+ // Hide menu elements
+ playButton.visible = false;
+ playTriangle.visible = false;
+ titleText.visible = false;
+ instructionText.visible = false;
+ // Create new scene
+ switch (sceneNumber) {
+ case 1:
+ currentScene = new EgyptScene();
+ gameState = 'scene1';
+ break;
+ case 2:
+ currentScene = new OnionScene();
+ gameState = 'scene2';
+ break;
+ case 3:
+ currentScene = new BalletScene();
+ gameState = 'scene3';
+ break;
+ case 4:
+ currentScene = new MoonScene();
+ gameState = 'scene4';
+ break;
+ }
+ if (currentScene) {
+ currentScene.x = 1024;
+ currentScene.y = 1000;
+ tvScreen.addChild(currentScene);
+ currentScene.animate();
+ LK.getSound('sceneTransition').play();
+ }
+ sceneTimer = 0;
+}
+function showMenu() {
+ gameState = 'menu';
+ // Clear current scene
+ if (currentScene) {
+ currentScene.destroy();
+ currentScene = null;
+ }
+ // Show menu elements
+ playButton.visible = true;
+ playTriangle.visible = true;
+ titleText.visible = true;
+ instructionText.visible = true;
+}
+// Play button click handler
+playButton.down = function (x, y, obj) {
+ if (gameState === 'menu') {
+ LK.getSound('click').play();
+ gameState = 'playing';
+ startScene(1);
+ }
+};
+playTriangle.down = function (x, y, obj) {
+ if (gameState === 'menu') {
+ LK.getSound('click').play();
+ gameState = 'playing';
+ startScene(1);
+ }
+};
+// Skip scene on tap
+tvScreen.down = function (x, y, obj) {
+ if (gameState !== 'menu') {
+ LK.getSound('click').play();
+ switch (gameState) {
+ case 'scene1':
+ startScene(2);
+ break;
+ case 'scene2':
+ startScene(3);
+ break;
+ case 'scene3':
+ startScene(4);
+ break;
+ case 'scene4':
+ showMenu();
+ break;
+ }
+ }
+};
+game.update = function () {
+ if (gameState !== 'menu') {
+ sceneTimer += 16; // Approximately 60 FPS
+ if (sceneTimer >= sceneDuration) {
+ switch (gameState) {
+ case 'scene1':
+ startScene(2);
+ break;
+ case 'scene2':
+ startScene(3);
+ break;
+ case 'scene3':
+ startScene(4);
+ break;
+ case 'scene4':
+ showMenu();
+ break;
+ }
+ }
+ }
+ // Animate play button
+ if (gameState === 'menu') {
+ playButton.alpha = 0.8 + 0.2 * Math.sin(LK.ticks * 0.1);
+ }
+};
\ No newline at end of file