Code edit (1 edits merged)
Please save this source code
User prompt
Pango's Sky Adventure: A Raccoon's Journey Through the Clouds
Initial prompt
Pango the blue raccoon stories 💙: setup ⛅️. Where you introduce the story setting and characters, the conflict 🌩️. Where you create a problem for your characters, the challenge 🌧️. Where you make the problem even more difficult, the climax 🌪️. Where you help the characters solve the problem, the resolution 🌈. Where you show the problem has been solved.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphic = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); self.drift = function () { tween(self, { x: self.x + (Math.random() - 0.5) * 100 }, { duration: 3000 + Math.random() * 2000, easing: tween.easeInOut, onFinish: function onFinish() { self.drift(); } }); }; return self; }); var Pango = Container.expand(function () { var self = Container.call(this); var pangoGraphic = self.attachAsset('pango', { anchorX: 0.5, anchorY: 0.5 }); self.bob = function () { tween(self, { y: self.y - 20 }, { duration: 1500, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { y: self.y + 20 }, { duration: 1500, easing: tween.easeInOut, onFinish: function onFinish() { self.bob(); } }); } }); }; self.bounce = function () { tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeIn }); } }); }; return self; }); var TapIndicator = Container.expand(function () { var self = Container.call(this); var indicator = self.attachAsset('tapIndicator', { anchorX: 0.5, anchorY: 0.5 }); self.alpha = 0.7; self.pulse = function () { tween(self, { scaleX: 1.3, scaleY: 1.3, alpha: 1 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1, alpha: 0.7 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { self.pulse(); } }); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Story structure var chapters = [{ title: "Chapter 1: Peaceful Clouds", segments: ["Meet Pango, a curious blue raccoon who lives among the fluffy white clouds.", "Every day, Pango explores his peaceful sky world, bouncing from cloud to cloud.", "The gentle breeze carries him softly through the endless blue sky.", "Life is simple and beautiful in Pango's cloud kingdom."] }, { title: "Chapter 2: The Problem", segments: ["One morning, Pango notices something strange in the distance.", "Dark storm clouds are gathering on the horizon, moving closer.", "The peaceful clouds around him begin to fade and disappear.", "Pango realizes his beautiful sky world is in danger!"] }, { title: "Chapter 3: Rising Challenge", segments: ["The storm clouds grow stronger, bringing fierce winds.", "Pango struggles to stay on his cloud as it shakes and wobbles.", "More and more clouds vanish into the growing darkness.", "Pango must find a way to save his home before it's too late."] }, { title: "Chapter 4: The Climax", segments: ["Pango discovers a magical star hidden deep within the storm.", "He must brave the strongest winds to reach the glowing star.", "With all his courage, Pango leaps toward the star through the darkness.", "The star's light begins to push back the storm clouds!"] }, { title: "Chapter 5: Happy Resolution", segments: ["The magical star's light spreads across the entire sky.", "All the storm clouds fade away, replaced by beautiful white clouds.", "Pango's cloud world is restored to its peaceful glory.", "Our brave raccoon hero can now explore his sky kingdom forever!"] }]; // Game state var currentChapter = 0; var currentSegment = 0; var isTransitioning = false; // Game elements var pango; var clouds = []; var stormClouds = []; var stars = []; var tapIndicator; // UI elements var chapterTitle; var storyText; // Initialize UI chapterTitle = new Text2(chapters[0].title, { size: 80, fill: 0xFFFFFF }); chapterTitle.anchor.set(0.5, 0); LK.gui.top.addChild(chapterTitle); chapterTitle.y = 150; storyText = new Text2(chapters[0].segments[0], { size: 60, fill: 0xFFFFFF }); storyText.anchor.set(0.5, 1); LK.gui.bottom.addChild(storyText); storyText.y = -200; // Initialize game world pango = game.addChild(new Pango()); pango.x = 1024; pango.y = 1366; pango.bob(); // Create initial clouds for (var i = 0; i < 6; i++) { var cloud = game.addChild(new Cloud()); cloud.x = Math.random() * 2048; cloud.y = 800 + Math.random() * 1200; cloud.drift(); clouds.push(cloud); } // Create tap indicator tapIndicator = game.addChild(new TapIndicator()); tapIndicator.x = 1024; tapIndicator.y = 2400; tapIndicator.pulse(); // Story progression function function progressStory() { if (isTransitioning) return; isTransitioning = true; LK.getSound('tap').play(); // Animate pango response pango.bounce(); // Hide tap indicator temporarily tapIndicator.alpha = 0; // Progress to next segment currentSegment++; if (currentSegment >= chapters[currentChapter].segments.length) { // Move to next chapter currentChapter++; currentSegment = 0; if (currentChapter >= chapters.length) { // Game complete LK.showYouWin(); return; } // Update chapter-specific visuals updateChapterVisuals(); } // Update text if (currentChapter < chapters.length) { chapterTitle.setText(chapters[currentChapter].title); storyText.setText(chapters[currentChapter].segments[currentSegment]); } // Re-enable interaction after transition LK.setTimeout(function () { isTransitioning = false; tapIndicator.alpha = 0.7; }, 1000); } // Update visuals based on current chapter function updateChapterVisuals() { switch (currentChapter) { case 0: // Peaceful setup game.setBackgroundColor(0x87CEEB); break; case 1: // Problem introduction game.setBackgroundColor(0x708090); // Add some small storm clouds for (var i = 0; i < 2; i++) { var storm = game.addChild(LK.getAsset('storm', { anchorX: 0.5, anchorY: 0.5, x: 1800 + Math.random() * 248, y: 500 + Math.random() * 500 })); stormClouds.push(storm); } LK.getSound('wind').play(); break; case 2: // Rising challenge game.setBackgroundColor(0x555555); // Add more storm clouds for (var i = 0; i < 3; i++) { var storm = game.addChild(LK.getAsset('storm', { anchorX: 0.5, anchorY: 0.5, x: Math.random() * 2048, y: 400 + Math.random() * 600 })); stormClouds.push(storm); } // Make some clouds fade for (var i = 0; i < 3; i++) { if (clouds[i]) { tween(clouds[i], { alpha: 0.3 }, { duration: 2000 }); } } break; case 3: // Climax game.setBackgroundColor(0x2F2F2F); // Add magical star var star = game.addChild(LK.getAsset('star', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 600 })); stars.push(star); // Make star glow tween(star, { scaleX: 1.5, scaleY: 1.5 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(star, { scaleX: 1, scaleY: 1 }, { duration: 1000, easing: tween.easeInOut }); } }); break; case 4: // Resolution game.setBackgroundColor(0x87CEEB); LK.getSound('resolve').play(); // Remove storm clouds for (var i = 0; i < stormClouds.length; i++) { if (stormClouds[i]) { tween(stormClouds[i], { alpha: 0 }, { duration: 2000, onFinish: function onFinish() { if (stormClouds[i]) { stormClouds[i].destroy(); } } }); } } // Restore clouds for (var i = 0; i < clouds.length; i++) { if (clouds[i]) { tween(clouds[i], { alpha: 1 }, { duration: 2000 }); } } // Add more beautiful clouds for (var i = 0; i < 3; i++) { var cloud = game.addChild(new Cloud()); cloud.x = Math.random() * 2048; cloud.y = 800 + Math.random() * 1200; cloud.alpha = 0; cloud.drift(); clouds.push(cloud); tween(cloud, { alpha: 1 }, { duration: 2000 }); } break; } } // Touch handling game.down = function (x, y, obj) { progressStory(); }; // Game update loop game.update = function () { // Gentle cloud movement based on chapter if (currentChapter >= 2 && currentChapter <= 3) { // Add some wind effect during storm chapters for (var i = 0; i < clouds.length; i++) { if (clouds[i]) { clouds[i].x += Math.sin(LK.ticks * 0.02) * 0.5; } } // Make pango sway in the wind pango.x = 1024 + Math.sin(LK.ticks * 0.03) * 30; } // Sparkle effect for stars for (var i = 0; i < stars.length; i++) { if (stars[i]) { stars[i].rotation += 0.02; } } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,357 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Cloud = Container.expand(function () {
+ var self = Container.call(this);
+ var cloudGraphic = self.attachAsset('cloud', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.drift = function () {
+ tween(self, {
+ x: self.x + (Math.random() - 0.5) * 100
+ }, {
+ duration: 3000 + Math.random() * 2000,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ self.drift();
+ }
+ });
+ };
+ return self;
+});
+var Pango = Container.expand(function () {
+ var self = Container.call(this);
+ var pangoGraphic = self.attachAsset('pango', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.bob = function () {
+ tween(self, {
+ y: self.y - 20
+ }, {
+ duration: 1500,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ y: self.y + 20
+ }, {
+ duration: 1500,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ self.bob();
+ }
+ });
+ }
+ });
+ };
+ self.bounce = function () {
+ tween(self, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeIn
+ });
+ }
+ });
+ };
+ return self;
+});
+var TapIndicator = Container.expand(function () {
+ var self = Container.call(this);
+ var indicator = self.attachAsset('tapIndicator', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.alpha = 0.7;
+ self.pulse = function () {
+ tween(self, {
+ scaleX: 1.3,
+ scaleY: 1.3,
+ alpha: 1
+ }, {
+ duration: 800,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1,
+ alpha: 0.7
+ }, {
+ duration: 800,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ self.pulse();
+ }
+ });
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+// Story structure
+var chapters = [{
+ title: "Chapter 1: Peaceful Clouds",
+ segments: ["Meet Pango, a curious blue raccoon who lives among the fluffy white clouds.", "Every day, Pango explores his peaceful sky world, bouncing from cloud to cloud.", "The gentle breeze carries him softly through the endless blue sky.", "Life is simple and beautiful in Pango's cloud kingdom."]
+}, {
+ title: "Chapter 2: The Problem",
+ segments: ["One morning, Pango notices something strange in the distance.", "Dark storm clouds are gathering on the horizon, moving closer.", "The peaceful clouds around him begin to fade and disappear.", "Pango realizes his beautiful sky world is in danger!"]
+}, {
+ title: "Chapter 3: Rising Challenge",
+ segments: ["The storm clouds grow stronger, bringing fierce winds.", "Pango struggles to stay on his cloud as it shakes and wobbles.", "More and more clouds vanish into the growing darkness.", "Pango must find a way to save his home before it's too late."]
+}, {
+ title: "Chapter 4: The Climax",
+ segments: ["Pango discovers a magical star hidden deep within the storm.", "He must brave the strongest winds to reach the glowing star.", "With all his courage, Pango leaps toward the star through the darkness.", "The star's light begins to push back the storm clouds!"]
+}, {
+ title: "Chapter 5: Happy Resolution",
+ segments: ["The magical star's light spreads across the entire sky.", "All the storm clouds fade away, replaced by beautiful white clouds.", "Pango's cloud world is restored to its peaceful glory.", "Our brave raccoon hero can now explore his sky kingdom forever!"]
+}];
+// Game state
+var currentChapter = 0;
+var currentSegment = 0;
+var isTransitioning = false;
+// Game elements
+var pango;
+var clouds = [];
+var stormClouds = [];
+var stars = [];
+var tapIndicator;
+// UI elements
+var chapterTitle;
+var storyText;
+// Initialize UI
+chapterTitle = new Text2(chapters[0].title, {
+ size: 80,
+ fill: 0xFFFFFF
+});
+chapterTitle.anchor.set(0.5, 0);
+LK.gui.top.addChild(chapterTitle);
+chapterTitle.y = 150;
+storyText = new Text2(chapters[0].segments[0], {
+ size: 60,
+ fill: 0xFFFFFF
+});
+storyText.anchor.set(0.5, 1);
+LK.gui.bottom.addChild(storyText);
+storyText.y = -200;
+// Initialize game world
+pango = game.addChild(new Pango());
+pango.x = 1024;
+pango.y = 1366;
+pango.bob();
+// Create initial clouds
+for (var i = 0; i < 6; i++) {
+ var cloud = game.addChild(new Cloud());
+ cloud.x = Math.random() * 2048;
+ cloud.y = 800 + Math.random() * 1200;
+ cloud.drift();
+ clouds.push(cloud);
+}
+// Create tap indicator
+tapIndicator = game.addChild(new TapIndicator());
+tapIndicator.x = 1024;
+tapIndicator.y = 2400;
+tapIndicator.pulse();
+// Story progression function
+function progressStory() {
+ if (isTransitioning) return;
+ isTransitioning = true;
+ LK.getSound('tap').play();
+ // Animate pango response
+ pango.bounce();
+ // Hide tap indicator temporarily
+ tapIndicator.alpha = 0;
+ // Progress to next segment
+ currentSegment++;
+ if (currentSegment >= chapters[currentChapter].segments.length) {
+ // Move to next chapter
+ currentChapter++;
+ currentSegment = 0;
+ if (currentChapter >= chapters.length) {
+ // Game complete
+ LK.showYouWin();
+ return;
+ }
+ // Update chapter-specific visuals
+ updateChapterVisuals();
+ }
+ // Update text
+ if (currentChapter < chapters.length) {
+ chapterTitle.setText(chapters[currentChapter].title);
+ storyText.setText(chapters[currentChapter].segments[currentSegment]);
+ }
+ // Re-enable interaction after transition
+ LK.setTimeout(function () {
+ isTransitioning = false;
+ tapIndicator.alpha = 0.7;
+ }, 1000);
+}
+// Update visuals based on current chapter
+function updateChapterVisuals() {
+ switch (currentChapter) {
+ case 0:
+ // Peaceful setup
+ game.setBackgroundColor(0x87CEEB);
+ break;
+ case 1:
+ // Problem introduction
+ game.setBackgroundColor(0x708090);
+ // Add some small storm clouds
+ for (var i = 0; i < 2; i++) {
+ var storm = game.addChild(LK.getAsset('storm', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1800 + Math.random() * 248,
+ y: 500 + Math.random() * 500
+ }));
+ stormClouds.push(storm);
+ }
+ LK.getSound('wind').play();
+ break;
+ case 2:
+ // Rising challenge
+ game.setBackgroundColor(0x555555);
+ // Add more storm clouds
+ for (var i = 0; i < 3; i++) {
+ var storm = game.addChild(LK.getAsset('storm', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: Math.random() * 2048,
+ y: 400 + Math.random() * 600
+ }));
+ stormClouds.push(storm);
+ }
+ // Make some clouds fade
+ for (var i = 0; i < 3; i++) {
+ if (clouds[i]) {
+ tween(clouds[i], {
+ alpha: 0.3
+ }, {
+ duration: 2000
+ });
+ }
+ }
+ break;
+ case 3:
+ // Climax
+ game.setBackgroundColor(0x2F2F2F);
+ // Add magical star
+ var star = game.addChild(LK.getAsset('star', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 600
+ }));
+ stars.push(star);
+ // Make star glow
+ tween(star, {
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(star, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut
+ });
+ }
+ });
+ break;
+ case 4:
+ // Resolution
+ game.setBackgroundColor(0x87CEEB);
+ LK.getSound('resolve').play();
+ // Remove storm clouds
+ for (var i = 0; i < stormClouds.length; i++) {
+ if (stormClouds[i]) {
+ tween(stormClouds[i], {
+ alpha: 0
+ }, {
+ duration: 2000,
+ onFinish: function onFinish() {
+ if (stormClouds[i]) {
+ stormClouds[i].destroy();
+ }
+ }
+ });
+ }
+ }
+ // Restore clouds
+ for (var i = 0; i < clouds.length; i++) {
+ if (clouds[i]) {
+ tween(clouds[i], {
+ alpha: 1
+ }, {
+ duration: 2000
+ });
+ }
+ }
+ // Add more beautiful clouds
+ for (var i = 0; i < 3; i++) {
+ var cloud = game.addChild(new Cloud());
+ cloud.x = Math.random() * 2048;
+ cloud.y = 800 + Math.random() * 1200;
+ cloud.alpha = 0;
+ cloud.drift();
+ clouds.push(cloud);
+ tween(cloud, {
+ alpha: 1
+ }, {
+ duration: 2000
+ });
+ }
+ break;
+ }
+}
+// Touch handling
+game.down = function (x, y, obj) {
+ progressStory();
+};
+// Game update loop
+game.update = function () {
+ // Gentle cloud movement based on chapter
+ if (currentChapter >= 2 && currentChapter <= 3) {
+ // Add some wind effect during storm chapters
+ for (var i = 0; i < clouds.length; i++) {
+ if (clouds[i]) {
+ clouds[i].x += Math.sin(LK.ticks * 0.02) * 0.5;
+ }
+ }
+ // Make pango sway in the wind
+ pango.x = 1024 + Math.sin(LK.ticks * 0.03) * 30;
+ }
+ // Sparkle effect for stars
+ for (var i = 0; i < stars.length; i++) {
+ if (stars[i]) {
+ stars[i].rotation += 0.02;
+ }
+ }
+};
\ No newline at end of file