Code edit (1 edits merged)
Please save this source code
User prompt
Jungle Me 2: Movie Magic
Initial prompt
Toca movie 2 (2013-2015). The powerpuff girls have a new tv to watch. Tap on the play button to make your tv come alive, it will be jungle me 2 movie on the tv. It will be Bella’s 3rd birthday scene at beginning 🐷 finny 🐬 goes away scene at scene 2 Bella 🐷 screams at Ella purple evil onion 👿 at scene 3 avoid the purple evil onions scene at scene 4 👿 lady’s wedding scene 🐞 at scene 5 for the end.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Scene = Container.expand(function (sceneNumber) {
var self = Container.call(this);
self.sceneNumber = sceneNumber;
self.isActive = false;
self.elements = [];
self.play = function () {
self.isActive = true;
self.setupScene();
};
self.pause = function () {
self.isActive = false;
// Stop all tweens for this scene
for (var i = 0; i < self.elements.length; i++) {
tween.stop(self.elements[i]);
}
};
self.setupScene = function () {
// Override in specific scenes
};
self.nextScene = function () {
if (currentSceneIndex < scenes.length - 1) {
currentSceneIndex++;
currentScene = scenes[currentSceneIndex];
tvScreen.showPlay();
LK.getSound('sceneTransition').play();
self.clearScene();
}
};
self.clearScene = function () {
for (var i = 0; i < self.elements.length; i++) {
if (self.elements[i].parent) {
self.elements[i].parent.removeChild(self.elements[i]);
}
}
self.elements = [];
};
return self;
});
var WeddingScene = Scene.expand(function () {
var self = Scene.call(this, 5);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 800,
y: 1500
}));
self.elements.push(bella);
// Finny character (returned)
var finny = game.addChild(LK.getAsset('finny', {
anchorX: 0.5,
anchorY: 0.5,
x: 1300,
y: 1500
}));
self.elements.push(finny);
// Wedding decoration
var wedding = game.addChild(LK.getAsset('wedding', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1200
}));
self.elements.push(wedding);
// Celebration hearts
for (var i = 0; i < 10; i++) {
var heart = game.addChild(LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5,
x: 500 + Math.random() * 1000,
y: 1800,
alpha: 0.8
}));
self.elements.push(heart);
// Hearts float up
tween(heart, {
y: 800,
alpha: 0
}, {
duration: 3000 + Math.random() * 2000,
easing: tween.easeOut
});
}
// Characters come together
tween(bella, {
x: 950
}, {
duration: 2000,
easing: tween.easeInOut
});
tween(finny, {
x: 1100
}, {
duration: 2000,
easing: tween.easeInOut
});
LK.getSound('celebration').play();
// Show completion message
LK.setTimeout(function () {
LK.showYouWin();
}, 5000);
};
return self;
});
var DepartureScene = Scene.expand(function () {
var self = Scene.call(this, 2);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 800,
y: 1400
}));
self.elements.push(bella);
// Finny character
var finny = game.addChild(LK.getAsset('finny', {
anchorX: 0.5,
anchorY: 0.5,
x: 1300,
y: 1400
}));
self.elements.push(finny);
// Hearts floating around
for (var i = 0; i < 5; i++) {
var heart = game.addChild(LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5,
x: 900 + Math.random() * 200,
y: 1200 + Math.random() * 100,
alpha: 0.7
}));
self.elements.push(heart);
// Animate hearts
tween(heart, {
y: heart.y - 100,
alpha: 0
}, {
duration: 3000,
easing: tween.easeOut
});
}
// Finny moves away
tween(finny, {
x: 2200
}, {
duration: 3000,
easing: tween.easeIn,
onFinish: function onFinish() {
self.nextScene();
}
});
// Bella waves
tween(bella, {
rotation: 0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
rotation: -0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
rotation: 0
}, {
duration: 500,
easing: tween.easeInOut
});
}
});
}
});
};
return self;
});
var ConfrontationScene = Scene.expand(function () {
var self = Scene.call(this, 3);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 700,
y: 1400
}));
self.elements.push(bella);
// Purple evil onion
var purpleOnion = game.addChild(LK.getAsset('purpleOnion', {
anchorX: 0.5,
anchorY: 0.5,
x: 1400,
y: 1400
}));
self.elements.push(purpleOnion);
// Bella screams animation
tween(bella, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(bella, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeIn
});
}
});
// Onion villain animation
tween(purpleOnion, {
rotation: 0.5
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(purpleOnion, {
rotation: -0.5
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(purpleOnion, {
rotation: 0
}, {
duration: 300,
easing: tween.easeInOut
});
}
});
}
});
// Flash screen red briefly
LK.effects.flashScreen(0xff0000, 500);
// Auto advance after 3 seconds
LK.setTimeout(function () {
self.nextScene();
}, 3000);
};
return self;
});
var BirthdayScene = Scene.expand(function () {
var self = Scene.call(this, 1);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1500
}));
self.elements.push(bella);
// Birthday cake
var cake = game.addChild(LK.getAsset('cake', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1300
}));
self.elements.push(cake);
// Balloons
for (var i = 0; i < 3; i++) {
var balloon = game.addChild(LK.getAsset('balloon', {
anchorX: 0.5,
anchorY: 0.5,
x: 600 + i * 200,
y: 1100
}));
self.elements.push(balloon);
// Animate balloons
tween(balloon, {
y: balloon.y - 50
}, {
duration: 2000,
easing: tween.easeInOut
});
}
// Birthday celebration animation
tween(bella, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
scaleX: 1,
scaleY: 1
}, {
duration: 1000,
easing: tween.easeInOut
});
}
});
LK.getSound('celebration').play();
// Auto advance to next scene after 4 seconds
LK.setTimeout(function () {
self.nextScene();
}, 4000);
};
return self;
});
var AvoidanceScene = Scene.expand(function () {
var self = Scene.call(this, 4);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1600
}));
self.elements.push(bella);
// Create multiple purple onions
for (var i = 0; i < 6; i++) {
var onion = game.addChild(LK.getAsset('purpleOnion', {
anchorX: 0.5,
anchorY: 0.5,
x: 200 + i * 280,
y: 1000
}));
self.elements.push(onion);
// Animate onions moving down
tween(onion, {
y: 1800
}, {
duration: 2000 + Math.random() * 1000,
easing: tween.easeIn
});
}
// Bella dodges side to side
tween(bella, {
x: 600
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
x: 1400
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
x: 1024
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.nextScene();
}
});
}
});
}
});
};
return self;
});
var TVScreen = Container.expand(function () {
var self = Container.call(this);
// TV Frame
var frame = self.attachAsset('tvFrame', {
anchorX: 0.5,
anchorY: 0.5
});
// TV Screen
var screen = self.attachAsset('tvScreen', {
anchorX: 0.5,
anchorY: 0.5
});
// Play/Pause Button
var playButton = self.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 500
});
// Play Triangle (initially visible)
var playTriangle = self.attachAsset('playTriangle', {
anchorX: 0.5,
anchorY: 0.5,
x: 5,
y: 500
});
// Pause Bars (initially hidden)
var pauseBar1 = self.attachAsset('pauseBar1', {
anchorX: 0.5,
anchorY: 0.5,
x: -10,
y: 500,
alpha: 0
});
var pauseBar2 = self.attachAsset('pauseBar2', {
anchorX: 0.5,
anchorY: 0.5,
x: 10,
y: 500,
alpha: 0
});
self.isPlaying = false;
self.showPlay = function () {
playTriangle.alpha = 1;
pauseBar1.alpha = 0;
pauseBar2.alpha = 0;
self.isPlaying = false;
};
self.showPause = function () {
playTriangle.alpha = 0;
pauseBar1.alpha = 1;
pauseBar2.alpha = 1;
self.isPlaying = true;
};
self.down = function (x, y, obj) {
// Check if clicked on play button area
var localPos = self.toLocal(obj.parent.toGlobal(obj.position));
var buttonDistance = Math.sqrt(Math.pow(localPos.x - playButton.x, 2) + Math.pow(localPos.y - playButton.y, 2));
if (buttonDistance < 60) {
LK.getSound('buttonClick').play();
if (self.isPlaying) {
self.showPlay();
currentScene.pause();
} else {
self.showPause();
currentScene.play();
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
var tvScreen;
var scenes = [];
var currentSceneIndex = 0;
var currentScene;
// Create TV Screen
tvScreen = game.addChild(new TVScreen());
tvScreen.x = 1024;
tvScreen.y = 1200;
// Create scenes
scenes.push(new BirthdayScene());
scenes.push(new DepartureScene());
scenes.push(new ConfrontationScene());
scenes.push(new AvoidanceScene());
scenes.push(new WeddingScene());
// Set initial scene
currentScene = scenes[currentSceneIndex];
// Title text
var titleText = new Text2('Jungle Me 2: Movie Magic', {
size: 80,
fill: 0x2C3E50
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 200;
game.addChild(titleText);
// Instructions text
var instructionText = new Text2('Tap the play button to watch the movie!', {
size: 60,
fill: 0x34495E
});
instructionText.anchor.set(0.5, 0);
instructionText.x = 1024;
instructionText.y = 300;
game.addChild(instructionText);
// Scene counter
var sceneText = new Text2('Scene 1 of 5', {
size: 50,
fill: 0x7F8C8D
});
sceneText.anchor.set(0.5, 0);
sceneText.x = 1024;
sceneText.y = 2600;
game.addChild(sceneText);
game.update = function () {
// Update scene counter
sceneText.setText('Scene ' + (currentSceneIndex + 1) + ' of 5');
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Scene = Container.expand(function (sceneNumber) {
var self = Container.call(this);
self.sceneNumber = sceneNumber;
self.isActive = false;
self.elements = [];
self.play = function () {
self.isActive = true;
self.setupScene();
};
self.pause = function () {
self.isActive = false;
// Stop all tweens for this scene
for (var i = 0; i < self.elements.length; i++) {
tween.stop(self.elements[i]);
}
};
self.setupScene = function () {
// Override in specific scenes
};
self.nextScene = function () {
if (currentSceneIndex < scenes.length - 1) {
currentSceneIndex++;
currentScene = scenes[currentSceneIndex];
tvScreen.showPlay();
LK.getSound('sceneTransition').play();
self.clearScene();
}
};
self.clearScene = function () {
for (var i = 0; i < self.elements.length; i++) {
if (self.elements[i].parent) {
self.elements[i].parent.removeChild(self.elements[i]);
}
}
self.elements = [];
};
return self;
});
var WeddingScene = Scene.expand(function () {
var self = Scene.call(this, 5);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 800,
y: 1500
}));
self.elements.push(bella);
// Finny character (returned)
var finny = game.addChild(LK.getAsset('finny', {
anchorX: 0.5,
anchorY: 0.5,
x: 1300,
y: 1500
}));
self.elements.push(finny);
// Wedding decoration
var wedding = game.addChild(LK.getAsset('wedding', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1200
}));
self.elements.push(wedding);
// Celebration hearts
for (var i = 0; i < 10; i++) {
var heart = game.addChild(LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5,
x: 500 + Math.random() * 1000,
y: 1800,
alpha: 0.8
}));
self.elements.push(heart);
// Hearts float up
tween(heart, {
y: 800,
alpha: 0
}, {
duration: 3000 + Math.random() * 2000,
easing: tween.easeOut
});
}
// Characters come together
tween(bella, {
x: 950
}, {
duration: 2000,
easing: tween.easeInOut
});
tween(finny, {
x: 1100
}, {
duration: 2000,
easing: tween.easeInOut
});
LK.getSound('celebration').play();
// Show completion message
LK.setTimeout(function () {
LK.showYouWin();
}, 5000);
};
return self;
});
var DepartureScene = Scene.expand(function () {
var self = Scene.call(this, 2);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 800,
y: 1400
}));
self.elements.push(bella);
// Finny character
var finny = game.addChild(LK.getAsset('finny', {
anchorX: 0.5,
anchorY: 0.5,
x: 1300,
y: 1400
}));
self.elements.push(finny);
// Hearts floating around
for (var i = 0; i < 5; i++) {
var heart = game.addChild(LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5,
x: 900 + Math.random() * 200,
y: 1200 + Math.random() * 100,
alpha: 0.7
}));
self.elements.push(heart);
// Animate hearts
tween(heart, {
y: heart.y - 100,
alpha: 0
}, {
duration: 3000,
easing: tween.easeOut
});
}
// Finny moves away
tween(finny, {
x: 2200
}, {
duration: 3000,
easing: tween.easeIn,
onFinish: function onFinish() {
self.nextScene();
}
});
// Bella waves
tween(bella, {
rotation: 0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
rotation: -0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
rotation: 0
}, {
duration: 500,
easing: tween.easeInOut
});
}
});
}
});
};
return self;
});
var ConfrontationScene = Scene.expand(function () {
var self = Scene.call(this, 3);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 700,
y: 1400
}));
self.elements.push(bella);
// Purple evil onion
var purpleOnion = game.addChild(LK.getAsset('purpleOnion', {
anchorX: 0.5,
anchorY: 0.5,
x: 1400,
y: 1400
}));
self.elements.push(purpleOnion);
// Bella screams animation
tween(bella, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(bella, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeIn
});
}
});
// Onion villain animation
tween(purpleOnion, {
rotation: 0.5
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(purpleOnion, {
rotation: -0.5
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(purpleOnion, {
rotation: 0
}, {
duration: 300,
easing: tween.easeInOut
});
}
});
}
});
// Flash screen red briefly
LK.effects.flashScreen(0xff0000, 500);
// Auto advance after 3 seconds
LK.setTimeout(function () {
self.nextScene();
}, 3000);
};
return self;
});
var BirthdayScene = Scene.expand(function () {
var self = Scene.call(this, 1);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1500
}));
self.elements.push(bella);
// Birthday cake
var cake = game.addChild(LK.getAsset('cake', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1300
}));
self.elements.push(cake);
// Balloons
for (var i = 0; i < 3; i++) {
var balloon = game.addChild(LK.getAsset('balloon', {
anchorX: 0.5,
anchorY: 0.5,
x: 600 + i * 200,
y: 1100
}));
self.elements.push(balloon);
// Animate balloons
tween(balloon, {
y: balloon.y - 50
}, {
duration: 2000,
easing: tween.easeInOut
});
}
// Birthday celebration animation
tween(bella, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
scaleX: 1,
scaleY: 1
}, {
duration: 1000,
easing: tween.easeInOut
});
}
});
LK.getSound('celebration').play();
// Auto advance to next scene after 4 seconds
LK.setTimeout(function () {
self.nextScene();
}, 4000);
};
return self;
});
var AvoidanceScene = Scene.expand(function () {
var self = Scene.call(this, 4);
self.setupScene = function () {
self.clearScene();
// Bella character
var bella = game.addChild(LK.getAsset('bella', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1600
}));
self.elements.push(bella);
// Create multiple purple onions
for (var i = 0; i < 6; i++) {
var onion = game.addChild(LK.getAsset('purpleOnion', {
anchorX: 0.5,
anchorY: 0.5,
x: 200 + i * 280,
y: 1000
}));
self.elements.push(onion);
// Animate onions moving down
tween(onion, {
y: 1800
}, {
duration: 2000 + Math.random() * 1000,
easing: tween.easeIn
});
}
// Bella dodges side to side
tween(bella, {
x: 600
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
x: 1400
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bella, {
x: 1024
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.nextScene();
}
});
}
});
}
});
};
return self;
});
var TVScreen = Container.expand(function () {
var self = Container.call(this);
// TV Frame
var frame = self.attachAsset('tvFrame', {
anchorX: 0.5,
anchorY: 0.5
});
// TV Screen
var screen = self.attachAsset('tvScreen', {
anchorX: 0.5,
anchorY: 0.5
});
// Play/Pause Button
var playButton = self.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 500
});
// Play Triangle (initially visible)
var playTriangle = self.attachAsset('playTriangle', {
anchorX: 0.5,
anchorY: 0.5,
x: 5,
y: 500
});
// Pause Bars (initially hidden)
var pauseBar1 = self.attachAsset('pauseBar1', {
anchorX: 0.5,
anchorY: 0.5,
x: -10,
y: 500,
alpha: 0
});
var pauseBar2 = self.attachAsset('pauseBar2', {
anchorX: 0.5,
anchorY: 0.5,
x: 10,
y: 500,
alpha: 0
});
self.isPlaying = false;
self.showPlay = function () {
playTriangle.alpha = 1;
pauseBar1.alpha = 0;
pauseBar2.alpha = 0;
self.isPlaying = false;
};
self.showPause = function () {
playTriangle.alpha = 0;
pauseBar1.alpha = 1;
pauseBar2.alpha = 1;
self.isPlaying = true;
};
self.down = function (x, y, obj) {
// Check if clicked on play button area
var localPos = self.toLocal(obj.parent.toGlobal(obj.position));
var buttonDistance = Math.sqrt(Math.pow(localPos.x - playButton.x, 2) + Math.pow(localPos.y - playButton.y, 2));
if (buttonDistance < 60) {
LK.getSound('buttonClick').play();
if (self.isPlaying) {
self.showPlay();
currentScene.pause();
} else {
self.showPause();
currentScene.play();
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
var tvScreen;
var scenes = [];
var currentSceneIndex = 0;
var currentScene;
// Create TV Screen
tvScreen = game.addChild(new TVScreen());
tvScreen.x = 1024;
tvScreen.y = 1200;
// Create scenes
scenes.push(new BirthdayScene());
scenes.push(new DepartureScene());
scenes.push(new ConfrontationScene());
scenes.push(new AvoidanceScene());
scenes.push(new WeddingScene());
// Set initial scene
currentScene = scenes[currentSceneIndex];
// Title text
var titleText = new Text2('Jungle Me 2: Movie Magic', {
size: 80,
fill: 0x2C3E50
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 200;
game.addChild(titleText);
// Instructions text
var instructionText = new Text2('Tap the play button to watch the movie!', {
size: 60,
fill: 0x34495E
});
instructionText.anchor.set(0.5, 0);
instructionText.x = 1024;
instructionText.y = 300;
game.addChild(instructionText);
// Scene counter
var sceneText = new Text2('Scene 1 of 5', {
size: 50,
fill: 0x7F8C8D
});
sceneText.anchor.set(0.5, 0);
sceneText.x = 1024;
sceneText.y = 2600;
game.addChild(sceneText);
game.update = function () {
// Update scene counter
sceneText.setText('Scene ' + (currentSceneIndex + 1) + ' of 5');
};