Code edit (1 edits merged)
Please save this source code
User prompt
Powerpuff Bedtime Adventure
Initial prompt
Toca seeing Santa (2012). Tap to find blossom 🩷 bubbles 💙 and buttercup 💚 to make them say shhh, it’s bedtime for the powerpuff girls tap on them to make them go zzzzz, the sun is out use your finger to drag the 3 coloured gifts onto the matching powerpuff girls, tap on 3 gifts to make them open, it is kite on blossom’s gift, it is a toy car on buttercup’s gift, and it is a doll on bubbles’s gift
/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
/**** 
* Classes
****/ 
var Gift = Container.expand(function (color, giftType, toyType) {
	var self = Container.call(this);
	var giftGraphics = self.attachAsset(giftType, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.color = color;
	self.toyType = toyType;
	self.isOpened = false;
	self.assignedGirl = null;
	self.originalX = 0;
	self.originalY = 0;
	self.isDragging = false;
	self.down = function (x, y, obj) {
		if (!self.assignedGirl) {
			self.isDragging = true;
			dragGift = self;
		} else if (!self.isOpened) {
			// Open gift
			self.openGift();
		}
	};
	self.openGift = function () {
		if (self.isOpened || !self.assignedGirl) return;
		self.isOpened = true;
		LK.getSound('giftOpen').play();
		// Hide gift and show toy
		tween(giftGraphics, {
			alpha: 0,
			scaleX: 0.1,
			scaleY: 0.1
		}, {
			duration: 300,
			onFinish: function onFinish() {
				var toy = self.attachAsset(self.toyType, {
					anchorX: 0.5,
					anchorY: 0.5,
					alpha: 0,
					scaleX: 0.1,
					scaleY: 0.1
				});
				tween(toy, {
					alpha: 1,
					scaleX: 1,
					scaleY: 1
				}, {
					duration: 500
				});
			}
		});
		self.assignedGirl.giftOpened = true;
		checkGameComplete();
	};
	return self;
});
var PowerpuffGirl = Container.expand(function (name, color, sleepState) {
	var self = Container.call(this);
	var characterGraphics = self.attachAsset(name, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.sleepState = sleepState || 'awake'; // 'awake', 'shhh', 'sleeping'
	self.name = name;
	self.color = color;
	self.hasGift = false;
	self.giftOpened = false;
	// Text for sleep states
	var sleepText = new Text2('', {
		size: 80,
		fill: 0xFFFFFF
	});
	sleepText.anchor.set(0.5, 0.5);
	sleepText.y = -250;
	self.addChild(sleepText);
	self.sleepText = sleepText;
	self.updateSleepText = function () {
		if (self.sleepState === 'shhh') {
			self.sleepText.setText('shhh...');
		} else if (self.sleepState === 'sleeping') {
			self.sleepText.setText('zzzzz');
		} else {
			self.sleepText.setText('');
		}
	};
	self.down = function (x, y, obj) {
		if (self.sleepState === 'awake') {
			self.sleepState = 'shhh';
			self.updateSleepText();
			LK.getSound('shhh').play();
			// Dim the character slightly
			tween(characterGraphics, {
				alpha: 0.8
			}, {
				duration: 500
			});
		} else if (self.sleepState === 'shhh') {
			self.sleepState = 'sleeping';
			self.updateSleepText();
			LK.getSound('zzz').play();
			// Dim the character more
			tween(characterGraphics, {
				alpha: 0.6
			}, {
				duration: 500
			});
		}
		checkGameComplete();
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB // Sky blue for daytime
});
/**** 
* Game Code
****/ 
// Sounds
// Toys revealed from gifts
// Gifts
// Powerpuff Girls characters
// Game state variables
var blossom, bubbles, buttercup;
var pinkGift, blueGift, greenGift;
var dragGift = null;
var gameComplete = false;
// Create Powerpuff Girls
blossom = game.addChild(new PowerpuffGirl('blossom', 0xFF69B4, 'awake'));
blossom.x = 2048 / 4;
blossom.y = 2732 / 2 - 200;
bubbles = game.addChild(new PowerpuffGirl('bubbles', 0x87CEEB, 'awake'));
bubbles.x = 2048 / 2;
bubbles.y = 2732 / 2 - 200;
buttercup = game.addChild(new PowerpuffGirl('buttercup', 0x90EE90, 'awake'));
buttercup.x = 3 * 2048 / 4;
buttercup.y = 2732 / 2 - 200;
// Create gifts at bottom of screen
pinkGift = game.addChild(new Gift(0xFF69B4, 'pinkGift', 'kite'));
pinkGift.x = 2048 / 4;
pinkGift.y = 2732 - 300;
pinkGift.originalX = pinkGift.x;
pinkGift.originalY = pinkGift.y;
blueGift = game.addChild(new Gift(0x87CEEB, 'blueGift', 'doll'));
blueGift.x = 2048 / 2;
blueGift.y = 2732 - 300;
blueGift.originalX = blueGift.x;
blueGift.originalY = blueGift.y;
greenGift = game.addChild(new Gift(0x90EE90, 'greenGift', 'toycar'));
greenGift.x = 3 * 2048 / 4;
greenGift.y = 2732 - 300;
greenGift.originalX = greenGift.x;
greenGift.originalY = greenGift.y;
// Instructions text
var instructionText = new Text2('Tap the girls to put them to sleep, then drag gifts to match colors!', {
	size: 60,
	fill: 0x000000
});
instructionText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionText);
instructionText.y = 100;
function checkGameComplete() {
	// Check if all girls are sleeping and all gifts are opened
	var allSleeping = blossom.sleepState === 'sleeping' && bubbles.sleepState === 'sleeping' && buttercup.sleepState === 'sleeping';
	var allGiftsOpened = blossom.giftOpened && bubbles.giftOpened && buttercup.giftOpened;
	if (allSleeping && allGiftsOpened && !gameComplete) {
		gameComplete = true;
		// Transition to night time
		tween(game, {
			backgroundColor: 0x191970
		}, {
			duration: 2000
		});
		instructionText.setText('Sweet dreams! Bedtime complete!');
		// Show completion after a delay
		LK.setTimeout(function () {
			LK.showYouWin();
		}, 3000);
	}
}
function checkGiftPlacement(gift) {
	var targetGirl = null;
	// Check which girl the gift is closest to
	if (gift.intersects(blossom)) {
		targetGirl = blossom;
	} else if (gift.intersects(bubbles)) {
		targetGirl = bubbles;
	} else if (gift.intersects(buttercup)) {
		targetGirl = buttercup;
	}
	if (targetGirl && targetGirl.color === gift.color && !targetGirl.hasGift) {
		// Correct match!
		gift.assignedGirl = targetGirl;
		targetGirl.hasGift = true;
		// Position gift near the girl
		tween(gift, {
			x: targetGirl.x,
			y: targetGirl.y + 300
		}, {
			duration: 300
		});
		return true;
	}
	return false;
}
game.move = function (x, y, obj) {
	if (dragGift) {
		dragGift.x = x;
		dragGift.y = y;
	}
};
game.up = function (x, y, obj) {
	if (dragGift) {
		var placed = checkGiftPlacement(dragGift);
		if (!placed) {
			// Return to original position
			tween(dragGift, {
				x: dragGift.originalX,
				y: dragGift.originalY
			}, {
				duration: 500
			});
		}
		dragGift.isDragging = false;
		dragGift = null;
	}
};
game.update = function () {
	// Game runs smoothly with automatic updates from classes
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,241 @@
-/****
+/**** 
+* Plugins
+****/ 
+var tween = LK.import("@upit/tween.v1");
+
+/**** 
+* Classes
+****/ 
+var Gift = Container.expand(function (color, giftType, toyType) {
+	var self = Container.call(this);
+	var giftGraphics = self.attachAsset(giftType, {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	self.color = color;
+	self.toyType = toyType;
+	self.isOpened = false;
+	self.assignedGirl = null;
+	self.originalX = 0;
+	self.originalY = 0;
+	self.isDragging = false;
+	self.down = function (x, y, obj) {
+		if (!self.assignedGirl) {
+			self.isDragging = true;
+			dragGift = self;
+		} else if (!self.isOpened) {
+			// Open gift
+			self.openGift();
+		}
+	};
+	self.openGift = function () {
+		if (self.isOpened || !self.assignedGirl) return;
+		self.isOpened = true;
+		LK.getSound('giftOpen').play();
+		// Hide gift and show toy
+		tween(giftGraphics, {
+			alpha: 0,
+			scaleX: 0.1,
+			scaleY: 0.1
+		}, {
+			duration: 300,
+			onFinish: function onFinish() {
+				var toy = self.attachAsset(self.toyType, {
+					anchorX: 0.5,
+					anchorY: 0.5,
+					alpha: 0,
+					scaleX: 0.1,
+					scaleY: 0.1
+				});
+				tween(toy, {
+					alpha: 1,
+					scaleX: 1,
+					scaleY: 1
+				}, {
+					duration: 500
+				});
+			}
+		});
+		self.assignedGirl.giftOpened = true;
+		checkGameComplete();
+	};
+	return self;
+});
+var PowerpuffGirl = Container.expand(function (name, color, sleepState) {
+	var self = Container.call(this);
+	var characterGraphics = self.attachAsset(name, {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	self.sleepState = sleepState || 'awake'; // 'awake', 'shhh', 'sleeping'
+	self.name = name;
+	self.color = color;
+	self.hasGift = false;
+	self.giftOpened = false;
+	// Text for sleep states
+	var sleepText = new Text2('', {
+		size: 80,
+		fill: 0xFFFFFF
+	});
+	sleepText.anchor.set(0.5, 0.5);
+	sleepText.y = -250;
+	self.addChild(sleepText);
+	self.sleepText = sleepText;
+	self.updateSleepText = function () {
+		if (self.sleepState === 'shhh') {
+			self.sleepText.setText('shhh...');
+		} else if (self.sleepState === 'sleeping') {
+			self.sleepText.setText('zzzzz');
+		} else {
+			self.sleepText.setText('');
+		}
+	};
+	self.down = function (x, y, obj) {
+		if (self.sleepState === 'awake') {
+			self.sleepState = 'shhh';
+			self.updateSleepText();
+			LK.getSound('shhh').play();
+			// Dim the character slightly
+			tween(characterGraphics, {
+				alpha: 0.8
+			}, {
+				duration: 500
+			});
+		} else if (self.sleepState === 'shhh') {
+			self.sleepState = 'sleeping';
+			self.updateSleepText();
+			LK.getSound('zzz').play();
+			// Dim the character more
+			tween(characterGraphics, {
+				alpha: 0.6
+			}, {
+				duration: 500
+			});
+		}
+		checkGameComplete();
+	};
+	return self;
+});
+
+/**** 
 * Initialize Game
-****/
+****/ 
 var game = new LK.Game({
-	backgroundColor: 0x000000
-});
\ No newline at end of file
+	backgroundColor: 0x87CEEB // Sky blue for daytime
+});
+
+/**** 
+* Game Code
+****/ 
+// Sounds
+// Toys revealed from gifts
+// Gifts
+// Powerpuff Girls characters
+// Game state variables
+var blossom, bubbles, buttercup;
+var pinkGift, blueGift, greenGift;
+var dragGift = null;
+var gameComplete = false;
+// Create Powerpuff Girls
+blossom = game.addChild(new PowerpuffGirl('blossom', 0xFF69B4, 'awake'));
+blossom.x = 2048 / 4;
+blossom.y = 2732 / 2 - 200;
+bubbles = game.addChild(new PowerpuffGirl('bubbles', 0x87CEEB, 'awake'));
+bubbles.x = 2048 / 2;
+bubbles.y = 2732 / 2 - 200;
+buttercup = game.addChild(new PowerpuffGirl('buttercup', 0x90EE90, 'awake'));
+buttercup.x = 3 * 2048 / 4;
+buttercup.y = 2732 / 2 - 200;
+// Create gifts at bottom of screen
+pinkGift = game.addChild(new Gift(0xFF69B4, 'pinkGift', 'kite'));
+pinkGift.x = 2048 / 4;
+pinkGift.y = 2732 - 300;
+pinkGift.originalX = pinkGift.x;
+pinkGift.originalY = pinkGift.y;
+blueGift = game.addChild(new Gift(0x87CEEB, 'blueGift', 'doll'));
+blueGift.x = 2048 / 2;
+blueGift.y = 2732 - 300;
+blueGift.originalX = blueGift.x;
+blueGift.originalY = blueGift.y;
+greenGift = game.addChild(new Gift(0x90EE90, 'greenGift', 'toycar'));
+greenGift.x = 3 * 2048 / 4;
+greenGift.y = 2732 - 300;
+greenGift.originalX = greenGift.x;
+greenGift.originalY = greenGift.y;
+// Instructions text
+var instructionText = new Text2('Tap the girls to put them to sleep, then drag gifts to match colors!', {
+	size: 60,
+	fill: 0x000000
+});
+instructionText.anchor.set(0.5, 0);
+LK.gui.top.addChild(instructionText);
+instructionText.y = 100;
+function checkGameComplete() {
+	// Check if all girls are sleeping and all gifts are opened
+	var allSleeping = blossom.sleepState === 'sleeping' && bubbles.sleepState === 'sleeping' && buttercup.sleepState === 'sleeping';
+	var allGiftsOpened = blossom.giftOpened && bubbles.giftOpened && buttercup.giftOpened;
+	if (allSleeping && allGiftsOpened && !gameComplete) {
+		gameComplete = true;
+		// Transition to night time
+		tween(game, {
+			backgroundColor: 0x191970
+		}, {
+			duration: 2000
+		});
+		instructionText.setText('Sweet dreams! Bedtime complete!');
+		// Show completion after a delay
+		LK.setTimeout(function () {
+			LK.showYouWin();
+		}, 3000);
+	}
+}
+function checkGiftPlacement(gift) {
+	var targetGirl = null;
+	// Check which girl the gift is closest to
+	if (gift.intersects(blossom)) {
+		targetGirl = blossom;
+	} else if (gift.intersects(bubbles)) {
+		targetGirl = bubbles;
+	} else if (gift.intersects(buttercup)) {
+		targetGirl = buttercup;
+	}
+	if (targetGirl && targetGirl.color === gift.color && !targetGirl.hasGift) {
+		// Correct match!
+		gift.assignedGirl = targetGirl;
+		targetGirl.hasGift = true;
+		// Position gift near the girl
+		tween(gift, {
+			x: targetGirl.x,
+			y: targetGirl.y + 300
+		}, {
+			duration: 300
+		});
+		return true;
+	}
+	return false;
+}
+game.move = function (x, y, obj) {
+	if (dragGift) {
+		dragGift.x = x;
+		dragGift.y = y;
+	}
+};
+game.up = function (x, y, obj) {
+	if (dragGift) {
+		var placed = checkGiftPlacement(dragGift);
+		if (!placed) {
+			// Return to original position
+			tween(dragGift, {
+				x: dragGift.originalX,
+				y: dragGift.originalY
+			}, {
+				duration: 500
+			});
+		}
+		dragGift.isDragging = false;
+		dragGift = null;
+	}
+};
+game.update = function () {
+	// Game runs smoothly with automatic updates from classes
+};
\ No newline at end of file