Code edit (1 edits merged)
Please save this source code
User prompt
The Very Hungry Lizard Story
Initial prompt
Toca animated story (2001). The powerpuff girls have a tv to watch. Tap on the green play button or continue button or again button to make the tv come to life or continue the story or read again, it will be a story movie called “the very hungry lizard”. They be in the light of the moon a little egg lay on a leaf scene at scene 1, the warm sun came out and the egg goes pop scene at scene 2, out of the egg came a tiny and very hungry lizard scene at scene 3, the lizard ate through 1 apple on Monday scene at scene 4, the lizard ate through 2 pears on Tuesday scene at scene 5, the lizard ate through 3 plums on Wednesday scene at scene 6, the lizard ate through 4 strawberries on Thursday scene at scene 7, the lizard ate through 5 oranges on Friday scene at scene 8, the lizard ate through one piece of cherry pie one sausage one lollipop and one slice of watermelon on Saturday scene at scene 9, that night the lizard had a stomach ache scene at scene 10, the lizard ate through one green leaf and after that he felt much better on Sunday scene at scene 11, the lizard builds a small house called a cocoon around himself scene at scene 12, out pops a pretty dragonfly scene at scene 13 for end,
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var GreenButton = Container.expand(function (text, callback) { var self = Container.call(this); var bg = self.attachAsset('continueButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2(text, { size: 40, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function () { LK.getSound('tap').play(); if (callback) callback(); }; return self; }); var StoryScene = Container.expand(function () { var self = Container.call(this); self.elements = []; self.addElement = function (assetId, x, y, scale) { var element = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5, x: x, y: y, scaleX: scale || 1, scaleY: scale || 1 }); self.elements.push(element); return element; }; self.animate = function () { // Simple fade-in animation for all elements for (var i = 0; i < self.elements.length; i++) { var element = self.elements[i]; element.alpha = 0; tween(element, { alpha: 1 }, { duration: 500 + i * 200 }); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ // Story elements // Powerpuff Girls (simplified colored shapes) // Background and UI elements var currentScene = 0; var isStoryStarted = false; var scenes = []; var currentSceneContainer = null; var continueButton = null; // TV setup var tvFrame = game.addChild(LK.getAsset('tvFrame', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 900 })); var tvScreen = game.addChild(LK.getAsset('tvScreen', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 900 })); // Powerpuff Girls var blossom = game.addChild(LK.getAsset('blossom', { anchorX: 0.5, anchorY: 1, x: 700, y: 1700 })); var bubbles = game.addChild(LK.getAsset('bubbles', { anchorX: 0.5, anchorY: 1, x: 1024, y: 1700 })); var buttercup = game.addChild(LK.getAsset('buttercup', { anchorX: 0.5, anchorY: 1, x: 1348, y: 1700 })); // Title text var titleText = new Text2("The Very Hungry Lizard Story", { size: 60, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 300; game.addChild(titleText); // Initial play button var playButton = game.addChild(new GreenButton("PLAY", startStory)); playButton.x = 1024; playButton.y = 900; function startStory() { isStoryStarted = true; currentScene = 0; playButton.visible = false; titleText.visible = false; showScene(0); } function createScene1() { var scene = new StoryScene(); scene.addElement('leaf', 0, 100, 1.5); scene.addElement('egg', 0, 0); scene.addElement('moon', -400, -200); return scene; } function createScene2() { var scene = new StoryScene(); scene.addElement('leaf', 0, 100, 1.5); scene.addElement('sun', 400, -200); return scene; } function createScene3() { var scene = new StoryScene(); scene.addElement('leaf', 0, 100, 1.5); scene.addElement('lizard', 0, 0); return scene; } function createScene4() { var scene = new StoryScene(); scene.addElement('lizard', -200, 0); scene.addElement('apple', 200, 0); return scene; } function createScene5() { var scene = new StoryScene(); scene.addElement('lizard', -200, 0, 1.2); scene.addElement('pear', 100, -50); scene.addElement('pear', 150, 50); return scene; } function createScene6() { var scene = new StoryScene(); scene.addElement('lizard', -200, 0, 1.4); scene.addElement('plum', 80, -80); scene.addElement('plum', 150, 0); scene.addElement('plum', 120, 80); return scene; } function createScene7() { var scene = new StoryScene(); scene.addElement('lizard', -250, 0, 1.6); scene.addElement('strawberry', 80, -100); scene.addElement('strawberry', 150, -30); scene.addElement('strawberry', 120, 40); scene.addElement('strawberry', 180, 100); return scene; } function createScene8() { var scene = new StoryScene(); scene.addElement('lizard', -250, 0, 1.8); scene.addElement('orange', 60, -120); scene.addElement('orange', 130, -60); scene.addElement('orange', 100, 0); scene.addElement('orange', 160, 60); scene.addElement('orange', 200, 120); return scene; } function createScene9() { var scene = new StoryScene(); scene.addElement('lizard', -250, 0, 2); scene.addElement('pie', 100, -100); scene.addElement('sausage', 150, -30); scene.addElement('lollipop', 200, 40); scene.addElement('watermelon', 120, 120); return scene; } function createScene10() { var scene = new StoryScene(); var lizard = scene.addElement('lizard', 0, 0, 2.2); lizard.tint = 0x90ee90; // Sick green tint scene.addElement('moon', -400, -200); return scene; } function createScene11() { var scene = new StoryScene(); scene.addElement('lizard', -100, 0, 1.5); scene.addElement('leaf', 100, 0, 0.8); return scene; } function createScene12() { var scene = new StoryScene(); scene.addElement('cocoon', 0, 0); return scene; } function createScene13() { var scene = new StoryScene(); scene.addElement('dragonfly', 0, 0, 1.5); return scene; } // Initialize all scenes scenes[0] = createScene1(); scenes[1] = createScene2(); scenes[2] = createScene3(); scenes[3] = createScene4(); scenes[4] = createScene5(); scenes[5] = createScene6(); scenes[6] = createScene7(); scenes[7] = createScene8(); scenes[8] = createScene9(); scenes[9] = createScene10(); scenes[10] = createScene11(); scenes[11] = createScene12(); scenes[12] = createScene13(); var sceneTexts = ["In the light of the moon, a little egg lay on a leaf.", "One sunny morning the warm sun came up and -pop!- out of the egg came a tiny and very hungry lizard.", "He started to look for some food.", "On Monday he ate through one apple. But he was still hungry.", "On Tuesday he ate through two pears, but he was still hungry.", "On Wednesday he ate through three plums, but he was still hungry.", "On Thursday he ate through four strawberries, but he was still hungry.", "On Friday he ate through five oranges, but he was still hungry.", "On Saturday he ate through one piece of pie, one sausage, one lollipop and one slice of watermelon. That night he had a stomachache!", "The next day was Sunday again. The lizard ate through one nice green leaf, and after that he felt much better.", "Now he wasn't hungry any more--and he wasn't a little lizard any more. He was a big, fat lizard.", "He built a small house, called a cocoon, around himself.", "He stayed inside for more than two weeks. Then he nibbled a hole in the cocoon, pushed his way out and... he was a beautiful dragonfly!"]; var storyText = null; function showScene(sceneIndex) { // Remove current scene if (currentSceneContainer) { currentSceneContainer.destroy(); } if (continueButton) { continueButton.destroy(); } if (storyText) { storyText.destroy(); } // Add new scene to TV screen currentSceneContainer = tvScreen.addChild(scenes[sceneIndex]); currentSceneContainer.animate(); // Add story text below TV storyText = new Text2(sceneTexts[sceneIndex], { size: 40, fill: 0x000000, wordWrap: true, wordWrapWidth: 1800 }); storyText.anchor.set(0.5, 0); storyText.x = 1024; storyText.y = 1600; game.addChild(storyText); // Add continue/again button var buttonText = sceneIndex < scenes.length - 1 ? "CONTINUE" : "PLAY AGAIN"; continueButton = game.addChild(new GreenButton(buttonText, function () { if (sceneIndex < scenes.length - 1) { showScene(sceneIndex + 1); } else { // Restart story showScene(0); } })); continueButton.x = 1024; continueButton.y = 2200; } game.update = function () { // No continuous updates needed for this story-based game };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,274 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var GreenButton = Container.expand(function (text, callback) {
+ var self = Container.call(this);
+ var bg = self.attachAsset('continueButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var buttonText = new Text2(text, {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ self.down = function () {
+ LK.getSound('tap').play();
+ if (callback) callback();
+ };
+ return self;
+});
+var StoryScene = Container.expand(function () {
+ var self = Container.call(this);
+ self.elements = [];
+ self.addElement = function (assetId, x, y, scale) {
+ var element = self.attachAsset(assetId, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: x,
+ y: y,
+ scaleX: scale || 1,
+ scaleY: scale || 1
+ });
+ self.elements.push(element);
+ return element;
+ };
+ self.animate = function () {
+ // Simple fade-in animation for all elements
+ for (var i = 0; i < self.elements.length; i++) {
+ var element = self.elements[i];
+ element.alpha = 0;
+ tween(element, {
+ alpha: 1
+ }, {
+ duration: 500 + i * 200
+ });
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+// Story elements
+// Powerpuff Girls (simplified colored shapes)
+// Background and UI elements
+var currentScene = 0;
+var isStoryStarted = false;
+var scenes = [];
+var currentSceneContainer = null;
+var continueButton = null;
+// TV setup
+var tvFrame = game.addChild(LK.getAsset('tvFrame', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 900
+}));
+var tvScreen = game.addChild(LK.getAsset('tvScreen', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 900
+}));
+// Powerpuff Girls
+var blossom = game.addChild(LK.getAsset('blossom', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 700,
+ y: 1700
+}));
+var bubbles = game.addChild(LK.getAsset('bubbles', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 1024,
+ y: 1700
+}));
+var buttercup = game.addChild(LK.getAsset('buttercup', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 1348,
+ y: 1700
+}));
+// Title text
+var titleText = new Text2("The Very Hungry Lizard Story", {
+ size: 60,
+ fill: 0xFFFFFF
+});
+titleText.anchor.set(0.5, 0.5);
+titleText.x = 1024;
+titleText.y = 300;
+game.addChild(titleText);
+// Initial play button
+var playButton = game.addChild(new GreenButton("PLAY", startStory));
+playButton.x = 1024;
+playButton.y = 900;
+function startStory() {
+ isStoryStarted = true;
+ currentScene = 0;
+ playButton.visible = false;
+ titleText.visible = false;
+ showScene(0);
+}
+function createScene1() {
+ var scene = new StoryScene();
+ scene.addElement('leaf', 0, 100, 1.5);
+ scene.addElement('egg', 0, 0);
+ scene.addElement('moon', -400, -200);
+ return scene;
+}
+function createScene2() {
+ var scene = new StoryScene();
+ scene.addElement('leaf', 0, 100, 1.5);
+ scene.addElement('sun', 400, -200);
+ return scene;
+}
+function createScene3() {
+ var scene = new StoryScene();
+ scene.addElement('leaf', 0, 100, 1.5);
+ scene.addElement('lizard', 0, 0);
+ return scene;
+}
+function createScene4() {
+ var scene = new StoryScene();
+ scene.addElement('lizard', -200, 0);
+ scene.addElement('apple', 200, 0);
+ return scene;
+}
+function createScene5() {
+ var scene = new StoryScene();
+ scene.addElement('lizard', -200, 0, 1.2);
+ scene.addElement('pear', 100, -50);
+ scene.addElement('pear', 150, 50);
+ return scene;
+}
+function createScene6() {
+ var scene = new StoryScene();
+ scene.addElement('lizard', -200, 0, 1.4);
+ scene.addElement('plum', 80, -80);
+ scene.addElement('plum', 150, 0);
+ scene.addElement('plum', 120, 80);
+ return scene;
+}
+function createScene7() {
+ var scene = new StoryScene();
+ scene.addElement('lizard', -250, 0, 1.6);
+ scene.addElement('strawberry', 80, -100);
+ scene.addElement('strawberry', 150, -30);
+ scene.addElement('strawberry', 120, 40);
+ scene.addElement('strawberry', 180, 100);
+ return scene;
+}
+function createScene8() {
+ var scene = new StoryScene();
+ scene.addElement('lizard', -250, 0, 1.8);
+ scene.addElement('orange', 60, -120);
+ scene.addElement('orange', 130, -60);
+ scene.addElement('orange', 100, 0);
+ scene.addElement('orange', 160, 60);
+ scene.addElement('orange', 200, 120);
+ return scene;
+}
+function createScene9() {
+ var scene = new StoryScene();
+ scene.addElement('lizard', -250, 0, 2);
+ scene.addElement('pie', 100, -100);
+ scene.addElement('sausage', 150, -30);
+ scene.addElement('lollipop', 200, 40);
+ scene.addElement('watermelon', 120, 120);
+ return scene;
+}
+function createScene10() {
+ var scene = new StoryScene();
+ var lizard = scene.addElement('lizard', 0, 0, 2.2);
+ lizard.tint = 0x90ee90; // Sick green tint
+ scene.addElement('moon', -400, -200);
+ return scene;
+}
+function createScene11() {
+ var scene = new StoryScene();
+ scene.addElement('lizard', -100, 0, 1.5);
+ scene.addElement('leaf', 100, 0, 0.8);
+ return scene;
+}
+function createScene12() {
+ var scene = new StoryScene();
+ scene.addElement('cocoon', 0, 0);
+ return scene;
+}
+function createScene13() {
+ var scene = new StoryScene();
+ scene.addElement('dragonfly', 0, 0, 1.5);
+ return scene;
+}
+// Initialize all scenes
+scenes[0] = createScene1();
+scenes[1] = createScene2();
+scenes[2] = createScene3();
+scenes[3] = createScene4();
+scenes[4] = createScene5();
+scenes[5] = createScene6();
+scenes[6] = createScene7();
+scenes[7] = createScene8();
+scenes[8] = createScene9();
+scenes[9] = createScene10();
+scenes[10] = createScene11();
+scenes[11] = createScene12();
+scenes[12] = createScene13();
+var sceneTexts = ["In the light of the moon, a little egg lay on a leaf.", "One sunny morning the warm sun came up and -pop!- out of the egg came a tiny and very hungry lizard.", "He started to look for some food.", "On Monday he ate through one apple. But he was still hungry.", "On Tuesday he ate through two pears, but he was still hungry.", "On Wednesday he ate through three plums, but he was still hungry.", "On Thursday he ate through four strawberries, but he was still hungry.", "On Friday he ate through five oranges, but he was still hungry.", "On Saturday he ate through one piece of pie, one sausage, one lollipop and one slice of watermelon. That night he had a stomachache!", "The next day was Sunday again. The lizard ate through one nice green leaf, and after that he felt much better.", "Now he wasn't hungry any more--and he wasn't a little lizard any more. He was a big, fat lizard.", "He built a small house, called a cocoon, around himself.", "He stayed inside for more than two weeks. Then he nibbled a hole in the cocoon, pushed his way out and... he was a beautiful dragonfly!"];
+var storyText = null;
+function showScene(sceneIndex) {
+ // Remove current scene
+ if (currentSceneContainer) {
+ currentSceneContainer.destroy();
+ }
+ if (continueButton) {
+ continueButton.destroy();
+ }
+ if (storyText) {
+ storyText.destroy();
+ }
+ // Add new scene to TV screen
+ currentSceneContainer = tvScreen.addChild(scenes[sceneIndex]);
+ currentSceneContainer.animate();
+ // Add story text below TV
+ storyText = new Text2(sceneTexts[sceneIndex], {
+ size: 40,
+ fill: 0x000000,
+ wordWrap: true,
+ wordWrapWidth: 1800
+ });
+ storyText.anchor.set(0.5, 0);
+ storyText.x = 1024;
+ storyText.y = 1600;
+ game.addChild(storyText);
+ // Add continue/again button
+ var buttonText = sceneIndex < scenes.length - 1 ? "CONTINUE" : "PLAY AGAIN";
+ continueButton = game.addChild(new GreenButton(buttonText, function () {
+ if (sceneIndex < scenes.length - 1) {
+ showScene(sceneIndex + 1);
+ } else {
+ // Restart story
+ showScene(0);
+ }
+ }));
+ continueButton.x = 1024;
+ continueButton.y = 2200;
+}
+game.update = function () {
+ // No continuous updates needed for this story-based game
+};
\ No newline at end of file