Code edit (1 edits merged)
Please save this source code
User prompt
Powerpuff Snow Day Adventure
Initial prompt
Toca snow day (2016). The powerpuff girls are playing in the snow. First on the list was snowboarding. Tap on the powerpuff girls to make them snowboard down the hill, second on the list was making snow angels. Tap on the powerpuff girls to make snow angels, third on the list was riding on train 🚂. Tap on the powerpuff express to make it go.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var PowerpuffGirl = Container.expand(function (girlType, color) { var self = Container.call(this); var girl = self.attachAsset(girlType, { anchorX: 0.5, anchorY: 0.5 }); self.activity = 'idle'; self.activityTimer = 0; self.originalX = 0; self.originalY = 0; self.isSnowboarding = false; self.snowboardStartX = 0; self.snowboardStartY = 0; self.setActivity = function (newActivity, x, y) { self.activity = newActivity; self.activityTimer = 0; self.originalX = x || self.x; self.originalY = y || self.y; if (newActivity === 'snowboarding') { self.isSnowboarding = true; self.snowboardStartX = self.x; self.snowboardStartY = self.y; } }; self.down = function (x, y, obj) { if (self.activity === 'idle') { // Determine which activity based on position var localPos = game.toLocal(obj.parent.toGlobal(obj.position)); if (localPos.y < 800) { // Snowboarding area self.setActivity('snowboarding'); LK.getSound('whoosh').play(); // Create snow particles for (var i = 0; i < 8; i++) { var particle = game.addChild(new SnowParticle()); particle.x = self.x + (Math.random() - 0.5) * 60; particle.y = self.y + (Math.random() - 0.5) * 60; snowParticles.push(particle); } } else if (localPos.y < 1600) { // Snow angel area self.setActivity('snowangel'); LK.getSound('snowcrunch').play(); // Create snow angel shape var angel = game.addChild(LK.getAsset('snowAngel', { anchorX: 0.5, anchorY: 0.5 })); angel.x = self.x; angel.y = self.y + 20; angel.alpha = 0.7; snowAngels.push(angel); } } }; self.update = function () { self.activityTimer++; if (self.activity === 'snowboarding') { self.y += 4; self.x += (Math.random() - 0.5) * 2; girl.rotation += 0.1; if (self.activityTimer % 5 === 0) { var particle = game.addChild(new SnowParticle()); particle.x = self.x + (Math.random() - 0.5) * 40; particle.y = self.y; snowParticles.push(particle); } if (self.y > 750) { self.activity = 'idle'; self.x = self.originalX; self.y = self.originalY; girl.rotation = 0; self.isSnowboarding = false; } } else if (self.activity === 'snowangel') { girl.scaleX = 1 + Math.sin(self.activityTimer * 0.3) * 0.2; girl.rotation = Math.sin(self.activityTimer * 0.2) * 0.2; if (self.activityTimer > 120) { self.activity = 'idle'; girl.scaleX = 1; girl.rotation = 0; } } else { // Idle floating animation girl.y = Math.sin(LK.ticks * 0.05 + self.originalX * 0.01) * 5; } }; return self; }); var SnowParticle = Container.expand(function () { var self = Container.call(this); var particle = self.attachAsset('snowParticle', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = (Math.random() - 0.5) * 4; self.speedY = Math.random() * 3 + 2; self.life = 60; self.update = function () { self.x += self.speedX; self.y += self.speedY; self.life--; particle.alpha = self.life / 60; if (self.life <= 0) { self.destroy(); } }; return self; }); var SteamPuff = Container.expand(function () { var self = Container.call(this); var steam = self.attachAsset('steamPuff', { anchorX: 0.5, anchorY: 0.5 }); self.speedY = -2; self.life = 90; self.update = function () { self.y += self.speedY; self.life--; steam.alpha = self.life / 90; steam.scaleX = steam.scaleY = 1 + (90 - self.life) / 90; if (self.life <= 0) { self.destroy(); } }; return self; }); var Train = Container.expand(function () { var self = Container.call(this); var trainBody = self.attachAsset('powerpuffExpress', { anchorX: 0.5, anchorY: 0.5 }); self.isMoving = false; self.moveTimer = 0; self.steamTimer = 0; self.down = function (x, y, obj) { if (!self.isMoving) { self.isMoving = true; self.moveTimer = 0; LK.getSound('trainWhistle').play(); tween(self, { x: self.x + 300 }, { duration: 2000, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { x: self.x - 300 }, { duration: 2000, easing: tween.easeIn, onFinish: function onFinish() { self.isMoving = false; } }); } }); } }; self.update = function () { if (self.isMoving) { self.moveTimer++; self.steamTimer++; if (self.steamTimer % 15 === 0) { var steam = game.addChild(new SteamPuff()); steam.x = self.x - 100; steam.y = self.y - 60; steamPuffs.push(steam); } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ // Arrays to track particles and effects var snowParticles = []; var steamPuffs = []; var snowAngels = []; // Create background areas var hillArea = game.addChild(LK.getAsset('snowboardHill', { anchorX: 0.5, anchorY: 0.5 })); hillArea.x = 1024; hillArea.y = 400; var angelArea = game.addChild(LK.getAsset('snowAngelArea', { anchorX: 0.5, anchorY: 0.5 })); angelArea.x = 1024; angelArea.y = 1200; var track = game.addChild(LK.getAsset('trainTrack', { anchorX: 0.5, anchorY: 0.5 })); track.x = 1024; track.y = 2000; // Create train var train = game.addChild(new Train()); train.x = 700; train.y = 1960; // Create Powerpuff Girls var blossom = game.addChild(new PowerpuffGirl('blossom')); blossom.x = 900; blossom.y = 300; blossom.originalX = blossom.x; blossom.originalY = blossom.y; var bubbles = game.addChild(new PowerpuffGirl('bubbles')); bubbles.x = 1024; bubbles.y = 280; bubbles.originalX = bubbles.x; bubbles.originalY = bubbles.y; var buttercup = game.addChild(new PowerpuffGirl('buttercup')); buttercup.x = 1150; buttercup.y = 320; buttercup.originalX = buttercup.x; buttercup.originalY = buttercup.y; // Add activity labels var snowboardLabel = new Text2('Tap Girls to Snowboard!', { size: 60, fill: 0xFFFFFF }); snowboardLabel.anchor.set(0.5, 0.5); snowboardLabel.x = 1024; snowboardLabel.y = 150; game.addChild(snowboardLabel); var angelLabel = new Text2('Tap Girls to Make Snow Angels!', { size: 60, fill: 0xFFFFFF }); angelLabel.anchor.set(0.5, 0.5); angelLabel.x = 1024; angelLabel.y = 1000; game.addChild(angelLabel); var trainLabel = new Text2('Tap Train for a Ride!', { size: 60, fill: 0xFFFFFF }); trainLabel.anchor.set(0.5, 0.5); trainLabel.x = 1024; trainLabel.y = 1800; game.addChild(trainLabel); // Ambient snow particles var ambientSnowTimer = 0; game.update = function () { ambientSnowTimer++; // Create ambient snow if (ambientSnowTimer % 20 === 0) { var particle = game.addChild(new SnowParticle()); particle.x = Math.random() * 2048; particle.y = -20; particle.speedY = Math.random() * 2 + 1; particle.speedX = (Math.random() - 0.5) * 2; particle.life = 200; snowParticles.push(particle); } // Clean up destroyed particles for (var i = snowParticles.length - 1; i >= 0; i--) { if (snowParticles[i].destroyed) { snowParticles.splice(i, 1); } } for (var j = steamPuffs.length - 1; j >= 0; j--) { if (steamPuffs[j].destroyed) { steamPuffs.splice(j, 1); } } // Clean up old snow angels for (var k = snowAngels.length - 1; k >= 0; k--) { if (LK.ticks % 600 === 0) { tween(snowAngels[k], { alpha: 0 }, { duration: 1000, onFinish: function onFinish() { if (snowAngels[k] && !snowAngels[k].destroyed) { snowAngels[k].destroy(); snowAngels.splice(k, 1); } } }); } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var PowerpuffGirl = Container.expand(function (girlType, color) {
var self = Container.call(this);
var girl = self.attachAsset(girlType, {
anchorX: 0.5,
anchorY: 0.5
});
self.activity = 'idle';
self.activityTimer = 0;
self.originalX = 0;
self.originalY = 0;
self.isSnowboarding = false;
self.snowboardStartX = 0;
self.snowboardStartY = 0;
self.setActivity = function (newActivity, x, y) {
self.activity = newActivity;
self.activityTimer = 0;
self.originalX = x || self.x;
self.originalY = y || self.y;
if (newActivity === 'snowboarding') {
self.isSnowboarding = true;
self.snowboardStartX = self.x;
self.snowboardStartY = self.y;
}
};
self.down = function (x, y, obj) {
if (self.activity === 'idle') {
// Determine which activity based on position
var localPos = game.toLocal(obj.parent.toGlobal(obj.position));
if (localPos.y < 800) {
// Snowboarding area
self.setActivity('snowboarding');
LK.getSound('whoosh').play();
// Create snow particles
for (var i = 0; i < 8; i++) {
var particle = game.addChild(new SnowParticle());
particle.x = self.x + (Math.random() - 0.5) * 60;
particle.y = self.y + (Math.random() - 0.5) * 60;
snowParticles.push(particle);
}
} else if (localPos.y < 1600) {
// Snow angel area
self.setActivity('snowangel');
LK.getSound('snowcrunch').play();
// Create snow angel shape
var angel = game.addChild(LK.getAsset('snowAngel', {
anchorX: 0.5,
anchorY: 0.5
}));
angel.x = self.x;
angel.y = self.y + 20;
angel.alpha = 0.7;
snowAngels.push(angel);
}
}
};
self.update = function () {
self.activityTimer++;
if (self.activity === 'snowboarding') {
self.y += 4;
self.x += (Math.random() - 0.5) * 2;
girl.rotation += 0.1;
if (self.activityTimer % 5 === 0) {
var particle = game.addChild(new SnowParticle());
particle.x = self.x + (Math.random() - 0.5) * 40;
particle.y = self.y;
snowParticles.push(particle);
}
if (self.y > 750) {
self.activity = 'idle';
self.x = self.originalX;
self.y = self.originalY;
girl.rotation = 0;
self.isSnowboarding = false;
}
} else if (self.activity === 'snowangel') {
girl.scaleX = 1 + Math.sin(self.activityTimer * 0.3) * 0.2;
girl.rotation = Math.sin(self.activityTimer * 0.2) * 0.2;
if (self.activityTimer > 120) {
self.activity = 'idle';
girl.scaleX = 1;
girl.rotation = 0;
}
} else {
// Idle floating animation
girl.y = Math.sin(LK.ticks * 0.05 + self.originalX * 0.01) * 5;
}
};
return self;
});
var SnowParticle = Container.expand(function () {
var self = Container.call(this);
var particle = self.attachAsset('snowParticle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = (Math.random() - 0.5) * 4;
self.speedY = Math.random() * 3 + 2;
self.life = 60;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
self.life--;
particle.alpha = self.life / 60;
if (self.life <= 0) {
self.destroy();
}
};
return self;
});
var SteamPuff = Container.expand(function () {
var self = Container.call(this);
var steam = self.attachAsset('steamPuff', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedY = -2;
self.life = 90;
self.update = function () {
self.y += self.speedY;
self.life--;
steam.alpha = self.life / 90;
steam.scaleX = steam.scaleY = 1 + (90 - self.life) / 90;
if (self.life <= 0) {
self.destroy();
}
};
return self;
});
var Train = Container.expand(function () {
var self = Container.call(this);
var trainBody = self.attachAsset('powerpuffExpress', {
anchorX: 0.5,
anchorY: 0.5
});
self.isMoving = false;
self.moveTimer = 0;
self.steamTimer = 0;
self.down = function (x, y, obj) {
if (!self.isMoving) {
self.isMoving = true;
self.moveTimer = 0;
LK.getSound('trainWhistle').play();
tween(self, {
x: self.x + 300
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
x: self.x - 300
}, {
duration: 2000,
easing: tween.easeIn,
onFinish: function onFinish() {
self.isMoving = false;
}
});
}
});
}
};
self.update = function () {
if (self.isMoving) {
self.moveTimer++;
self.steamTimer++;
if (self.steamTimer % 15 === 0) {
var steam = game.addChild(new SteamPuff());
steam.x = self.x - 100;
steam.y = self.y - 60;
steamPuffs.push(steam);
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Arrays to track particles and effects
var snowParticles = [];
var steamPuffs = [];
var snowAngels = [];
// Create background areas
var hillArea = game.addChild(LK.getAsset('snowboardHill', {
anchorX: 0.5,
anchorY: 0.5
}));
hillArea.x = 1024;
hillArea.y = 400;
var angelArea = game.addChild(LK.getAsset('snowAngelArea', {
anchorX: 0.5,
anchorY: 0.5
}));
angelArea.x = 1024;
angelArea.y = 1200;
var track = game.addChild(LK.getAsset('trainTrack', {
anchorX: 0.5,
anchorY: 0.5
}));
track.x = 1024;
track.y = 2000;
// Create train
var train = game.addChild(new Train());
train.x = 700;
train.y = 1960;
// Create Powerpuff Girls
var blossom = game.addChild(new PowerpuffGirl('blossom'));
blossom.x = 900;
blossom.y = 300;
blossom.originalX = blossom.x;
blossom.originalY = blossom.y;
var bubbles = game.addChild(new PowerpuffGirl('bubbles'));
bubbles.x = 1024;
bubbles.y = 280;
bubbles.originalX = bubbles.x;
bubbles.originalY = bubbles.y;
var buttercup = game.addChild(new PowerpuffGirl('buttercup'));
buttercup.x = 1150;
buttercup.y = 320;
buttercup.originalX = buttercup.x;
buttercup.originalY = buttercup.y;
// Add activity labels
var snowboardLabel = new Text2('Tap Girls to Snowboard!', {
size: 60,
fill: 0xFFFFFF
});
snowboardLabel.anchor.set(0.5, 0.5);
snowboardLabel.x = 1024;
snowboardLabel.y = 150;
game.addChild(snowboardLabel);
var angelLabel = new Text2('Tap Girls to Make Snow Angels!', {
size: 60,
fill: 0xFFFFFF
});
angelLabel.anchor.set(0.5, 0.5);
angelLabel.x = 1024;
angelLabel.y = 1000;
game.addChild(angelLabel);
var trainLabel = new Text2('Tap Train for a Ride!', {
size: 60,
fill: 0xFFFFFF
});
trainLabel.anchor.set(0.5, 0.5);
trainLabel.x = 1024;
trainLabel.y = 1800;
game.addChild(trainLabel);
// Ambient snow particles
var ambientSnowTimer = 0;
game.update = function () {
ambientSnowTimer++;
// Create ambient snow
if (ambientSnowTimer % 20 === 0) {
var particle = game.addChild(new SnowParticle());
particle.x = Math.random() * 2048;
particle.y = -20;
particle.speedY = Math.random() * 2 + 1;
particle.speedX = (Math.random() - 0.5) * 2;
particle.life = 200;
snowParticles.push(particle);
}
// Clean up destroyed particles
for (var i = snowParticles.length - 1; i >= 0; i--) {
if (snowParticles[i].destroyed) {
snowParticles.splice(i, 1);
}
}
for (var j = steamPuffs.length - 1; j >= 0; j--) {
if (steamPuffs[j].destroyed) {
steamPuffs.splice(j, 1);
}
}
// Clean up old snow angels
for (var k = snowAngels.length - 1; k >= 0; k--) {
if (LK.ticks % 600 === 0) {
tween(snowAngels[k], {
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
if (snowAngels[k] && !snowAngels[k].destroyed) {
snowAngels[k].destroy();
snowAngels.splice(k, 1);
}
}
});
}
}
};