Code edit (1 edits merged)
Please save this source code
User prompt
Troll Bridge Live: Powerpuff Girls Adventure
Initial prompt
Toca big fun showtime 2 (2016). The powerpuff girls are outside in town at night š. This show is called ātroll bridge liveā. Tap on 2 red curtains to make them go left from the beginning, tap on 3 goats to make them go meeh or baaaah, tap on dirty Danās bum to make it go down the chimney, the third goat said ādirty Dan?! Why are you here?ā, the second goat š getting dirty Dan off the chimney, so 3 goats go to the supermarket to see dirty Dan, outside at home the 3 goats want to ride a flying and fast car š, meeting nice Dan, celebrating with confetti and snowfall
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Confetti = Container.expand(function () { var self = Container.call(this); var confettiGraphics = self.attachAsset('confetti', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 3 + 2; self.rotationSpeed = Math.random() * 0.2 - 0.1; self.update = function () { self.y += self.speed; self.rotation += self.rotationSpeed; if (self.y > 2732 + 50) { self.y = -50; self.x = Math.random() * 2048; } }; return self; }); var DirtyDan = Container.expand(function () { var self = Container.call(this); var danGraphics = self.attachAsset('dirtyDan', { anchorX: 0.5, anchorY: 0.5 }); self.fallDown = function () { LK.getSound('whoosh').play(); tween(self, { y: self.y + 400, alpha: 0 }, { duration: 800, easing: tween.easeIn }); }; self.down = function (x, y, obj) { if (currentScene === 3) { self.fallDown(); LK.setTimeout(function () { nextScene(); }, 1000); } }; return self; }); var Goat = Container.expand(function () { var self = Container.call(this); var goatGraphics = self.attachAsset('goat', { anchorX: 0.5, anchorY: 0.5 }); self.vocalize = function () { var sound = Math.random() > 0.5 ? 'meeh' : 'baaaah'; LK.getSound(sound).play(); tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 200, easing: tween.easeOut }); tween(self, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeIn }); }; self.down = function (x, y, obj) { if (currentScene === 2) { self.vocalize(); goatsVocalized++; if (goatsVocalized >= 3) { LK.setTimeout(function () { nextScene(); }, 1000); } } }; return self; }); var NiceDan = Container.expand(function () { var self = Container.call(this); var danGraphics = self.attachAsset('niceDan', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var RedCurtain = Container.expand(function () { var self = Container.call(this); var curtainGraphics = self.attachAsset('redCurtain', { anchorX: 0.5, anchorY: 0.5 }); self.slideLeft = function () { tween(self, { x: self.x - 700 }, { duration: 1000, easing: tween.easeOut }); }; self.down = function (x, y, obj) { if (currentScene === 1) { self.slideLeft(); curtainsOpened++; if (curtainsOpened >= 2) { LK.setTimeout(function () { nextScene(); }, 1200); } } }; return self; }); var Snowflake = Container.expand(function () { var self = Container.call(this); var snowGraphics = self.attachAsset('snowflake', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 2 + 1; 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; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000080 }); /**** * Game Code ****/ var currentScene = 1; var curtainsOpened = 0; var goatsVocalized = 0; var confettiParticles = []; var snowParticles = []; // Background var nightSky = game.addChild(LK.getAsset('nightSky', { anchorX: 0, anchorY: 0, x: 0, y: 0 })); // Scene 1: Stage and Curtains var stage = game.addChild(LK.getAsset('stage', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1366 })); var leftCurtain = game.addChild(new RedCurtain()); leftCurtain.x = 2048 / 2 - 300; leftCurtain.y = 1366; var rightCurtain = game.addChild(new RedCurtain()); rightCurtain.x = 2048 / 2 + 300; rightCurtain.y = 1366; // Scene 2: Goats (initially hidden) var goats = []; for (var i = 0; i < 3; i++) { var goat = game.addChild(new Goat()); goat.x = 500 + i * 400; goat.y = 1200; goat.visible = false; goats.push(goat); } // Scene 3: Chimney and Dirty Dan (initially hidden) var chimney = game.addChild(LK.getAsset('chimney', { anchorX: 0.5, anchorY: 1, x: 1600, y: 1100 })); chimney.visible = false; var dirtyDan = game.addChild(new DirtyDan()); dirtyDan.x = 1600; dirtyDan.y = 900; dirtyDan.visible = false; // Scene 6: Supermarket (initially hidden) var supermarket = game.addChild(LK.getAsset('supermarket', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1500 })); supermarket.visible = false; // Scene 7: Car (initially hidden) var car = game.addChild(LK.getAsset('car', { anchorX: 0.5, anchorY: 0.5, x: -200, y: 1000 })); car.visible = false; // Scene 8: Nice Dan (initially hidden) var niceDan = game.addChild(new NiceDan()); niceDan.x = 2048 / 2; niceDan.y = 1400; niceDan.visible = false; // Scene text var sceneText = new Text2('Tap the red curtains to begin!', { size: 80, fill: 0xFFFFFF }); sceneText.anchor.set(0.5, 0); LK.gui.top.addChild(sceneText); sceneText.y = 200; function nextScene() { currentScene++; switch (currentScene) { case 2: // Show goats for (var i = 0; i < goats.length; i++) { goats[i].visible = true; tween(goats[i], { y: 1200 }, { duration: 500, easing: tween.bounceOut }); } sceneText.setText('Tap the goats to make them vocalize!'); break; case 3: // Show chimney and Dirty Dan chimney.visible = true; dirtyDan.visible = true; sceneText.setText('Tap Dirty Dan to make him fall!'); break; case 4: // Third goat reacts sceneText.setText('Oh no! What happened to Dirty Dan?'); tween(goats[2], { x: goats[2].x + 100 }, { duration: 500, easing: tween.easeOut }); LK.setTimeout(function () { nextScene(); }, 2000); break; case 5: // Second goat helps sceneText.setText('Let me help get him out!'); tween(goats[1], { x: 1500 }, { duration: 1000, easing: tween.easeOut }); LK.setTimeout(function () { nextScene(); }, 2000); break; case 6: // Travel to supermarket sceneText.setText('Let\'s go to the supermarket to find Dirty Dan!'); supermarket.visible = true; // Move all goats to supermarket for (var i = 0; i < goats.length; i++) { tween(goats[i], { x: 2048 / 2 - 200 + i * 100, y: 1300 }, { duration: 1500, easing: tween.easeOut }); } LK.setTimeout(function () { nextScene(); }, 2500); break; case 7: // Flying car scene sceneText.setText('Flying home in style!'); car.visible = true; // Move goats to car for (var i = 0; i < goats.length; i++) { tween(goats[i], { x: car.x - 50 + i * 50, y: car.y - 50 }, { duration: 800, easing: tween.easeOut }); } // Fly car across screen tween(car, { x: 2048 + 200 }, { duration: 3000, easing: tween.easeOut }); LK.setTimeout(function () { nextScene(); }, 3500); break; case 8: // Meet Nice Dan and celebrate sceneText.setText('Hooray! We found Nice Dan! Let\'s celebrate!'); niceDan.visible = true; // Move goats back to center for (var i = 0; i < goats.length; i++) { goats[i].x = 800 + i * 300; goats[i].y = 1400; goats[i].visible = true; tween(goats[i], { scaleX: 1.2, scaleY: 1.2 }, { duration: 200, easing: tween.bounceOut }); } LK.getSound('celebration').play(); // Create confetti for (var i = 0; i < 20; i++) { var confetti = game.addChild(new Confetti()); confetti.x = Math.random() * 2048; confetti.y = Math.random() * -500; confettiParticles.push(confetti); } // Create snowflakes for (var i = 0; i < 15; i++) { var snow = game.addChild(new Snowflake()); snow.x = Math.random() * 2048; snow.y = Math.random() * -500; snowParticles.push(snow); } break; } } game.update = function () { // Update particles in final scene if (currentScene >= 8) { for (var i = 0; i < confettiParticles.length; i++) { confettiParticles[i].update(); } for (var i = 0; i < snowParticles.length; i++) { snowParticles[i].update(); } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Confetti = Container.expand(function () {
var self = Container.call(this);
var confettiGraphics = self.attachAsset('confetti', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 3 + 2;
self.rotationSpeed = Math.random() * 0.2 - 0.1;
self.update = function () {
self.y += self.speed;
self.rotation += self.rotationSpeed;
if (self.y > 2732 + 50) {
self.y = -50;
self.x = Math.random() * 2048;
}
};
return self;
});
var DirtyDan = Container.expand(function () {
var self = Container.call(this);
var danGraphics = self.attachAsset('dirtyDan', {
anchorX: 0.5,
anchorY: 0.5
});
self.fallDown = function () {
LK.getSound('whoosh').play();
tween(self, {
y: self.y + 400,
alpha: 0
}, {
duration: 800,
easing: tween.easeIn
});
};
self.down = function (x, y, obj) {
if (currentScene === 3) {
self.fallDown();
LK.setTimeout(function () {
nextScene();
}, 1000);
}
};
return self;
});
var Goat = Container.expand(function () {
var self = Container.call(this);
var goatGraphics = self.attachAsset('goat', {
anchorX: 0.5,
anchorY: 0.5
});
self.vocalize = function () {
var sound = Math.random() > 0.5 ? 'meeh' : 'baaaah';
LK.getSound(sound).play();
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut
});
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeIn
});
};
self.down = function (x, y, obj) {
if (currentScene === 2) {
self.vocalize();
goatsVocalized++;
if (goatsVocalized >= 3) {
LK.setTimeout(function () {
nextScene();
}, 1000);
}
}
};
return self;
});
var NiceDan = Container.expand(function () {
var self = Container.call(this);
var danGraphics = self.attachAsset('niceDan', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var RedCurtain = Container.expand(function () {
var self = Container.call(this);
var curtainGraphics = self.attachAsset('redCurtain', {
anchorX: 0.5,
anchorY: 0.5
});
self.slideLeft = function () {
tween(self, {
x: self.x - 700
}, {
duration: 1000,
easing: tween.easeOut
});
};
self.down = function (x, y, obj) {
if (currentScene === 1) {
self.slideLeft();
curtainsOpened++;
if (curtainsOpened >= 2) {
LK.setTimeout(function () {
nextScene();
}, 1200);
}
}
};
return self;
});
var Snowflake = Container.expand(function () {
var self = Container.call(this);
var snowGraphics = self.attachAsset('snowflake', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 2 + 1;
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;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000080
});
/****
* Game Code
****/
var currentScene = 1;
var curtainsOpened = 0;
var goatsVocalized = 0;
var confettiParticles = [];
var snowParticles = [];
// Background
var nightSky = game.addChild(LK.getAsset('nightSky', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Scene 1: Stage and Curtains
var stage = game.addChild(LK.getAsset('stage', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 1366
}));
var leftCurtain = game.addChild(new RedCurtain());
leftCurtain.x = 2048 / 2 - 300;
leftCurtain.y = 1366;
var rightCurtain = game.addChild(new RedCurtain());
rightCurtain.x = 2048 / 2 + 300;
rightCurtain.y = 1366;
// Scene 2: Goats (initially hidden)
var goats = [];
for (var i = 0; i < 3; i++) {
var goat = game.addChild(new Goat());
goat.x = 500 + i * 400;
goat.y = 1200;
goat.visible = false;
goats.push(goat);
}
// Scene 3: Chimney and Dirty Dan (initially hidden)
var chimney = game.addChild(LK.getAsset('chimney', {
anchorX: 0.5,
anchorY: 1,
x: 1600,
y: 1100
}));
chimney.visible = false;
var dirtyDan = game.addChild(new DirtyDan());
dirtyDan.x = 1600;
dirtyDan.y = 900;
dirtyDan.visible = false;
// Scene 6: Supermarket (initially hidden)
var supermarket = game.addChild(LK.getAsset('supermarket', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 1500
}));
supermarket.visible = false;
// Scene 7: Car (initially hidden)
var car = game.addChild(LK.getAsset('car', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 1000
}));
car.visible = false;
// Scene 8: Nice Dan (initially hidden)
var niceDan = game.addChild(new NiceDan());
niceDan.x = 2048 / 2;
niceDan.y = 1400;
niceDan.visible = false;
// Scene text
var sceneText = new Text2('Tap the red curtains to begin!', {
size: 80,
fill: 0xFFFFFF
});
sceneText.anchor.set(0.5, 0);
LK.gui.top.addChild(sceneText);
sceneText.y = 200;
function nextScene() {
currentScene++;
switch (currentScene) {
case 2:
// Show goats
for (var i = 0; i < goats.length; i++) {
goats[i].visible = true;
tween(goats[i], {
y: 1200
}, {
duration: 500,
easing: tween.bounceOut
});
}
sceneText.setText('Tap the goats to make them vocalize!');
break;
case 3:
// Show chimney and Dirty Dan
chimney.visible = true;
dirtyDan.visible = true;
sceneText.setText('Tap Dirty Dan to make him fall!');
break;
case 4:
// Third goat reacts
sceneText.setText('Oh no! What happened to Dirty Dan?');
tween(goats[2], {
x: goats[2].x + 100
}, {
duration: 500,
easing: tween.easeOut
});
LK.setTimeout(function () {
nextScene();
}, 2000);
break;
case 5:
// Second goat helps
sceneText.setText('Let me help get him out!');
tween(goats[1], {
x: 1500
}, {
duration: 1000,
easing: tween.easeOut
});
LK.setTimeout(function () {
nextScene();
}, 2000);
break;
case 6:
// Travel to supermarket
sceneText.setText('Let\'s go to the supermarket to find Dirty Dan!');
supermarket.visible = true;
// Move all goats to supermarket
for (var i = 0; i < goats.length; i++) {
tween(goats[i], {
x: 2048 / 2 - 200 + i * 100,
y: 1300
}, {
duration: 1500,
easing: tween.easeOut
});
}
LK.setTimeout(function () {
nextScene();
}, 2500);
break;
case 7:
// Flying car scene
sceneText.setText('Flying home in style!');
car.visible = true;
// Move goats to car
for (var i = 0; i < goats.length; i++) {
tween(goats[i], {
x: car.x - 50 + i * 50,
y: car.y - 50
}, {
duration: 800,
easing: tween.easeOut
});
}
// Fly car across screen
tween(car, {
x: 2048 + 200
}, {
duration: 3000,
easing: tween.easeOut
});
LK.setTimeout(function () {
nextScene();
}, 3500);
break;
case 8:
// Meet Nice Dan and celebrate
sceneText.setText('Hooray! We found Nice Dan! Let\'s celebrate!');
niceDan.visible = true;
// Move goats back to center
for (var i = 0; i < goats.length; i++) {
goats[i].x = 800 + i * 300;
goats[i].y = 1400;
goats[i].visible = true;
tween(goats[i], {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.bounceOut
});
}
LK.getSound('celebration').play();
// Create confetti
for (var i = 0; i < 20; i++) {
var confetti = game.addChild(new Confetti());
confetti.x = Math.random() * 2048;
confetti.y = Math.random() * -500;
confettiParticles.push(confetti);
}
// Create snowflakes
for (var i = 0; i < 15; i++) {
var snow = game.addChild(new Snowflake());
snow.x = Math.random() * 2048;
snow.y = Math.random() * -500;
snowParticles.push(snow);
}
break;
}
}
game.update = function () {
// Update particles in final scene
if (currentScene >= 8) {
for (var i = 0; i < confettiParticles.length; i++) {
confettiParticles[i].update();
}
for (var i = 0; i < snowParticles.length; i++) {
snowParticles[i].update();
}
}
};