Code edit (1 edits merged)
Please save this source code
User prompt
Powerpuff Girls: Snowball Showdown
Initial prompt
The powerpuff girls: blossom is walking over with footprints in snow. Bubbles and buttercup are making 10 snowballs. Tap on bubbles or buttercup to make them throw 10 snowballs onto blossom. For the final of the snowball fight just tap on blossom’s bigger snowball to roll and jump onto bubbles and buttercup.
/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
/**** 
* Classes
****/ 
var Character = Container.expand(function (characterType) {
	var self = Container.call(this);
	var characterGraphics = self.attachAsset(characterType, {
		anchorX: 0.5,
		anchorY: 1.0
	});
	self.characterType = characterType;
	self.snowballCount = 10;
	self.down = function (x, y, obj) {
		if (gamePhase == 'attack' && self.snowballCount > 0 && (self.characterType == 'bubbles' || self.characterType == 'buttercup')) {
			self.throwSnowball();
		}
	};
	self.throwSnowball = function () {
		if (self.snowballCount > 0) {
			var newSnowball = new Snowball();
			newSnowball.x = self.x;
			newSnowball.y = self.y - 80;
			newSnowball.launch(blossom.x, blossom.y - 75);
			snowballs.push(newSnowball);
			game.addChild(newSnowball);
			self.snowballCount--;
			LK.getSound('throw').play();
			updateSnowballCounters();
			if (bubbles.snowballCount == 0 && buttercup.snowballCount == 0) {
				LK.setTimeout(function () {
					startFinalePhase();
				}, 1000);
			}
		}
	};
	return self;
});
var Footprint = Container.expand(function () {
	var self = Container.call(this);
	var footprintGraphics = self.attachAsset('footprint', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	footprintGraphics.alpha = 0.6;
	return self;
});
var GiantSnowball = Container.expand(function () {
	var self = Container.call(this);
	var snowballGraphics = self.attachAsset('giantSnowball', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speedX = 0;
	self.speedY = 0;
	self.active = false;
	self.jumpHeight = 0;
	self.isJumping = false;
	self.activate = function () {
		self.active = true;
		self.speedX = -8;
		self.speedY = -2;
		LK.getSound('roll').play();
	};
	self.down = function (x, y, obj) {
		if (!self.active && gamePhase == 'finale') {
			self.activate();
		}
	};
	self.update = function () {
		if (self.active) {
			self.x += self.speedX;
			self.y += self.speedY;
			snowballGraphics.rotation += 0.2;
			if (self.y > 2000 && !self.isJumping) {
				self.isJumping = true;
				self.speedY = -15;
			}
			if (self.isJumping) {
				self.speedY += 0.8;
				if (self.y > 2000) {
					self.speedY = -10;
				}
			}
		}
	};
	return self;
});
var SnowParticle = Container.expand(function () {
	var self = Container.call(this);
	var particleGraphics = self.attachAsset('snowParticle', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speedX = (Math.random() - 0.5) * 4;
	self.speedY = (Math.random() - 0.5) * 4;
	self.life = 60;
	self.update = function () {
		self.x += self.speedX;
		self.y += self.speedY;
		self.life--;
		particleGraphics.alpha = self.life / 60;
		if (self.life <= 0) {
			self.destroy();
		}
	};
	return self;
});
var Snowball = Container.expand(function () {
	var self = Container.call(this);
	var snowballGraphics = self.attachAsset('snowball', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speedX = 0;
	self.speedY = 0;
	self.active = false;
	self.launch = function (targetX, targetY) {
		self.active = true;
		var deltaX = targetX - self.x;
		var deltaY = targetY - self.y;
		var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
		self.speedX = deltaX / distance * 12;
		self.speedY = deltaY / distance * 12;
	};
	self.update = function () {
		if (self.active) {
			self.x += self.speedX;
			self.y += self.speedY;
			if (self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782) {
				self.active = false;
			}
		}
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87ceeb
});
/**** 
* Game Code
****/ 
// Game state variables
var gamePhase = 'setup'; // 'setup', 'attack', 'finale', 'victory'
var blossom, bubbles, buttercup;
var giantSnowball;
var snowballs = [];
var footprints = [];
var particles = [];
var footprintTimer = 0;
// UI elements
var bubblesCountText, buttercupCountText;
var instructionText;
// Initialize characters
blossom = game.addChild(new Character('blossom'));
blossom.x = -100;
blossom.y = 1800;
bubbles = game.addChild(new Character('bubbles'));
bubbles.x = 400;
bubbles.y = 2200;
buttercup = game.addChild(new Character('buttercup'));
buttercup.x = 1600;
buttercup.y = 2200;
// Initialize giant snowball (hidden initially)
giantSnowball = game.addChild(new GiantSnowball());
giantSnowball.x = 2200;
giantSnowball.y = 1800;
giantSnowball.alpha = 0;
// UI Setup
bubblesCountText = new Text2('Bubbles: 10', {
	size: 60,
	fill: 0xFFFFFF
});
bubblesCountText.anchor.set(0, 0);
LK.gui.topLeft.addChild(bubblesCountText);
bubblesCountText.x = 120;
bubblesCountText.y = 20;
buttercupCountText = new Text2('Buttercup: 10', {
	size: 60,
	fill: 0xFFFFFF
});
buttercupCountText.anchor.set(1, 0);
LK.gui.topRight.addChild(buttercupCountText);
instructionText = new Text2('Watch Blossom walk...', {
	size: 80,
	fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionText);
instructionText.y = 150;
function updateSnowballCounters() {
	bubblesCountText.setText('Bubbles: ' + bubbles.snowballCount);
	buttercupCountText.setText('Buttercup: ' + buttercup.snowballCount);
}
function createFootprint(x, y) {
	var footprint = new Footprint();
	footprint.x = x;
	footprint.y = y;
	footprints.push(footprint);
	game.addChild(footprint);
}
function createSnowParticles(x, y, count) {
	for (var i = 0; i < count; i++) {
		var particle = new SnowParticle();
		particle.x = x + (Math.random() - 0.5) * 60;
		particle.y = y + (Math.random() - 0.5) * 60;
		particles.push(particle);
		game.addChild(particle);
	}
}
function startAttackPhase() {
	gamePhase = 'attack';
	instructionText.setText('Tap Bubbles & Buttercup to throw snowballs!');
}
function startFinalePhase() {
	gamePhase = 'finale';
	instructionText.setText('Tap the giant snowball to help Blossom!');
	giantSnowball.alpha = 1;
	tween(giantSnowball, {
		scaleX: 1.2,
		scaleY: 1.2
	}, {
		duration: 500,
		easing: tween.easeInOut,
		onFinish: function onFinish() {
			tween(giantSnowball, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 500,
				easing: tween.easeInOut
			});
		}
	});
}
function checkVictory() {
	if (giantSnowball.active && giantSnowball.x < 600) {
		gamePhase = 'victory';
		instructionText.setText('Blossom wins the snowball fight!');
		LK.showYouWin();
	}
}
// Game update loop
game.update = function () {
	// Setup phase: Blossom walks across screen
	if (gamePhase == 'setup') {
		blossom.x += 3;
		// Create footprints
		footprintTimer++;
		if (footprintTimer % 20 == 0) {
			createFootprint(blossom.x - 30, blossom.y);
		}
		// Start attack phase when Blossom reaches center
		if (blossom.x > 1024) {
			startAttackPhase();
		}
	}
	// Attack phase: Blossom continues walking slowly
	if (gamePhase == 'attack') {
		blossom.x += 1;
		footprintTimer++;
		if (footprintTimer % 30 == 0) {
			createFootprint(blossom.x - 30, blossom.y);
		}
	}
	// Check snowball collisions with Blossom
	for (var i = snowballs.length - 1; i >= 0; i--) {
		var snowball = snowballs[i];
		if (snowball.active && snowball.intersects(blossom)) {
			// Hit effect
			LK.getSound('hit').play();
			createSnowParticles(snowball.x, snowball.y, 8);
			LK.effects.flashObject(blossom, 0xffffff, 300);
			// Remove snowball
			snowball.destroy();
			snowballs.splice(i, 1);
			// Add score
			LK.setScore(LK.getScore() + 10);
		} else if (!snowball.active) {
			snowball.destroy();
			snowballs.splice(i, 1);
		}
	}
	// Clean up old particles
	for (var j = particles.length - 1; j >= 0; j--) {
		if (particles[j].life <= 0) {
			particles.splice(j, 1);
		}
	}
	// Check victory condition
	if (gamePhase == 'finale') {
		checkVictory();
	}
	// Fade old footprints
	for (var k = 0; k < footprints.length; k++) {
		if (footprints[k].alpha > 0) {
			footprints[k].alpha -= 0.005;
		}
	}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,308 @@
-/****
+/**** 
+* Plugins
+****/ 
+var tween = LK.import("@upit/tween.v1");
+
+/**** 
+* Classes
+****/ 
+var Character = Container.expand(function (characterType) {
+	var self = Container.call(this);
+	var characterGraphics = self.attachAsset(characterType, {
+		anchorX: 0.5,
+		anchorY: 1.0
+	});
+	self.characterType = characterType;
+	self.snowballCount = 10;
+	self.down = function (x, y, obj) {
+		if (gamePhase == 'attack' && self.snowballCount > 0 && (self.characterType == 'bubbles' || self.characterType == 'buttercup')) {
+			self.throwSnowball();
+		}
+	};
+	self.throwSnowball = function () {
+		if (self.snowballCount > 0) {
+			var newSnowball = new Snowball();
+			newSnowball.x = self.x;
+			newSnowball.y = self.y - 80;
+			newSnowball.launch(blossom.x, blossom.y - 75);
+			snowballs.push(newSnowball);
+			game.addChild(newSnowball);
+			self.snowballCount--;
+			LK.getSound('throw').play();
+			updateSnowballCounters();
+			if (bubbles.snowballCount == 0 && buttercup.snowballCount == 0) {
+				LK.setTimeout(function () {
+					startFinalePhase();
+				}, 1000);
+			}
+		}
+	};
+	return self;
+});
+var Footprint = Container.expand(function () {
+	var self = Container.call(this);
+	var footprintGraphics = self.attachAsset('footprint', {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	footprintGraphics.alpha = 0.6;
+	return self;
+});
+var GiantSnowball = Container.expand(function () {
+	var self = Container.call(this);
+	var snowballGraphics = self.attachAsset('giantSnowball', {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	self.speedX = 0;
+	self.speedY = 0;
+	self.active = false;
+	self.jumpHeight = 0;
+	self.isJumping = false;
+	self.activate = function () {
+		self.active = true;
+		self.speedX = -8;
+		self.speedY = -2;
+		LK.getSound('roll').play();
+	};
+	self.down = function (x, y, obj) {
+		if (!self.active && gamePhase == 'finale') {
+			self.activate();
+		}
+	};
+	self.update = function () {
+		if (self.active) {
+			self.x += self.speedX;
+			self.y += self.speedY;
+			snowballGraphics.rotation += 0.2;
+			if (self.y > 2000 && !self.isJumping) {
+				self.isJumping = true;
+				self.speedY = -15;
+			}
+			if (self.isJumping) {
+				self.speedY += 0.8;
+				if (self.y > 2000) {
+					self.speedY = -10;
+				}
+			}
+		}
+	};
+	return self;
+});
+var SnowParticle = Container.expand(function () {
+	var self = Container.call(this);
+	var particleGraphics = self.attachAsset('snowParticle', {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	self.speedX = (Math.random() - 0.5) * 4;
+	self.speedY = (Math.random() - 0.5) * 4;
+	self.life = 60;
+	self.update = function () {
+		self.x += self.speedX;
+		self.y += self.speedY;
+		self.life--;
+		particleGraphics.alpha = self.life / 60;
+		if (self.life <= 0) {
+			self.destroy();
+		}
+	};
+	return self;
+});
+var Snowball = Container.expand(function () {
+	var self = Container.call(this);
+	var snowballGraphics = self.attachAsset('snowball', {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	self.speedX = 0;
+	self.speedY = 0;
+	self.active = false;
+	self.launch = function (targetX, targetY) {
+		self.active = true;
+		var deltaX = targetX - self.x;
+		var deltaY = targetY - self.y;
+		var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
+		self.speedX = deltaX / distance * 12;
+		self.speedY = deltaY / distance * 12;
+	};
+	self.update = function () {
+		if (self.active) {
+			self.x += self.speedX;
+			self.y += self.speedY;
+			if (self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782) {
+				self.active = false;
+			}
+		}
+	};
+	return self;
+});
+
+/**** 
 * Initialize Game
-****/
+****/ 
 var game = new LK.Game({
-	backgroundColor: 0x000000
-});
\ No newline at end of file
+	backgroundColor: 0x87ceeb
+});
+
+/**** 
+* Game Code
+****/ 
+// Game state variables
+var gamePhase = 'setup'; // 'setup', 'attack', 'finale', 'victory'
+var blossom, bubbles, buttercup;
+var giantSnowball;
+var snowballs = [];
+var footprints = [];
+var particles = [];
+var footprintTimer = 0;
+// UI elements
+var bubblesCountText, buttercupCountText;
+var instructionText;
+// Initialize characters
+blossom = game.addChild(new Character('blossom'));
+blossom.x = -100;
+blossom.y = 1800;
+bubbles = game.addChild(new Character('bubbles'));
+bubbles.x = 400;
+bubbles.y = 2200;
+buttercup = game.addChild(new Character('buttercup'));
+buttercup.x = 1600;
+buttercup.y = 2200;
+// Initialize giant snowball (hidden initially)
+giantSnowball = game.addChild(new GiantSnowball());
+giantSnowball.x = 2200;
+giantSnowball.y = 1800;
+giantSnowball.alpha = 0;
+// UI Setup
+bubblesCountText = new Text2('Bubbles: 10', {
+	size: 60,
+	fill: 0xFFFFFF
+});
+bubblesCountText.anchor.set(0, 0);
+LK.gui.topLeft.addChild(bubblesCountText);
+bubblesCountText.x = 120;
+bubblesCountText.y = 20;
+buttercupCountText = new Text2('Buttercup: 10', {
+	size: 60,
+	fill: 0xFFFFFF
+});
+buttercupCountText.anchor.set(1, 0);
+LK.gui.topRight.addChild(buttercupCountText);
+instructionText = new Text2('Watch Blossom walk...', {
+	size: 80,
+	fill: 0xFFFFFF
+});
+instructionText.anchor.set(0.5, 0);
+LK.gui.top.addChild(instructionText);
+instructionText.y = 150;
+function updateSnowballCounters() {
+	bubblesCountText.setText('Bubbles: ' + bubbles.snowballCount);
+	buttercupCountText.setText('Buttercup: ' + buttercup.snowballCount);
+}
+function createFootprint(x, y) {
+	var footprint = new Footprint();
+	footprint.x = x;
+	footprint.y = y;
+	footprints.push(footprint);
+	game.addChild(footprint);
+}
+function createSnowParticles(x, y, count) {
+	for (var i = 0; i < count; i++) {
+		var particle = new SnowParticle();
+		particle.x = x + (Math.random() - 0.5) * 60;
+		particle.y = y + (Math.random() - 0.5) * 60;
+		particles.push(particle);
+		game.addChild(particle);
+	}
+}
+function startAttackPhase() {
+	gamePhase = 'attack';
+	instructionText.setText('Tap Bubbles & Buttercup to throw snowballs!');
+}
+function startFinalePhase() {
+	gamePhase = 'finale';
+	instructionText.setText('Tap the giant snowball to help Blossom!');
+	giantSnowball.alpha = 1;
+	tween(giantSnowball, {
+		scaleX: 1.2,
+		scaleY: 1.2
+	}, {
+		duration: 500,
+		easing: tween.easeInOut,
+		onFinish: function onFinish() {
+			tween(giantSnowball, {
+				scaleX: 1,
+				scaleY: 1
+			}, {
+				duration: 500,
+				easing: tween.easeInOut
+			});
+		}
+	});
+}
+function checkVictory() {
+	if (giantSnowball.active && giantSnowball.x < 600) {
+		gamePhase = 'victory';
+		instructionText.setText('Blossom wins the snowball fight!');
+		LK.showYouWin();
+	}
+}
+// Game update loop
+game.update = function () {
+	// Setup phase: Blossom walks across screen
+	if (gamePhase == 'setup') {
+		blossom.x += 3;
+		// Create footprints
+		footprintTimer++;
+		if (footprintTimer % 20 == 0) {
+			createFootprint(blossom.x - 30, blossom.y);
+		}
+		// Start attack phase when Blossom reaches center
+		if (blossom.x > 1024) {
+			startAttackPhase();
+		}
+	}
+	// Attack phase: Blossom continues walking slowly
+	if (gamePhase == 'attack') {
+		blossom.x += 1;
+		footprintTimer++;
+		if (footprintTimer % 30 == 0) {
+			createFootprint(blossom.x - 30, blossom.y);
+		}
+	}
+	// Check snowball collisions with Blossom
+	for (var i = snowballs.length - 1; i >= 0; i--) {
+		var snowball = snowballs[i];
+		if (snowball.active && snowball.intersects(blossom)) {
+			// Hit effect
+			LK.getSound('hit').play();
+			createSnowParticles(snowball.x, snowball.y, 8);
+			LK.effects.flashObject(blossom, 0xffffff, 300);
+			// Remove snowball
+			snowball.destroy();
+			snowballs.splice(i, 1);
+			// Add score
+			LK.setScore(LK.getScore() + 10);
+		} else if (!snowball.active) {
+			snowball.destroy();
+			snowballs.splice(i, 1);
+		}
+	}
+	// Clean up old particles
+	for (var j = particles.length - 1; j >= 0; j--) {
+		if (particles[j].life <= 0) {
+			particles.splice(j, 1);
+		}
+	}
+	// Check victory condition
+	if (gamePhase == 'finale') {
+		checkVictory();
+	}
+	// Fade old footprints
+	for (var k = 0; k < footprints.length; k++) {
+		if (footprints[k].alpha > 0) {
+			footprints[k].alpha -= 0.005;
+		}
+	}
+};
\ No newline at end of file