Code edit (1 edits merged)
Please save this source code
User prompt
Powerpuff Potty Time
Initial prompt
Toca toilet time (2004). The powerpuff girls have done a wee wee or poo poo. Tap on the powerpuff girls to make a big wee or poop on the toilet before confetti falling 6 times. Tap on the soap to scrub the powerpuff girls’s hands, tap on the hands to rub, tap on the sink to wash their hands, tap on the towel to dry their hands.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Confetti = Container.expand(function () { var self = Container.call(this); var confettiGraphics = self.attachAsset('confetti', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.rotationSpeed = 0.2; self.update = function () { self.y += self.speed; self.rotation += self.rotationSpeed; if (self.y > 2732 + 50) { self.destroy(); var index = confettiPieces.indexOf(self); if (index > -1) { confettiPieces.splice(index, 1); } } }; return self; }); var PowerpuffGirl = Container.expand(function (girlType) { var self = Container.call(this); var girlGraphics = self.attachAsset(girlType, { anchorX: 0.5, anchorY: 0.5 }); self.girlType = girlType; self.isOnPotty = false; self.hasUsedPotty = false; self.hygienStep = 0; // 0=none, 1=soap, 2=scrub, 3=rinse, 4=dry self.down = function (x, y, obj) { if (gameState === 'potty' && !self.hasUsedPotty) { self.usePotty(); } else if (gameState === 'hygiene' && self.hasUsedPotty) { // Hygiene interactions handled by specific objects } }; self.usePotty = function () { if (!self.hasUsedPotty) { self.hasUsedPotty = true; self.isOnPotty = true; // Move to toilet position tween(self, { x: toilet.x, y: toilet.y - 50 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { LK.getSound('success').play(); LK.effects.flashObject(self, 0x00ff00, 500); // Check if all girls have used potty checkPottyCompletion(); } }); } }; self.moveToSink = function () { tween(self, { x: sink.x - 100, y: sink.y + 100 }, { duration: 800, easing: tween.easeOut }); }; return self; }); var SoapBubble = Container.expand(function () { var self = Container.call(this); var bubbleGraphics = self.attachAsset('soap', { anchorX: 0.5, anchorY: 0.5 }); self.lifetime = 0; self.maxLifetime = 120; // 2 seconds at 60fps self.update = function () { self.lifetime++; self.alpha = Math.max(0, 1 - self.lifetime / self.maxLifetime); if (self.lifetime >= self.maxLifetime) { self.destroy(); var index = soapBubbles.indexOf(self); if (index > -1) { soapBubbles.splice(index, 1); } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xe6f3ff }); /**** * Game Code ****/ // Sound effects // Effect assets // Powerpuff Girls assets // Bathroom scene assets // Game state variables var gameState = 'potty'; // 'potty', 'hygiene', 'complete' var confettiCount = 0; var maxConfetti = 6; var confettiPieces = []; var soapBubbles = []; var hygieneStep = 0; // 0=start, 1=soap, 2=scrub, 3=rinse, 4=dry var handsSoapy = false; var handsWet = false; // Create bathroom scene var bathroom = game.addChild(LK.getAsset('bathroom', { anchorX: 0, anchorY: 0, x: 0, y: 0 })); var toilet = game.addChild(LK.getAsset('toilet', { anchorX: 0.5, anchorY: 1, x: 1024, y: 1800 })); var sink = game.addChild(LK.getAsset('sink', { anchorX: 0.5, anchorY: 1, x: 1024, y: 1000 })); var mirror = game.addChild(LK.getAsset('mirror', { anchorX: 0.5, anchorY: 1, x: 1024, y: 700 })); var towel = game.addChild(LK.getAsset('towel', { anchorX: 0, anchorY: 0, x: 1400, y: 800 })); var soapDispenser = game.addChild(LK.getAsset('soapDispenser', { anchorX: 0.5, anchorY: 1, x: 800, y: 1000 })); // Create Powerpuff Girls var blossom = game.addChild(new PowerpuffGirl('blossom')); blossom.x = 500; blossom.y = 2200; var bubbles = game.addChild(new PowerpuffGirl('bubbles')); bubbles.x = 1024; bubbles.y = 2200; var buttercup = game.addChild(new PowerpuffGirl('buttercup')); buttercup.x = 1548; buttercup.y = 2200; var girls = [blossom, bubbles, buttercup]; // UI Elements var instructionText = new Text2('Tap the girls to help them use the potty!', { size: 80, fill: 0x333333 }); instructionText.anchor.set(0.5, 0); LK.gui.top.addChild(instructionText); var timerText = new Text2('Confetti: 0/6', { size: 60, fill: 0xFF0000 }); timerText.anchor.set(1, 0); LK.gui.topRight.addChild(timerText); // Timer for confetti drops var confettiTimer = LK.setInterval(function () { if (gameState === 'potty' && confettiCount < maxConfetti) { dropConfetti(); confettiCount++; timerText.setText('Confetti: ' + confettiCount + '/6'); if (confettiCount >= maxConfetti) { // Time's up! Game over checkGameOver(); } } }, 3000); // Every 3 seconds // Game interaction handlers game.down = function (x, y, obj) { if (gameState === 'hygiene') { // Check soap dispenser interaction if (soapDispenser.intersects({ x: x, y: y, width: 1, height: 1 })) { if (hygieneStep === 0) { useSoap(); } } // Check sink interaction if (sink.intersects({ x: x, y: y, width: 1, height: 1 })) { if (hygieneStep === 2 && handsSoapy) { rinseHands(); } } // Check towel interaction if (towel.intersects({ x: x, y: y, width: 1, height: 1 })) { if (hygieneStep === 3 && handsWet) { dryHands(); } } // Check hand scrubbing area if (x > 800 && x < 1300 && y > 1200 && y < 1600) { if (hygieneStep === 1 && handsSoapy) { scrubHands(); } } } }; function dropConfetti() { LK.getSound('timer').play(); for (var i = 0; i < 8; i++) { var confetti = new Confetti(); confetti.x = Math.random() * 2048; confetti.y = -50; confetti.tint = Math.random() * 0xffffff; confettiPieces.push(confetti); game.addChild(confetti); } } function checkPottyCompletion() { var allUsed = true; for (var i = 0; i < girls.length; i++) { if (!girls[i].hasUsedPotty) { allUsed = false; break; } } if (allUsed) { // All girls used potty successfully! LK.clearInterval(confettiTimer); gameState = 'hygiene'; startHygienePhase(); } } function startHygienePhase() { instructionText.setText('Now wash your hands! Tap the soap dispenser first.'); timerText.setText('Hygiene Steps: 1/4'); // Move girls to sink area for (var i = 0; i < girls.length; i++) { girls[i].moveToSink(); } } function useSoap() { if (hygieneStep === 0) { hygieneStep = 1; handsSoapy = true; instructionText.setText('Great! Now rub your hands together to scrub.'); timerText.setText('Hygiene Steps: 2/4'); LK.getSound('wash').play(); // Create soap bubbles effect for (var i = 0; i < 5; i++) { var bubble = new SoapBubble(); bubble.x = 800 + Math.random() * 400; bubble.y = 1300 + Math.random() * 200; soapBubbles.push(bubble); game.addChild(bubble); } } } function scrubHands() { if (hygieneStep === 1 && handsSoapy) { hygieneStep = 2; instructionText.setText('Good scrubbing! Now tap the sink to rinse.'); timerText.setText('Hygiene Steps: 3/4'); LK.getSound('wash').play(); } } function rinseHands() { if (hygieneStep === 2 && handsSoapy) { hygieneStep = 3; handsSoapy = false; handsWet = true; instructionText.setText('Almost done! Tap the towel to dry your hands.'); timerText.setText('Hygiene Steps: 4/4'); LK.getSound('wash').play(); // Water effect for (var i = 0; i < 8; i++) { var water = LK.getAsset('water', { anchorX: 0.5, anchorY: 0.5, x: sink.x + (Math.random() - 0.5) * 200, y: sink.y - 50 + Math.random() * 100 }); game.addChild(water); tween(water, { alpha: 0, y: water.y + 100 }, { duration: 1000, onFinish: function onFinish() { water.destroy(); } }); } } } function dryHands() { if (hygieneStep === 3 && handsWet) { hygieneStep = 4; handsWet = false; gameState = 'complete'; instructionText.setText('Excellent! You completed perfect potty time and hygiene!'); timerText.setText('COMPLETE!'); LK.getSound('success').play(); // Flash all girls green for (var i = 0; i < girls.length; i++) { LK.effects.flashObject(girls[i], 0x00ff00, 1000); } // Show victory after delay LK.setTimeout(function () { LK.showYouWin(); }, 2000); } } function checkGameOver() { var allUsed = true; for (var i = 0; i < girls.length; i++) { if (!girls[i].hasUsedPotty) { allUsed = false; break; } } if (!allUsed) { // Time ran out before all girls used potty instructionText.setText('Time\'s up! Try again to help all the girls!'); LK.setTimeout(function () { LK.showGameOver(); }, 1500); } } // Main game update loop game.update = function () { // Update confetti pieces for (var i = confettiPieces.length - 1; i >= 0; i--) { // Confetti pieces update themselves } // Update soap bubbles for (var i = soapBubbles.length - 1; i >= 0; i--) { // Soap bubbles update themselves } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,372 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Confetti = Container.expand(function () {
+ var self = Container.call(this);
+ var confettiGraphics = self.attachAsset('confetti', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.rotationSpeed = 0.2;
+ self.update = function () {
+ self.y += self.speed;
+ self.rotation += self.rotationSpeed;
+ if (self.y > 2732 + 50) {
+ self.destroy();
+ var index = confettiPieces.indexOf(self);
+ if (index > -1) {
+ confettiPieces.splice(index, 1);
+ }
+ }
+ };
+ return self;
+});
+var PowerpuffGirl = Container.expand(function (girlType) {
+ var self = Container.call(this);
+ var girlGraphics = self.attachAsset(girlType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.girlType = girlType;
+ self.isOnPotty = false;
+ self.hasUsedPotty = false;
+ self.hygienStep = 0; // 0=none, 1=soap, 2=scrub, 3=rinse, 4=dry
+ self.down = function (x, y, obj) {
+ if (gameState === 'potty' && !self.hasUsedPotty) {
+ self.usePotty();
+ } else if (gameState === 'hygiene' && self.hasUsedPotty) {
+ // Hygiene interactions handled by specific objects
+ }
+ };
+ self.usePotty = function () {
+ if (!self.hasUsedPotty) {
+ self.hasUsedPotty = true;
+ self.isOnPotty = true;
+ // Move to toilet position
+ tween(self, {
+ x: toilet.x,
+ y: toilet.y - 50
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ LK.getSound('success').play();
+ LK.effects.flashObject(self, 0x00ff00, 500);
+ // Check if all girls have used potty
+ checkPottyCompletion();
+ }
+ });
+ }
+ };
+ self.moveToSink = function () {
+ tween(self, {
+ x: sink.x - 100,
+ y: sink.y + 100
+ }, {
+ duration: 800,
+ easing: tween.easeOut
+ });
+ };
+ return self;
+});
+var SoapBubble = Container.expand(function () {
+ var self = Container.call(this);
+ var bubbleGraphics = self.attachAsset('soap', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.lifetime = 0;
+ self.maxLifetime = 120; // 2 seconds at 60fps
+ self.update = function () {
+ self.lifetime++;
+ self.alpha = Math.max(0, 1 - self.lifetime / self.maxLifetime);
+ if (self.lifetime >= self.maxLifetime) {
+ self.destroy();
+ var index = soapBubbles.indexOf(self);
+ if (index > -1) {
+ soapBubbles.splice(index, 1);
+ }
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xe6f3ff
+});
+
+/****
+* Game Code
+****/
+// Sound effects
+// Effect assets
+// Powerpuff Girls assets
+// Bathroom scene assets
+// Game state variables
+var gameState = 'potty'; // 'potty', 'hygiene', 'complete'
+var confettiCount = 0;
+var maxConfetti = 6;
+var confettiPieces = [];
+var soapBubbles = [];
+var hygieneStep = 0; // 0=start, 1=soap, 2=scrub, 3=rinse, 4=dry
+var handsSoapy = false;
+var handsWet = false;
+// Create bathroom scene
+var bathroom = game.addChild(LK.getAsset('bathroom', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0
+}));
+var toilet = game.addChild(LK.getAsset('toilet', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 1024,
+ y: 1800
+}));
+var sink = game.addChild(LK.getAsset('sink', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 1024,
+ y: 1000
+}));
+var mirror = game.addChild(LK.getAsset('mirror', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 1024,
+ y: 700
+}));
+var towel = game.addChild(LK.getAsset('towel', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 1400,
+ y: 800
+}));
+var soapDispenser = game.addChild(LK.getAsset('soapDispenser', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 800,
+ y: 1000
+}));
+// Create Powerpuff Girls
+var blossom = game.addChild(new PowerpuffGirl('blossom'));
+blossom.x = 500;
+blossom.y = 2200;
+var bubbles = game.addChild(new PowerpuffGirl('bubbles'));
+bubbles.x = 1024;
+bubbles.y = 2200;
+var buttercup = game.addChild(new PowerpuffGirl('buttercup'));
+buttercup.x = 1548;
+buttercup.y = 2200;
+var girls = [blossom, bubbles, buttercup];
+// UI Elements
+var instructionText = new Text2('Tap the girls to help them use the potty!', {
+ size: 80,
+ fill: 0x333333
+});
+instructionText.anchor.set(0.5, 0);
+LK.gui.top.addChild(instructionText);
+var timerText = new Text2('Confetti: 0/6', {
+ size: 60,
+ fill: 0xFF0000
+});
+timerText.anchor.set(1, 0);
+LK.gui.topRight.addChild(timerText);
+// Timer for confetti drops
+var confettiTimer = LK.setInterval(function () {
+ if (gameState === 'potty' && confettiCount < maxConfetti) {
+ dropConfetti();
+ confettiCount++;
+ timerText.setText('Confetti: ' + confettiCount + '/6');
+ if (confettiCount >= maxConfetti) {
+ // Time's up! Game over
+ checkGameOver();
+ }
+ }
+}, 3000); // Every 3 seconds
+// Game interaction handlers
+game.down = function (x, y, obj) {
+ if (gameState === 'hygiene') {
+ // Check soap dispenser interaction
+ if (soapDispenser.intersects({
+ x: x,
+ y: y,
+ width: 1,
+ height: 1
+ })) {
+ if (hygieneStep === 0) {
+ useSoap();
+ }
+ }
+ // Check sink interaction
+ if (sink.intersects({
+ x: x,
+ y: y,
+ width: 1,
+ height: 1
+ })) {
+ if (hygieneStep === 2 && handsSoapy) {
+ rinseHands();
+ }
+ }
+ // Check towel interaction
+ if (towel.intersects({
+ x: x,
+ y: y,
+ width: 1,
+ height: 1
+ })) {
+ if (hygieneStep === 3 && handsWet) {
+ dryHands();
+ }
+ }
+ // Check hand scrubbing area
+ if (x > 800 && x < 1300 && y > 1200 && y < 1600) {
+ if (hygieneStep === 1 && handsSoapy) {
+ scrubHands();
+ }
+ }
+ }
+};
+function dropConfetti() {
+ LK.getSound('timer').play();
+ for (var i = 0; i < 8; i++) {
+ var confetti = new Confetti();
+ confetti.x = Math.random() * 2048;
+ confetti.y = -50;
+ confetti.tint = Math.random() * 0xffffff;
+ confettiPieces.push(confetti);
+ game.addChild(confetti);
+ }
+}
+function checkPottyCompletion() {
+ var allUsed = true;
+ for (var i = 0; i < girls.length; i++) {
+ if (!girls[i].hasUsedPotty) {
+ allUsed = false;
+ break;
+ }
+ }
+ if (allUsed) {
+ // All girls used potty successfully!
+ LK.clearInterval(confettiTimer);
+ gameState = 'hygiene';
+ startHygienePhase();
+ }
+}
+function startHygienePhase() {
+ instructionText.setText('Now wash your hands! Tap the soap dispenser first.');
+ timerText.setText('Hygiene Steps: 1/4');
+ // Move girls to sink area
+ for (var i = 0; i < girls.length; i++) {
+ girls[i].moveToSink();
+ }
+}
+function useSoap() {
+ if (hygieneStep === 0) {
+ hygieneStep = 1;
+ handsSoapy = true;
+ instructionText.setText('Great! Now rub your hands together to scrub.');
+ timerText.setText('Hygiene Steps: 2/4');
+ LK.getSound('wash').play();
+ // Create soap bubbles effect
+ for (var i = 0; i < 5; i++) {
+ var bubble = new SoapBubble();
+ bubble.x = 800 + Math.random() * 400;
+ bubble.y = 1300 + Math.random() * 200;
+ soapBubbles.push(bubble);
+ game.addChild(bubble);
+ }
+ }
+}
+function scrubHands() {
+ if (hygieneStep === 1 && handsSoapy) {
+ hygieneStep = 2;
+ instructionText.setText('Good scrubbing! Now tap the sink to rinse.');
+ timerText.setText('Hygiene Steps: 3/4');
+ LK.getSound('wash').play();
+ }
+}
+function rinseHands() {
+ if (hygieneStep === 2 && handsSoapy) {
+ hygieneStep = 3;
+ handsSoapy = false;
+ handsWet = true;
+ instructionText.setText('Almost done! Tap the towel to dry your hands.');
+ timerText.setText('Hygiene Steps: 4/4');
+ LK.getSound('wash').play();
+ // Water effect
+ for (var i = 0; i < 8; i++) {
+ var water = LK.getAsset('water', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: sink.x + (Math.random() - 0.5) * 200,
+ y: sink.y - 50 + Math.random() * 100
+ });
+ game.addChild(water);
+ tween(water, {
+ alpha: 0,
+ y: water.y + 100
+ }, {
+ duration: 1000,
+ onFinish: function onFinish() {
+ water.destroy();
+ }
+ });
+ }
+ }
+}
+function dryHands() {
+ if (hygieneStep === 3 && handsWet) {
+ hygieneStep = 4;
+ handsWet = false;
+ gameState = 'complete';
+ instructionText.setText('Excellent! You completed perfect potty time and hygiene!');
+ timerText.setText('COMPLETE!');
+ LK.getSound('success').play();
+ // Flash all girls green
+ for (var i = 0; i < girls.length; i++) {
+ LK.effects.flashObject(girls[i], 0x00ff00, 1000);
+ }
+ // Show victory after delay
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 2000);
+ }
+}
+function checkGameOver() {
+ var allUsed = true;
+ for (var i = 0; i < girls.length; i++) {
+ if (!girls[i].hasUsedPotty) {
+ allUsed = false;
+ break;
+ }
+ }
+ if (!allUsed) {
+ // Time ran out before all girls used potty
+ instructionText.setText('Time\'s up! Try again to help all the girls!');
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 1500);
+ }
+}
+// Main game update loop
+game.update = function () {
+ // Update confetti pieces
+ for (var i = confettiPieces.length - 1; i >= 0; i--) {
+ // Confetti pieces update themselves
+ }
+ // Update soap bubbles
+ for (var i = soapBubbles.length - 1; i >= 0; i--) {
+ // Soap bubbles update themselves
+ }
+};
\ No newline at end of file