Code edit (1 edits merged)
Please save this source code
User prompt
Powerpuff Girls: Balloon Rescue
Initial prompt
The powerpuff girls: Bella pig’s little brother named Jorge pig 🐷 has not let the green dinosaur balloon and it is flying to the moon. Tap the green button to call the powerpuff girls. Tap the red button to end call. Tap on the powerpuff girls to fly to get the green dinosaur balloon (no levels)
/**** * 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 }); self.speed = -2; self.isCaught = false; self.update = function () { if (!self.isCaught) { self.y += self.speed; if (self.y < -200) { self.y = 2732 + 200; } } }; self["catch"] = function () { self.isCaught = true; tween(self, { y: 2400 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { self.isCaught = false; self.speed *= 1.1; } }); }; return self; }); var CallButton = Container.expand(function (color, action) { var self = Container.call(this); var buttonGraphics = self.attachAsset(color + 'Button', { anchorX: 0.5, anchorY: 0.5 }); self.down = function () { action(); tween(self, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); }; self.up = function () { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100 }); }; return self; }); var PowerpuffGirl = Container.expand(function (color, xPos) { var self = Container.call(this); var girlGraphics = self.attachAsset(color, { anchorX: 0.5, anchorY: 0.5 }); self.isFlying = false; self.targetY = 0; self.down = function () { if (!self.isFlying && balloon) { self.isFlying = true; self.targetY = balloon.y; tween(self, { y: self.targetY }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { if (self.intersects(balloon)) { balloon["catch"](); LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); } tween(self, { y: 2200 }, { duration: 600, easing: tween.easeIn, onFinish: function onFinish() { self.isFlying = false; } }); } }); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ var balloon; var moon; var greenButton; var redButton; var blossom; var bubbles; var buttercup; var girlsActive = false; var scoreTxt; moon = LK.getAsset('moon', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 300 }); game.addChild(moon); balloon = new Balloon(); balloon.x = 1024; balloon.y = 2400; game.addChild(balloon); function showPowerpuffGirls() { if (girlsActive) return; girlsActive = true; blossom = new PowerpuffGirl('blossom'); blossom.x = 624; blossom.y = 2200; game.addChild(blossom); bubbles = new PowerpuffGirl('bubbles'); bubbles.x = 1024; bubbles.y = 2200; game.addChild(bubbles); buttercup = new PowerpuffGirl('buttercup'); buttercup.x = 1424; buttercup.y = 2200; game.addChild(buttercup); tween(blossom, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.bounceOut }); tween(bubbles, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.bounceOut }); tween(buttercup, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.bounceOut }); } function hidePowerpuffGirls() { if (!girlsActive) return; girlsActive = false; if (blossom) { blossom.destroy(); blossom = null; } if (bubbles) { bubbles.destroy(); bubbles = null; } if (buttercup) { buttercup.destroy(); buttercup = null; } } greenButton = new CallButton('green', showPowerpuffGirls); greenButton.x = 512; greenButton.y = 2532; game.addChild(greenButton); redButton = new CallButton('red', hidePowerpuffGirls); redButton.x = 1536; redButton.y = 2532; game.addChild(redButton); scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); game.update = function () {};
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,201 @@
-/****
+/****
+* 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
+ });
+ self.speed = -2;
+ self.isCaught = false;
+ self.update = function () {
+ if (!self.isCaught) {
+ self.y += self.speed;
+ if (self.y < -200) {
+ self.y = 2732 + 200;
+ }
+ }
+ };
+ self["catch"] = function () {
+ self.isCaught = true;
+ tween(self, {
+ y: 2400
+ }, {
+ duration: 1000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.isCaught = false;
+ self.speed *= 1.1;
+ }
+ });
+ };
+ return self;
+});
+var CallButton = Container.expand(function (color, action) {
+ var self = Container.call(this);
+ var buttonGraphics = self.attachAsset(color + 'Button', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.down = function () {
+ action();
+ tween(self, {
+ scaleX: 0.9,
+ scaleY: 0.9
+ }, {
+ duration: 100
+ });
+ };
+ self.up = function () {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ };
+ return self;
+});
+var PowerpuffGirl = Container.expand(function (color, xPos) {
+ var self = Container.call(this);
+ var girlGraphics = self.attachAsset(color, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isFlying = false;
+ self.targetY = 0;
+ self.down = function () {
+ if (!self.isFlying && balloon) {
+ self.isFlying = true;
+ self.targetY = balloon.y;
+ tween(self, {
+ y: self.targetY
+ }, {
+ duration: 800,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ if (self.intersects(balloon)) {
+ balloon["catch"]();
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ }
+ tween(self, {
+ y: 2200
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.isFlying = false;
+ }
+ });
+ }
+ });
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+var balloon;
+var moon;
+var greenButton;
+var redButton;
+var blossom;
+var bubbles;
+var buttercup;
+var girlsActive = false;
+var scoreTxt;
+moon = LK.getAsset('moon', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 300
+});
+game.addChild(moon);
+balloon = new Balloon();
+balloon.x = 1024;
+balloon.y = 2400;
+game.addChild(balloon);
+function showPowerpuffGirls() {
+ if (girlsActive) return;
+ girlsActive = true;
+ blossom = new PowerpuffGirl('blossom');
+ blossom.x = 624;
+ blossom.y = 2200;
+ game.addChild(blossom);
+ bubbles = new PowerpuffGirl('bubbles');
+ bubbles.x = 1024;
+ bubbles.y = 2200;
+ game.addChild(bubbles);
+ buttercup = new PowerpuffGirl('buttercup');
+ buttercup.x = 1424;
+ buttercup.y = 2200;
+ game.addChild(buttercup);
+ tween(blossom, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.bounceOut
+ });
+ tween(bubbles, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.bounceOut
+ });
+ tween(buttercup, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.bounceOut
+ });
+}
+function hidePowerpuffGirls() {
+ if (!girlsActive) return;
+ girlsActive = false;
+ if (blossom) {
+ blossom.destroy();
+ blossom = null;
+ }
+ if (bubbles) {
+ bubbles.destroy();
+ bubbles = null;
+ }
+ if (buttercup) {
+ buttercup.destroy();
+ buttercup = null;
+ }
+}
+greenButton = new CallButton('green', showPowerpuffGirls);
+greenButton.x = 512;
+greenButton.y = 2532;
+game.addChild(greenButton);
+redButton = new CallButton('red', hidePowerpuffGirls);
+redButton.x = 1536;
+redButton.y = 2532;
+game.addChild(redButton);
+scoreTxt = new Text2('0', {
+ size: 120,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+game.update = function () {};
\ No newline at end of file