/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Scene = Container.expand(function (sceneType) { var self = Container.call(this); self.sceneType = sceneType; self.characters = []; self.props = []; self.createScene = function () { // Clear previous scene self.removeChildren(); self.characters = []; self.props = []; switch (self.sceneType) { case 'porridge': self.createPorridgeScene(); break; case 'courtyard': self.createCourtyardScene(); break; case 'hideseek': self.createHideSeekScene(); break; case 'elftree': self.createElfTreeScene(); break; case 'birds': self.createBirdsScene(); break; case 'tears': self.createTearsScene(); break; case 'return': self.createReturnScene(); break; } self.animateScene(); }; self.createPorridgeScene = function () { var daisy = self.attachAsset('daisy', { x: 200, y: 200, anchorX: 0.5, anchorY: 0.5 }); var poppy = self.attachAsset('poppy', { x: 400, y: 200, anchorX: 0.5, anchorY: 0.5 }); var porridge1 = self.attachAsset('porridge', { x: 250, y: 300, anchorX: 0.5, anchorY: 0.5 }); var porridge2 = self.attachAsset('porridge', { x: 350, y: 300, anchorX: 0.5, anchorY: 0.5 }); self.characters.push(daisy, poppy); self.props.push(porridge1, porridge2); }; self.createCourtyardScene = function () { var courtyard = self.attachAsset('courtyard', { x: 60, y: 60, anchorX: 0, anchorY: 0 }); var daisy = self.attachAsset('daisy', { x: 150, y: 200, anchorX: 0.5, anchorY: 0.5 }); var poppy = self.attachAsset('poppy', { x: 250, y: 200, anchorX: 0.5, anchorY: 0.5 }); var friend1 = self.attachAsset('friend', { x: 350, y: 180, anchorX: 0.5, anchorY: 0.5 }); var friend2 = self.attachAsset('friend', { x: 450, y: 220, anchorX: 0.5, anchorY: 0.5 }); self.props.push(courtyard); self.characters.push(daisy, poppy, friend1, friend2); }; self.createHideSeekScene = function () { var daisy = self.attachAsset('daisy', { x: 500, y: 200, anchorX: 0.5, anchorY: 0.5 }); var poppy = self.attachAsset('poppy', { x: 200, y: 350, anchorX: 0.5, anchorY: 0.5 }); var friend1 = self.attachAsset('friend', { x: 100, y: 150, anchorX: 0.5, anchorY: 0.5 }); // Initially hide poppy (lower alpha) poppy.alpha = 0.3; self.characters.push(daisy, poppy, friend1); }; self.createElfTreeScene = function () { var tree = self.attachAsset('tree', { x: 300, y: 200, anchorX: 0.5, anchorY: 1 }); var leaves = self.attachAsset('treeLeaves', { x: 300, y: 150, anchorX: 0.5, anchorY: 0.5 }); var daisy = self.attachAsset('daisy', { x: 200, y: 350, anchorX: 0.5, anchorY: 0.5 }); var poppy = self.attachAsset('poppy', { x: 400, y: 350, anchorX: 0.5, anchorY: 0.5 }); self.props.push(tree, leaves); self.characters.push(daisy, poppy); }; self.createBirdsScene = function () { var bird1 = self.attachAsset('bird', { x: 200, y: 200, anchorX: 0.5, anchorY: 0.5 }); var bird2 = self.attachAsset('bird', { x: 400, y: 180, anchorX: 0.5, anchorY: 0.5 }); self.characters.push(bird1, bird2); }; self.createTearsScene = function () { var bird1 = self.attachAsset('bird', { x: 200, y: 200, anchorX: 0.5, anchorY: 0.5 }); var bird2 = self.attachAsset('bird', { x: 400, y: 180, anchorX: 0.5, anchorY: 0.5 }); var tear1 = self.attachAsset('tear', { x: 200, y: 250, anchorX: 0.5, anchorY: 0.5 }); var tear2 = self.attachAsset('tear', { x: 400, y: 230, anchorX: 0.5, anchorY: 0.5 }); self.characters.push(bird1, bird2); self.props.push(tear1, tear2); }; self.createReturnScene = function () { var daisy = self.attachAsset('daisy', { x: 200, y: 200, anchorX: 0.5, anchorY: 0.5 }); var poppy = self.attachAsset('poppy', { x: 400, y: 200, anchorX: 0.5, anchorY: 0.5 }); self.characters.push(daisy, poppy); }; self.animateScene = function () { // Animate characters with gentle movements for (var i = 0; i < self.characters.length; i++) { var character = self.characters[i]; var originalY = character.y; tween(character, { y: originalY - 10 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(character, { y: originalY }, { duration: 1000, easing: tween.easeInOut }); } }); } // Special animations for certain scenes if (self.sceneType === 'birds') { for (var i = 0; i < self.characters.length; i++) { var bird = self.characters[i]; var originalX = bird.x; tween(bird, { x: originalX + 50 }, { duration: 2000, easing: tween.easeInOut, onFinish: function onFinish() { tween(bird, { x: originalX }, { duration: 2000, easing: tween.easeInOut }); } }); } } if (self.sceneType === 'tears') { for (var i = 0; i < self.props.length; i++) { var tear = self.props[i]; var originalY = tear.y; tween(tear, { y: originalY + 100 }, { duration: 1500, easing: tween.easeIn }); } } }; return self; }); var Television = Container.expand(function () { var self = Container.call(this); var tvFrame = self.attachAsset('tvFrame', { anchorX: 0.5, anchorY: 0.5 }); var tvScreen = self.attachAsset('tvScreen', { anchorX: 0.5, anchorY: 0.5 }); var playButton = self.attachAsset('playButton', { anchorX: 0.5, anchorY: 0.5 }); var playTriangle = self.attachAsset('playTriangle', { anchorX: 0.5, anchorY: 0.5 }); self.currentScene = null; self.isPlaying = false; self.showPlayButton = function () { playButton.visible = true; playTriangle.visible = true; self.isPlaying = false; }; self.hidePlayButton = function () { playButton.visible = false; playTriangle.visible = false; self.isPlaying = true; }; self.playScene = function (sceneType) { if (self.currentScene) { self.removeChild(self.currentScene); } self.currentScene = new Scene(sceneType); self.currentScene.createScene(); // Position scene within TV screen self.currentScene.x = -tvScreen.width / 2; self.currentScene.y = -tvScreen.height / 2; self.currentScene.scaleX = 0.8; self.currentScene.scaleY = 0.8; self.addChild(self.currentScene); self.hidePlayButton(); }; self.down = function (x, y, obj) { if (!self.isPlaying && playButton.visible) { LK.getSound('click').play(); startMovie(); } else if (self.isPlaying) { LK.getSound('click').play(); nextScene(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x4A4A4A }); /**** * Game Code ****/ // Sounds // Scene elements // Daisy and Poppy characters // Powerpuff Girls // TV and screen elements // Hotel room background // Game state var currentSceneIndex = 0; var scenes = ['porridge', 'courtyard', 'hideseek', 'elftree', 'birds', 'tears', 'return']; var movieStarted = false; // Create hotel room var hotelWall = game.attachAsset('hotelWall', { x: 0, y: 0, anchorX: 0, anchorY: 0 }); var hotelFloor = game.attachAsset('hotelFloor', { x: 0, y: 2332, anchorX: 0, anchorY: 0 }); // Create Powerpuff Girls var blossom = game.attachAsset('blossom', { x: 300, y: 2400, anchorX: 0.5, anchorY: 0.5 }); var bubbles = game.attachAsset('bubbles', { x: 500, y: 2450, anchorX: 0.5, anchorY: 0.5 }); var buttercup = game.attachAsset('buttercup', { x: 700, y: 2400, anchorX: 0.5, anchorY: 0.5 }); // Create TV var television = game.addChild(new Television()); television.x = 1024; television.y = 800; // Create title text var titleText = new Text2('Daisy and Poppy: The Magic TV Movie', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 200; game.addChild(titleText); // Create instruction text var instructionText = new Text2('Tap the TV to watch the magical story!', { size: 60, fill: 0xFFFF00 }); instructionText.anchor.set(0.5, 0); instructionText.x = 1024; instructionText.y = 1200; game.addChild(instructionText); // Show initial play button television.showPlayButton(); function startMovie() { movieStarted = true; currentSceneIndex = 0; instructionText.setText('Tap to continue the story!'); playCurrentScene(); } function nextScene() { if (!movieStarted) return; currentSceneIndex++; if (currentSceneIndex >= scenes.length) { // Movie finished endMovie(); return; } playCurrentScene(); } function playCurrentScene() { if (currentSceneIndex < scenes.length) { television.playScene(scenes[currentSceneIndex]); LK.getSound('magic').play(); // Update instruction based on scene var sceneNames = ['Making Porridge', 'Playing in Courtyard', 'Hide and Seek', 'The Great Elf Tree', 'Magical Birds', 'Tears of Sadness', 'Back to Normal']; instructionText.setText('Scene ' + (currentSceneIndex + 1) + ': ' + sceneNames[currentSceneIndex]); } } function endMovie() { instructionText.setText('The End! Tap to watch again!'); television.showPlayButton(); movieStarted = false; currentSceneIndex = 0; } // Animate Powerpuff Girls game.update = function () { if (LK.ticks % 180 === 0) { // Gentle floating animation for Powerpuff Girls var girls = [blossom, bubbles, buttercup]; for (var i = 0; i < girls.length; i++) { var girl = girls[i]; var originalY = girl.y; tween(girl, { y: originalY - 20 }, { duration: 2000, easing: tween.easeInOut, onFinish: function onFinish() { tween(girl, { y: originalY }, { duration: 2000, easing: tween.easeInOut }); } }); } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Scene = Container.expand(function (sceneType) {
var self = Container.call(this);
self.sceneType = sceneType;
self.characters = [];
self.props = [];
self.createScene = function () {
// Clear previous scene
self.removeChildren();
self.characters = [];
self.props = [];
switch (self.sceneType) {
case 'porridge':
self.createPorridgeScene();
break;
case 'courtyard':
self.createCourtyardScene();
break;
case 'hideseek':
self.createHideSeekScene();
break;
case 'elftree':
self.createElfTreeScene();
break;
case 'birds':
self.createBirdsScene();
break;
case 'tears':
self.createTearsScene();
break;
case 'return':
self.createReturnScene();
break;
}
self.animateScene();
};
self.createPorridgeScene = function () {
var daisy = self.attachAsset('daisy', {
x: 200,
y: 200,
anchorX: 0.5,
anchorY: 0.5
});
var poppy = self.attachAsset('poppy', {
x: 400,
y: 200,
anchorX: 0.5,
anchorY: 0.5
});
var porridge1 = self.attachAsset('porridge', {
x: 250,
y: 300,
anchorX: 0.5,
anchorY: 0.5
});
var porridge2 = self.attachAsset('porridge', {
x: 350,
y: 300,
anchorX: 0.5,
anchorY: 0.5
});
self.characters.push(daisy, poppy);
self.props.push(porridge1, porridge2);
};
self.createCourtyardScene = function () {
var courtyard = self.attachAsset('courtyard', {
x: 60,
y: 60,
anchorX: 0,
anchorY: 0
});
var daisy = self.attachAsset('daisy', {
x: 150,
y: 200,
anchorX: 0.5,
anchorY: 0.5
});
var poppy = self.attachAsset('poppy', {
x: 250,
y: 200,
anchorX: 0.5,
anchorY: 0.5
});
var friend1 = self.attachAsset('friend', {
x: 350,
y: 180,
anchorX: 0.5,
anchorY: 0.5
});
var friend2 = self.attachAsset('friend', {
x: 450,
y: 220,
anchorX: 0.5,
anchorY: 0.5
});
self.props.push(courtyard);
self.characters.push(daisy, poppy, friend1, friend2);
};
self.createHideSeekScene = function () {
var daisy = self.attachAsset('daisy', {
x: 500,
y: 200,
anchorX: 0.5,
anchorY: 0.5
});
var poppy = self.attachAsset('poppy', {
x: 200,
y: 350,
anchorX: 0.5,
anchorY: 0.5
});
var friend1 = self.attachAsset('friend', {
x: 100,
y: 150,
anchorX: 0.5,
anchorY: 0.5
});
// Initially hide poppy (lower alpha)
poppy.alpha = 0.3;
self.characters.push(daisy, poppy, friend1);
};
self.createElfTreeScene = function () {
var tree = self.attachAsset('tree', {
x: 300,
y: 200,
anchorX: 0.5,
anchorY: 1
});
var leaves = self.attachAsset('treeLeaves', {
x: 300,
y: 150,
anchorX: 0.5,
anchorY: 0.5
});
var daisy = self.attachAsset('daisy', {
x: 200,
y: 350,
anchorX: 0.5,
anchorY: 0.5
});
var poppy = self.attachAsset('poppy', {
x: 400,
y: 350,
anchorX: 0.5,
anchorY: 0.5
});
self.props.push(tree, leaves);
self.characters.push(daisy, poppy);
};
self.createBirdsScene = function () {
var bird1 = self.attachAsset('bird', {
x: 200,
y: 200,
anchorX: 0.5,
anchorY: 0.5
});
var bird2 = self.attachAsset('bird', {
x: 400,
y: 180,
anchorX: 0.5,
anchorY: 0.5
});
self.characters.push(bird1, bird2);
};
self.createTearsScene = function () {
var bird1 = self.attachAsset('bird', {
x: 200,
y: 200,
anchorX: 0.5,
anchorY: 0.5
});
var bird2 = self.attachAsset('bird', {
x: 400,
y: 180,
anchorX: 0.5,
anchorY: 0.5
});
var tear1 = self.attachAsset('tear', {
x: 200,
y: 250,
anchorX: 0.5,
anchorY: 0.5
});
var tear2 = self.attachAsset('tear', {
x: 400,
y: 230,
anchorX: 0.5,
anchorY: 0.5
});
self.characters.push(bird1, bird2);
self.props.push(tear1, tear2);
};
self.createReturnScene = function () {
var daisy = self.attachAsset('daisy', {
x: 200,
y: 200,
anchorX: 0.5,
anchorY: 0.5
});
var poppy = self.attachAsset('poppy', {
x: 400,
y: 200,
anchorX: 0.5,
anchorY: 0.5
});
self.characters.push(daisy, poppy);
};
self.animateScene = function () {
// Animate characters with gentle movements
for (var i = 0; i < self.characters.length; i++) {
var character = self.characters[i];
var originalY = character.y;
tween(character, {
y: originalY - 10
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(character, {
y: originalY
}, {
duration: 1000,
easing: tween.easeInOut
});
}
});
}
// Special animations for certain scenes
if (self.sceneType === 'birds') {
for (var i = 0; i < self.characters.length; i++) {
var bird = self.characters[i];
var originalX = bird.x;
tween(bird, {
x: originalX + 50
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bird, {
x: originalX
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
}
}
if (self.sceneType === 'tears') {
for (var i = 0; i < self.props.length; i++) {
var tear = self.props[i];
var originalY = tear.y;
tween(tear, {
y: originalY + 100
}, {
duration: 1500,
easing: tween.easeIn
});
}
}
};
return self;
});
var Television = Container.expand(function () {
var self = Container.call(this);
var tvFrame = self.attachAsset('tvFrame', {
anchorX: 0.5,
anchorY: 0.5
});
var tvScreen = self.attachAsset('tvScreen', {
anchorX: 0.5,
anchorY: 0.5
});
var playButton = self.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5
});
var playTriangle = self.attachAsset('playTriangle', {
anchorX: 0.5,
anchorY: 0.5
});
self.currentScene = null;
self.isPlaying = false;
self.showPlayButton = function () {
playButton.visible = true;
playTriangle.visible = true;
self.isPlaying = false;
};
self.hidePlayButton = function () {
playButton.visible = false;
playTriangle.visible = false;
self.isPlaying = true;
};
self.playScene = function (sceneType) {
if (self.currentScene) {
self.removeChild(self.currentScene);
}
self.currentScene = new Scene(sceneType);
self.currentScene.createScene();
// Position scene within TV screen
self.currentScene.x = -tvScreen.width / 2;
self.currentScene.y = -tvScreen.height / 2;
self.currentScene.scaleX = 0.8;
self.currentScene.scaleY = 0.8;
self.addChild(self.currentScene);
self.hidePlayButton();
};
self.down = function (x, y, obj) {
if (!self.isPlaying && playButton.visible) {
LK.getSound('click').play();
startMovie();
} else if (self.isPlaying) {
LK.getSound('click').play();
nextScene();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x4A4A4A
});
/****
* Game Code
****/
// Sounds
// Scene elements
// Daisy and Poppy characters
// Powerpuff Girls
// TV and screen elements
// Hotel room background
// Game state
var currentSceneIndex = 0;
var scenes = ['porridge', 'courtyard', 'hideseek', 'elftree', 'birds', 'tears', 'return'];
var movieStarted = false;
// Create hotel room
var hotelWall = game.attachAsset('hotelWall', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0
});
var hotelFloor = game.attachAsset('hotelFloor', {
x: 0,
y: 2332,
anchorX: 0,
anchorY: 0
});
// Create Powerpuff Girls
var blossom = game.attachAsset('blossom', {
x: 300,
y: 2400,
anchorX: 0.5,
anchorY: 0.5
});
var bubbles = game.attachAsset('bubbles', {
x: 500,
y: 2450,
anchorX: 0.5,
anchorY: 0.5
});
var buttercup = game.attachAsset('buttercup', {
x: 700,
y: 2400,
anchorX: 0.5,
anchorY: 0.5
});
// Create TV
var television = game.addChild(new Television());
television.x = 1024;
television.y = 800;
// Create title text
var titleText = new Text2('Daisy and Poppy: The Magic TV Movie', {
size: 80,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 200;
game.addChild(titleText);
// Create instruction text
var instructionText = new Text2('Tap the TV to watch the magical story!', {
size: 60,
fill: 0xFFFF00
});
instructionText.anchor.set(0.5, 0);
instructionText.x = 1024;
instructionText.y = 1200;
game.addChild(instructionText);
// Show initial play button
television.showPlayButton();
function startMovie() {
movieStarted = true;
currentSceneIndex = 0;
instructionText.setText('Tap to continue the story!');
playCurrentScene();
}
function nextScene() {
if (!movieStarted) return;
currentSceneIndex++;
if (currentSceneIndex >= scenes.length) {
// Movie finished
endMovie();
return;
}
playCurrentScene();
}
function playCurrentScene() {
if (currentSceneIndex < scenes.length) {
television.playScene(scenes[currentSceneIndex]);
LK.getSound('magic').play();
// Update instruction based on scene
var sceneNames = ['Making Porridge', 'Playing in Courtyard', 'Hide and Seek', 'The Great Elf Tree', 'Magical Birds', 'Tears of Sadness', 'Back to Normal'];
instructionText.setText('Scene ' + (currentSceneIndex + 1) + ': ' + sceneNames[currentSceneIndex]);
}
}
function endMovie() {
instructionText.setText('The End! Tap to watch again!');
television.showPlayButton();
movieStarted = false;
currentSceneIndex = 0;
}
// Animate Powerpuff Girls
game.update = function () {
if (LK.ticks % 180 === 0) {
// Gentle floating animation for Powerpuff Girls
var girls = [blossom, bubbles, buttercup];
for (var i = 0; i < girls.length; i++) {
var girl = girls[i];
var originalY = girl.y;
tween(girl, {
y: originalY - 20
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(girl, {
y: originalY
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
}
}
};