Code edit (1 edits merged)
Please save this source code
User prompt
Powerpuff Girls Christmas TV Theater
Initial prompt
Toca television 2 (2016). The powerpuff girls have a tv to watch. Tap on the play button to make the tv come to life. It will be a story movie about “Christmas shorts”. They be a candle 🕯️ going down while yeti sings deck the halls scene at scene 1 snow-man snowboarding scene at scene 2 snow globe with a penguin turning scene at scene 3 rabbit 🤍 making a snow angel scene at scene 3 sula shivering at snow falling from black hole scene at scene 4 squirrel 💛dancing scene at scene 5 glove turns into deer head turns into snow-man head turns into nutcracker head scene at scene 6 for end
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var TVInterface = Container.expand(function () { var self = Container.call(this); // TV Frame var tvFrame = self.attachAsset('tvFrame', { anchorX: 0.5, anchorY: 0.5 }); // TV Screen var tvScreen = self.attachAsset('tvScreen', { anchorX: 0.5, anchorY: 0.5 }); // Play Button var playButton = self.attachAsset('playButton', { anchorX: 0.5, anchorY: 0.5 }); var playTriangle = self.attachAsset('playTriangle', { anchorX: 0.5, anchorY: 0.5 }); self.isPlaying = false; self.down = function (x, y, obj) { if (!self.isPlaying) { self.startShow(); } }; self.startShow = function () { self.isPlaying = true; playButton.visible = false; playTriangle.visible = false; LK.getSound('click').play(); // Start the Christmas show currentScene = 1; self.showScene(currentScene); }; self.showScene = function (sceneNumber) { // Clear current scene self.clearScene(); switch (sceneNumber) { case 1: self.createScene1(); break; case 2: self.createScene2(); break; case 3: self.createScene3(); break; case 4: self.createScene4(); break; case 5: self.createScene5(); break; case 6: self.createScene6(); break; default: self.resetToStart(); break; } }; self.clearScene = function () { // Remove all scene elements for (var i = self.children.length - 1; i >= 0; i--) { var child = self.children[i]; if (child !== tvFrame && child !== tvScreen && child !== playButton && child !== playTriangle) { self.removeChild(child); } } }; self.createScene1 = function () { // Candle countdown with yeti singing var candle = self.attachAsset('candle', { anchorX: 0.5, anchorY: 1, x: -200, y: 100 }); var flame = self.attachAsset('candleFlame', { anchorX: 0.5, anchorY: 1, x: -200, y: -100 }); var yeti = self.attachAsset('yeti', { anchorX: 0.5, anchorY: 0.5, x: 200, y: 0 }); var yetiEye1 = self.attachAsset('yetiEyes', { anchorX: 0.5, anchorY: 0.5, x: 170, y: -50 }); var yetiEye2 = self.attachAsset('yetiEyes', { anchorX: 0.5, anchorY: 0.5, x: 230, y: -50 }); // Animate candle burning down tween(candle, { scaleY: 0.3 }, { duration: 3000 }); tween(flame, { alpha: 0.5 }, { duration: 3000 }); // Animate yeti singing tween(yeti, { scaleX: 1.1, scaleY: 1.1 }, { duration: 500, easing: tween.easeInOut }); tween(yeti, { scaleX: 1.0, scaleY: 1.0 }, { duration: 500, easing: tween.easeInOut }); LK.setTimeout(function () { currentScene++; self.showScene(currentScene); }, 4000); }; self.createScene2 = function () { // Snowman snowboarding var snowmanBody = self.attachAsset('snowmanBody', { anchorX: 0.5, anchorY: 0.5, x: -300, y: 100 }); var snowmanHead = self.attachAsset('snowmanHead', { anchorX: 0.5, anchorY: 0.5, x: -300, y: -50 }); var carrot = self.attachAsset('carrot', { anchorX: 0.5, anchorY: 0.5, x: -280, y: -50 }); // Animate snowman snowboarding tween(snowmanBody, { x: 300, y: 200 }, { duration: 3000, easing: tween.easeIn }); tween(snowmanHead, { x: 300, y: 50 }, { duration: 3000, easing: tween.easeIn }); tween(carrot, { x: 320, y: 50 }, { duration: 3000, easing: tween.easeIn }); LK.setTimeout(function () { currentScene++; self.showScene(currentScene); }, 4000); }; self.createScene3 = function () { // Snow globe with spinning penguin and rabbit var snowGlobe = self.attachAsset('snowGlobe', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, alpha: 0.3 }); var penguin = self.attachAsset('penguin', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); var penguinBelly = self.attachAsset('penguinBelly', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 10 }); var rabbit = self.attachAsset('rabbit', { anchorX: 0.5, anchorY: 0.5, x: -150, y: 100 }); var rabbitEar1 = self.attachAsset('rabbitEars', { anchorX: 0.5, anchorY: 1, x: -170, y: 0 }); var rabbitEar2 = self.attachAsset('rabbitEars', { anchorX: 0.5, anchorY: 1, x: -130, y: 0 }); // Animate spinning penguin tween(penguin, { rotation: Math.PI * 4 }, { duration: 3000, easing: tween.linear }); tween(penguinBelly, { rotation: Math.PI * 4 }, { duration: 3000, easing: tween.linear }); // Animate rabbit making snow angels tween(rabbit, { rotation: Math.PI * 0.5 }, { duration: 1000, easing: tween.easeInOut }); tween(rabbit, { rotation: -Math.PI * 0.5 }, { duration: 1000, easing: tween.easeInOut }); LK.setTimeout(function () { currentScene++; self.showScene(currentScene); }, 4000); }; self.createScene4 = function () { // Sula shivering in snowfall var sula = self.attachAsset('sula', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 50 }); // Create snowflakes for (var i = 0; i < 20; i++) { var snowflake = self.attachAsset('snowflake', { anchorX: 0.5, anchorY: 0.5, x: Math.random() * 800 - 400, y: -300 - Math.random() * 200 }); tween(snowflake, { y: 400 }, { duration: 2000 + Math.random() * 2000, easing: tween.linear }); } // Animate Sula shivering var shiver = function shiver() { tween(sula, { x: 10 }, { duration: 100, easing: tween.linear }); tween(sula, { x: -10 }, { duration: 100, easing: tween.linear }); tween(sula, { x: 0 }, { duration: 100, easing: tween.linear }); }; shiver(); LK.setTimeout(shiver, 300); LK.setTimeout(shiver, 600); LK.setTimeout(shiver, 900); LK.setTimeout(function () { currentScene++; self.showScene(currentScene); }, 4000); }; self.createScene5 = function () { // Dancing squirrel var squirrel = self.attachAsset('squirrel', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); var squirrelTail = self.attachAsset('squirrelTail', { anchorX: 0.5, anchorY: 0.5, x: -50, y: -50 }); // Animate dancing squirrel tween(squirrel, { scaleX: 1.2, scaleY: 1.2 }, { duration: 300, easing: tween.easeInOut }); tween(squirrel, { scaleX: 1.0, scaleY: 1.0 }, { duration: 300, easing: tween.easeInOut }); tween(squirrelTail, { rotation: Math.PI * 0.3 }, { duration: 200, easing: tween.easeInOut }); tween(squirrelTail, { rotation: -Math.PI * 0.3 }, { duration: 200, easing: tween.easeInOut }); tween(squirrelTail, { rotation: 0 }, { duration: 200, easing: tween.easeInOut }); LK.setTimeout(function () { currentScene++; self.showScene(currentScene); }, 4000); }; self.createScene6 = function () { // Morphing sequence var morphObject = self.attachAsset('glove', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); LK.setTimeout(function () { self.removeChild(morphObject); morphObject = self.attachAsset('deerHead', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, alpha: 0 }); var antler1 = self.attachAsset('deerAntler', { anchorX: 0.5, anchorY: 1, x: -60, y: -100, alpha: 0 }); var antler2 = self.attachAsset('deerAntler', { anchorX: 0.5, anchorY: 1, x: 60, y: -100, alpha: 0 }); tween(morphObject, { alpha: 1 }, { duration: 500 }); tween(antler1, { alpha: 1 }, { duration: 500 }); tween(antler2, { alpha: 1 }, { duration: 500 }); LK.getSound('magic').play(); }, 1000); LK.setTimeout(function () { self.clearScene(); morphObject = self.attachAsset('snowmanHead', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, alpha: 0 }); var carrot = self.attachAsset('carrot', { anchorX: 0.5, anchorY: 0.5, x: 20, y: 0, alpha: 0 }); tween(morphObject, { alpha: 1 }, { duration: 500 }); tween(carrot, { alpha: 1 }, { duration: 500 }); LK.getSound('magic').play(); }, 2000); LK.setTimeout(function () { self.clearScene(); morphObject = self.attachAsset('nutcracker', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, alpha: 0 }); var nutcrackerHat = self.attachAsset('nutcrackerHat', { anchorX: 0.5, anchorY: 1, x: 0, y: -150, alpha: 0 }); tween(morphObject, { alpha: 1 }, { duration: 500 }); tween(nutcrackerHat, { alpha: 1 }, { duration: 500 }); LK.getSound('magic').play(); }, 3000); LK.setTimeout(function () { self.resetToStart(); }, 5000); }; self.resetToStart = function () { self.clearScene(); self.isPlaying = false; playButton.visible = true; playTriangle.visible = true; currentScene = 0; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x001122 }); /**** * Game Code ****/ // Scene elements // Powerpuff Girls characters var currentScene = 0; // Create TV interface var tv = game.addChild(new TVInterface()); tv.x = 2048 / 2; tv.y = 2732 / 2; // Create Powerpuff Girls characters around the TV var blossom = game.addChild(LK.getAsset('blossom', { anchorX: 0.5, anchorY: 0.5 })); blossom.x = 2048 / 2 - 600; blossom.y = 2732 / 2; var bubbles = game.addChild(LK.getAsset('bubbles', { anchorX: 0.5, anchorY: 0.5 })); bubbles.x = 2048 / 2 + 600; bubbles.y = 2732 / 2; var buttercup = game.addChild(LK.getAsset('buttercup', { anchorX: 0.5, anchorY: 0.5 })); buttercup.x = 2048 / 2; buttercup.y = 2732 / 2 + 400; // Add title text var titleText = new Text2('Powerpuff Girls Christmas TV Theater', { size: 120, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); LK.gui.top.addChild(titleText); titleText.y = 100; // Play Christmas music LK.playMusic('christmas'); // Simple floating animation for the girls game.update = function () { if (LK.ticks % 120 === 0) { tween(blossom, { y: blossom.y - 20 }, { duration: 1000, easing: tween.easeInOut }); tween(blossom, { y: blossom.y + 20 }, { duration: 1000, easing: tween.easeInOut }); } if (LK.ticks % 140 === 0) { tween(bubbles, { y: bubbles.y - 15 }, { duration: 1200, easing: tween.easeInOut }); tween(bubbles, { y: bubbles.y + 15 }, { duration: 1200, easing: tween.easeInOut }); } if (LK.ticks % 160 === 0) { tween(buttercup, { y: buttercup.y - 25 }, { duration: 800, easing: tween.easeInOut }); tween(buttercup, { y: buttercup.y + 25 }, { duration: 800, easing: tween.easeInOut }); } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var TVInterface = Container.expand(function () {
var self = Container.call(this);
// TV Frame
var tvFrame = self.attachAsset('tvFrame', {
anchorX: 0.5,
anchorY: 0.5
});
// TV Screen
var tvScreen = self.attachAsset('tvScreen', {
anchorX: 0.5,
anchorY: 0.5
});
// Play Button
var playButton = self.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5
});
var playTriangle = self.attachAsset('playTriangle', {
anchorX: 0.5,
anchorY: 0.5
});
self.isPlaying = false;
self.down = function (x, y, obj) {
if (!self.isPlaying) {
self.startShow();
}
};
self.startShow = function () {
self.isPlaying = true;
playButton.visible = false;
playTriangle.visible = false;
LK.getSound('click').play();
// Start the Christmas show
currentScene = 1;
self.showScene(currentScene);
};
self.showScene = function (sceneNumber) {
// Clear current scene
self.clearScene();
switch (sceneNumber) {
case 1:
self.createScene1();
break;
case 2:
self.createScene2();
break;
case 3:
self.createScene3();
break;
case 4:
self.createScene4();
break;
case 5:
self.createScene5();
break;
case 6:
self.createScene6();
break;
default:
self.resetToStart();
break;
}
};
self.clearScene = function () {
// Remove all scene elements
for (var i = self.children.length - 1; i >= 0; i--) {
var child = self.children[i];
if (child !== tvFrame && child !== tvScreen && child !== playButton && child !== playTriangle) {
self.removeChild(child);
}
}
};
self.createScene1 = function () {
// Candle countdown with yeti singing
var candle = self.attachAsset('candle', {
anchorX: 0.5,
anchorY: 1,
x: -200,
y: 100
});
var flame = self.attachAsset('candleFlame', {
anchorX: 0.5,
anchorY: 1,
x: -200,
y: -100
});
var yeti = self.attachAsset('yeti', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: 0
});
var yetiEye1 = self.attachAsset('yetiEyes', {
anchorX: 0.5,
anchorY: 0.5,
x: 170,
y: -50
});
var yetiEye2 = self.attachAsset('yetiEyes', {
anchorX: 0.5,
anchorY: 0.5,
x: 230,
y: -50
});
// Animate candle burning down
tween(candle, {
scaleY: 0.3
}, {
duration: 3000
});
tween(flame, {
alpha: 0.5
}, {
duration: 3000
});
// Animate yeti singing
tween(yeti, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 500,
easing: tween.easeInOut
});
tween(yeti, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 500,
easing: tween.easeInOut
});
LK.setTimeout(function () {
currentScene++;
self.showScene(currentScene);
}, 4000);
};
self.createScene2 = function () {
// Snowman snowboarding
var snowmanBody = self.attachAsset('snowmanBody', {
anchorX: 0.5,
anchorY: 0.5,
x: -300,
y: 100
});
var snowmanHead = self.attachAsset('snowmanHead', {
anchorX: 0.5,
anchorY: 0.5,
x: -300,
y: -50
});
var carrot = self.attachAsset('carrot', {
anchorX: 0.5,
anchorY: 0.5,
x: -280,
y: -50
});
// Animate snowman snowboarding
tween(snowmanBody, {
x: 300,
y: 200
}, {
duration: 3000,
easing: tween.easeIn
});
tween(snowmanHead, {
x: 300,
y: 50
}, {
duration: 3000,
easing: tween.easeIn
});
tween(carrot, {
x: 320,
y: 50
}, {
duration: 3000,
easing: tween.easeIn
});
LK.setTimeout(function () {
currentScene++;
self.showScene(currentScene);
}, 4000);
};
self.createScene3 = function () {
// Snow globe with spinning penguin and rabbit
var snowGlobe = self.attachAsset('snowGlobe', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
alpha: 0.3
});
var penguin = self.attachAsset('penguin', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
});
var penguinBelly = self.attachAsset('penguinBelly', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 10
});
var rabbit = self.attachAsset('rabbit', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: 100
});
var rabbitEar1 = self.attachAsset('rabbitEars', {
anchorX: 0.5,
anchorY: 1,
x: -170,
y: 0
});
var rabbitEar2 = self.attachAsset('rabbitEars', {
anchorX: 0.5,
anchorY: 1,
x: -130,
y: 0
});
// Animate spinning penguin
tween(penguin, {
rotation: Math.PI * 4
}, {
duration: 3000,
easing: tween.linear
});
tween(penguinBelly, {
rotation: Math.PI * 4
}, {
duration: 3000,
easing: tween.linear
});
// Animate rabbit making snow angels
tween(rabbit, {
rotation: Math.PI * 0.5
}, {
duration: 1000,
easing: tween.easeInOut
});
tween(rabbit, {
rotation: -Math.PI * 0.5
}, {
duration: 1000,
easing: tween.easeInOut
});
LK.setTimeout(function () {
currentScene++;
self.showScene(currentScene);
}, 4000);
};
self.createScene4 = function () {
// Sula shivering in snowfall
var sula = self.attachAsset('sula', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 50
});
// Create snowflakes
for (var i = 0; i < 20; i++) {
var snowflake = self.attachAsset('snowflake', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 800 - 400,
y: -300 - Math.random() * 200
});
tween(snowflake, {
y: 400
}, {
duration: 2000 + Math.random() * 2000,
easing: tween.linear
});
}
// Animate Sula shivering
var shiver = function shiver() {
tween(sula, {
x: 10
}, {
duration: 100,
easing: tween.linear
});
tween(sula, {
x: -10
}, {
duration: 100,
easing: tween.linear
});
tween(sula, {
x: 0
}, {
duration: 100,
easing: tween.linear
});
};
shiver();
LK.setTimeout(shiver, 300);
LK.setTimeout(shiver, 600);
LK.setTimeout(shiver, 900);
LK.setTimeout(function () {
currentScene++;
self.showScene(currentScene);
}, 4000);
};
self.createScene5 = function () {
// Dancing squirrel
var squirrel = self.attachAsset('squirrel', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
});
var squirrelTail = self.attachAsset('squirrelTail', {
anchorX: 0.5,
anchorY: 0.5,
x: -50,
y: -50
});
// Animate dancing squirrel
tween(squirrel, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.easeInOut
});
tween(squirrel, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 300,
easing: tween.easeInOut
});
tween(squirrelTail, {
rotation: Math.PI * 0.3
}, {
duration: 200,
easing: tween.easeInOut
});
tween(squirrelTail, {
rotation: -Math.PI * 0.3
}, {
duration: 200,
easing: tween.easeInOut
});
tween(squirrelTail, {
rotation: 0
}, {
duration: 200,
easing: tween.easeInOut
});
LK.setTimeout(function () {
currentScene++;
self.showScene(currentScene);
}, 4000);
};
self.createScene6 = function () {
// Morphing sequence
var morphObject = self.attachAsset('glove', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
});
LK.setTimeout(function () {
self.removeChild(morphObject);
morphObject = self.attachAsset('deerHead', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
alpha: 0
});
var antler1 = self.attachAsset('deerAntler', {
anchorX: 0.5,
anchorY: 1,
x: -60,
y: -100,
alpha: 0
});
var antler2 = self.attachAsset('deerAntler', {
anchorX: 0.5,
anchorY: 1,
x: 60,
y: -100,
alpha: 0
});
tween(morphObject, {
alpha: 1
}, {
duration: 500
});
tween(antler1, {
alpha: 1
}, {
duration: 500
});
tween(antler2, {
alpha: 1
}, {
duration: 500
});
LK.getSound('magic').play();
}, 1000);
LK.setTimeout(function () {
self.clearScene();
morphObject = self.attachAsset('snowmanHead', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
alpha: 0
});
var carrot = self.attachAsset('carrot', {
anchorX: 0.5,
anchorY: 0.5,
x: 20,
y: 0,
alpha: 0
});
tween(morphObject, {
alpha: 1
}, {
duration: 500
});
tween(carrot, {
alpha: 1
}, {
duration: 500
});
LK.getSound('magic').play();
}, 2000);
LK.setTimeout(function () {
self.clearScene();
morphObject = self.attachAsset('nutcracker', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
alpha: 0
});
var nutcrackerHat = self.attachAsset('nutcrackerHat', {
anchorX: 0.5,
anchorY: 1,
x: 0,
y: -150,
alpha: 0
});
tween(morphObject, {
alpha: 1
}, {
duration: 500
});
tween(nutcrackerHat, {
alpha: 1
}, {
duration: 500
});
LK.getSound('magic').play();
}, 3000);
LK.setTimeout(function () {
self.resetToStart();
}, 5000);
};
self.resetToStart = function () {
self.clearScene();
self.isPlaying = false;
playButton.visible = true;
playTriangle.visible = true;
currentScene = 0;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001122
});
/****
* Game Code
****/
// Scene elements
// Powerpuff Girls characters
var currentScene = 0;
// Create TV interface
var tv = game.addChild(new TVInterface());
tv.x = 2048 / 2;
tv.y = 2732 / 2;
// Create Powerpuff Girls characters around the TV
var blossom = game.addChild(LK.getAsset('blossom', {
anchorX: 0.5,
anchorY: 0.5
}));
blossom.x = 2048 / 2 - 600;
blossom.y = 2732 / 2;
var bubbles = game.addChild(LK.getAsset('bubbles', {
anchorX: 0.5,
anchorY: 0.5
}));
bubbles.x = 2048 / 2 + 600;
bubbles.y = 2732 / 2;
var buttercup = game.addChild(LK.getAsset('buttercup', {
anchorX: 0.5,
anchorY: 0.5
}));
buttercup.x = 2048 / 2;
buttercup.y = 2732 / 2 + 400;
// Add title text
var titleText = new Text2('Powerpuff Girls Christmas TV Theater', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
LK.gui.top.addChild(titleText);
titleText.y = 100;
// Play Christmas music
LK.playMusic('christmas');
// Simple floating animation for the girls
game.update = function () {
if (LK.ticks % 120 === 0) {
tween(blossom, {
y: blossom.y - 20
}, {
duration: 1000,
easing: tween.easeInOut
});
tween(blossom, {
y: blossom.y + 20
}, {
duration: 1000,
easing: tween.easeInOut
});
}
if (LK.ticks % 140 === 0) {
tween(bubbles, {
y: bubbles.y - 15
}, {
duration: 1200,
easing: tween.easeInOut
});
tween(bubbles, {
y: bubbles.y + 15
}, {
duration: 1200,
easing: tween.easeInOut
});
}
if (LK.ticks % 160 === 0) {
tween(buttercup, {
y: buttercup.y - 25
}, {
duration: 800,
easing: tween.easeInOut
});
tween(buttercup, {
y: buttercup.y + 25
}, {
duration: 800,
easing: tween.easeInOut
});
}
};