Code edit (1 edits merged)
Please save this source code
User prompt
Halloween Scare with the Powerpuff Girls
Initial prompt
Toca Halloween 2 (2010). The powerpuff girls have spiders on their hair. And they got a video on the tv. Tap on the play button to make the tv turn on, when minion Dave 🍌 says “3..2...1.... BOO!” on the tv the powerpuff girls scream.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var MinionDave = Container.expand(function () { var self = Container.call(this); var body = self.attachAsset('minion', { anchorX: 0.5, anchorY: 0.5 }); // Add eyes var leftEye = self.attachAsset('minionEye', { anchorX: 0.5, anchorY: 0.5, x: -60, y: -80 }); var rightEye = self.attachAsset('minionEye', { anchorX: 0.5, anchorY: 0.5, x: 60, y: -80 }); var leftPupil = self.attachAsset('minionPupil', { anchorX: 0.5, anchorY: 0.5, x: -60, y: -80 }); var rightPupil = self.attachAsset('minionPupil', { anchorX: 0.5, anchorY: 0.5, x: 60, y: -80 }); self.visible = false; return self; }); var PowerpuffGirl = Container.expand(function (color) { var self = Container.call(this); var body = self.attachAsset(color === 0xff69b4 ? 'blossom' : color === 0x87ceeb ? 'bubbles' : 'buttercup', { anchorX: 0.5, anchorY: 0.5 }); // Add spiders to hair self.spiders = []; for (var i = 0; i < 3; i++) { var spider = new Spider(); spider.x = (Math.random() - 0.5) * 150; spider.y = -100 + (Math.random() - 0.5) * 50; self.addChild(spider); self.spiders.push(spider); } self.scared = false; self.scare = function () { if (self.scared) return; self.scared = true; // Jump back animation tween(self, { scaleX: 1.2, scaleY: 0.8 }, { duration: 100, easing: tween.easeOut }); tween(self, { scaleX: 0.9, scaleY: 1.3 }, { duration: 150, easing: tween.easeInOut }); tween(self, { scaleX: 1.0, scaleY: 1.0 }, { duration: 200, easing: tween.bounceOut }); // Make spiders wiggle for (var i = 0; i < self.spiders.length; i++) { self.spiders[i].wiggle(); } // Reset after animation LK.setTimeout(function () { self.scared = false; }, 2000); }; return self; }); var Spider = Container.expand(function () { var self = Container.call(this); var body = self.attachAsset('spider', { anchorX: 0.5, anchorY: 0.5 }); // Add spider legs var legs = []; for (var i = 0; i < 8; i++) { var leg = self.attachAsset('spiderLeg', { anchorX: 0.5, anchorY: 0.5 }); var angle = i / 8 * Math.PI * 2; leg.x = Math.cos(angle) * 25; leg.y = Math.sin(angle) * 25; leg.rotation = angle; legs.push(leg); } self.wiggle = function () { tween(self, { rotation: self.rotation + 0.2 }, { duration: 200, easing: tween.easeInOut }); tween(self, { rotation: self.rotation - 0.2 }, { duration: 200, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { rotation: 0 }, { duration: 200, easing: tween.easeInOut }); } }); }; return self; }); var Television = Container.expand(function () { var self = Container.call(this); var tvBody = self.attachAsset('tv', { anchorX: 0.5, anchorY: 0.5 }); var screen = self.attachAsset('tvScreen', { anchorX: 0.5, anchorY: 0.5, y: -20 }); self.playButton = self.attachAsset('playButton', { anchorX: 0.5, anchorY: 0.5, y: -20 }); var playTriangle = self.attachAsset('playTriangle', { anchorX: 0.5, anchorY: 0.5, x: 10, y: -20 }); self.countdownText = new Text2('', { size: 120, fill: '#ffffff' }); self.countdownText.anchor.set(0.5, 0.5); self.countdownText.x = 0; self.countdownText.y = -20; self.countdownText.visible = false; self.addChild(self.countdownText); self.minion = new MinionDave(); self.minion.x = 0; self.minion.y = -20; self.addChild(self.minion); self.isPlaying = false; self.startCountdown = function () { if (self.isPlaying) return; self.isPlaying = true; // Hide play button self.playButton.visible = false; playTriangle.visible = false; // Show minion self.minion.visible = true; self.countdownText.visible = true; // Start countdown sequence self.countdownText.setText('3'); LK.getSound('countdown3').play(); LK.setTimeout(function () { self.countdownText.setText('2'); LK.getSound('countdown2').play(); }, 1000); LK.setTimeout(function () { self.countdownText.setText('1'); LK.getSound('countdown1').play(); }, 2000); LK.setTimeout(function () { self.countdownText.setText('BOO!'); self.countdownText.style.fill = '#ff0000'; LK.getSound('boo').play(); // Scale up BOO text tween(self.countdownText, { scaleX: 1.5, scaleY: 1.5 }, { duration: 200, easing: tween.easeOut }); // Trigger scare reactions if (typeof triggerScare === 'function') { triggerScare(); } }, 3000); // Reset after scare LK.setTimeout(function () { self.reset(); }, 5000); }; self.reset = function () { self.isPlaying = false; self.playButton.visible = true; playTriangle.visible = true; self.minion.visible = false; self.countdownText.visible = false; self.countdownText.style.fill = '#ffffff'; self.countdownText.scaleX = 1; self.countdownText.scaleY = 1; }; self.down = function (x, y, obj) { if (!self.isPlaying && self.playButton.visible) { self.startCountdown(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2a1810 }); /**** * Game Code ****/ // Sound effects // Minion Dave // Spider elements // Powerpuff Girls // Create background var background = game.attachAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); // Create TV var tv = game.addChild(new Television()); tv.x = 1024; tv.y = 800; // Create Powerpuff Girls var blossom = game.addChild(new PowerpuffGirl(0xff69b4)); blossom.x = 600; blossom.y = 1800; var bubbles = game.addChild(new PowerpuffGirl(0x87ceeb)); bubbles.x = 1024; bubbles.y = 1900; var buttercup = game.addChild(new PowerpuffGirl(0x90ee90)); buttercup.x = 1448; buttercup.y = 1800; // Global function to trigger scare function triggerScare() { blossom.scare(); bubbles.scare(); buttercup.scare(); LK.getSound('scream').play(); // Screen flash effect LK.effects.flashScreen(0xff0000, 300); } game.update = function () { // Game logic runs here };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var MinionDave = Container.expand(function () {
var self = Container.call(this);
var body = self.attachAsset('minion', {
anchorX: 0.5,
anchorY: 0.5
});
// Add eyes
var leftEye = self.attachAsset('minionEye', {
anchorX: 0.5,
anchorY: 0.5,
x: -60,
y: -80
});
var rightEye = self.attachAsset('minionEye', {
anchorX: 0.5,
anchorY: 0.5,
x: 60,
y: -80
});
var leftPupil = self.attachAsset('minionPupil', {
anchorX: 0.5,
anchorY: 0.5,
x: -60,
y: -80
});
var rightPupil = self.attachAsset('minionPupil', {
anchorX: 0.5,
anchorY: 0.5,
x: 60,
y: -80
});
self.visible = false;
return self;
});
var PowerpuffGirl = Container.expand(function (color) {
var self = Container.call(this);
var body = self.attachAsset(color === 0xff69b4 ? 'blossom' : color === 0x87ceeb ? 'bubbles' : 'buttercup', {
anchorX: 0.5,
anchorY: 0.5
});
// Add spiders to hair
self.spiders = [];
for (var i = 0; i < 3; i++) {
var spider = new Spider();
spider.x = (Math.random() - 0.5) * 150;
spider.y = -100 + (Math.random() - 0.5) * 50;
self.addChild(spider);
self.spiders.push(spider);
}
self.scared = false;
self.scare = function () {
if (self.scared) return;
self.scared = true;
// Jump back animation
tween(self, {
scaleX: 1.2,
scaleY: 0.8
}, {
duration: 100,
easing: tween.easeOut
});
tween(self, {
scaleX: 0.9,
scaleY: 1.3
}, {
duration: 150,
easing: tween.easeInOut
});
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200,
easing: tween.bounceOut
});
// Make spiders wiggle
for (var i = 0; i < self.spiders.length; i++) {
self.spiders[i].wiggle();
}
// Reset after animation
LK.setTimeout(function () {
self.scared = false;
}, 2000);
};
return self;
});
var Spider = Container.expand(function () {
var self = Container.call(this);
var body = self.attachAsset('spider', {
anchorX: 0.5,
anchorY: 0.5
});
// Add spider legs
var legs = [];
for (var i = 0; i < 8; i++) {
var leg = self.attachAsset('spiderLeg', {
anchorX: 0.5,
anchorY: 0.5
});
var angle = i / 8 * Math.PI * 2;
leg.x = Math.cos(angle) * 25;
leg.y = Math.sin(angle) * 25;
leg.rotation = angle;
legs.push(leg);
}
self.wiggle = function () {
tween(self, {
rotation: self.rotation + 0.2
}, {
duration: 200,
easing: tween.easeInOut
});
tween(self, {
rotation: self.rotation - 0.2
}, {
duration: 200,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(self, {
rotation: 0
}, {
duration: 200,
easing: tween.easeInOut
});
}
});
};
return self;
});
var Television = Container.expand(function () {
var self = Container.call(this);
var tvBody = self.attachAsset('tv', {
anchorX: 0.5,
anchorY: 0.5
});
var screen = self.attachAsset('tvScreen', {
anchorX: 0.5,
anchorY: 0.5,
y: -20
});
self.playButton = self.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5,
y: -20
});
var playTriangle = self.attachAsset('playTriangle', {
anchorX: 0.5,
anchorY: 0.5,
x: 10,
y: -20
});
self.countdownText = new Text2('', {
size: 120,
fill: '#ffffff'
});
self.countdownText.anchor.set(0.5, 0.5);
self.countdownText.x = 0;
self.countdownText.y = -20;
self.countdownText.visible = false;
self.addChild(self.countdownText);
self.minion = new MinionDave();
self.minion.x = 0;
self.minion.y = -20;
self.addChild(self.minion);
self.isPlaying = false;
self.startCountdown = function () {
if (self.isPlaying) return;
self.isPlaying = true;
// Hide play button
self.playButton.visible = false;
playTriangle.visible = false;
// Show minion
self.minion.visible = true;
self.countdownText.visible = true;
// Start countdown sequence
self.countdownText.setText('3');
LK.getSound('countdown3').play();
LK.setTimeout(function () {
self.countdownText.setText('2');
LK.getSound('countdown2').play();
}, 1000);
LK.setTimeout(function () {
self.countdownText.setText('1');
LK.getSound('countdown1').play();
}, 2000);
LK.setTimeout(function () {
self.countdownText.setText('BOO!');
self.countdownText.style.fill = '#ff0000';
LK.getSound('boo').play();
// Scale up BOO text
tween(self.countdownText, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 200,
easing: tween.easeOut
});
// Trigger scare reactions
if (typeof triggerScare === 'function') {
triggerScare();
}
}, 3000);
// Reset after scare
LK.setTimeout(function () {
self.reset();
}, 5000);
};
self.reset = function () {
self.isPlaying = false;
self.playButton.visible = true;
playTriangle.visible = true;
self.minion.visible = false;
self.countdownText.visible = false;
self.countdownText.style.fill = '#ffffff';
self.countdownText.scaleX = 1;
self.countdownText.scaleY = 1;
};
self.down = function (x, y, obj) {
if (!self.isPlaying && self.playButton.visible) {
self.startCountdown();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2a1810
});
/****
* Game Code
****/
// Sound effects
// Minion Dave
// Spider elements
// Powerpuff Girls
// Create background
var background = game.attachAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
// Create TV
var tv = game.addChild(new Television());
tv.x = 1024;
tv.y = 800;
// Create Powerpuff Girls
var blossom = game.addChild(new PowerpuffGirl(0xff69b4));
blossom.x = 600;
blossom.y = 1800;
var bubbles = game.addChild(new PowerpuffGirl(0x87ceeb));
bubbles.x = 1024;
bubbles.y = 1900;
var buttercup = game.addChild(new PowerpuffGirl(0x90ee90));
buttercup.x = 1448;
buttercup.y = 1800;
// Global function to trigger scare
function triggerScare() {
blossom.scare();
bubbles.scare();
buttercup.scare();
LK.getSound('scream').play();
// Screen flash effect
LK.effects.flashScreen(0xff0000, 300);
}
game.update = function () {
// Game logic runs here
};