Code edit (1 edits merged)
Please save this source code
User prompt
Powerpuff Factory Adventures
Initial prompt
Toca factory (2009-2021). Choose a powerpuff girl from the wheel you want to play as, every day a different powerpuff girl will be transformed into a gingerbread man, bell, pudding, or a gift, tap online to tell me who be getting ready in the factory
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var FactoryStation = Container.expand(function (stationType) { var self = Container.call(this); var station = self.attachAsset('factoryStation', { anchorX: 0.5, anchorY: 0.5 }); if (stationType === 'mixer') { var mixer = self.attachAsset('mixer', { anchorX: 0.5, anchorY: 0.5, y: -20 }); self.mixer = mixer; } else if (stationType === 'oven') { var oven = self.attachAsset('oven', { anchorX: 0.5, anchorY: 0.5, y: -20 }); self.oven = oven; } self.stationType = stationType; self.active = false; self.completed = false; self.activate = function () { if (self.completed) return; self.active = true; LK.getSound('factorySound').play(); if (self.mixer) { tween(self.mixer, { rotation: self.mixer.rotation + Math.PI * 4 }, { duration: 2000, easing: tween.linear, onFinish: function onFinish() { self.completed = true; self.active = false; stationProgress++; } }); } else if (self.oven) { tween(station, { tint: 0xFF4500 }, { duration: 1000 }); LK.setTimeout(function () { tween(station, { tint: 0xFFFFFF }, { duration: 1000 }); self.completed = true; self.active = false; stationProgress++; }, 2000); } else { LK.setTimeout(function () { self.completed = true; self.active = false; stationProgress++; }, 1500); } }; self.down = function (x, y, obj) { if (!self.completed && !self.active && characterSelected && currentCharacter) { self.activate(); } }; return self; }); var PowerpuffCharacter = Container.expand(function (characterType) { var self = Container.call(this); var character = self.attachAsset(characterType, { anchorX: 0.5, anchorY: 0.5 }); self.characterType = characterType; self.transformProgress = 0; self.moveToPosition = function (targetX, targetY, duration) { tween(self, { x: targetX, y: targetY }, { duration: duration || 1000, easing: tween.easeInOut }); }; self.transform = function (targetType) { LK.getSound('transform').play(); // Visual transformation effect tween(character, { scaleX: 1.5, scaleY: 1.5 }, { duration: 500 }); tween(character, { alpha: 0.5 }, { duration: 500, onFinish: function onFinish() { // Replace with target asset self.removeChild(character); character = self.attachAsset(targetType, { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5, alpha: 0.5 }); tween(character, { scaleX: 1, scaleY: 1, alpha: 1 }, { duration: 500 }); } }); }; return self; }); var SpinWheel = Container.expand(function () { var self = Container.call(this); var background = self.attachAsset('wheelBackground', { anchorX: 0.5, anchorY: 0.5 }); var section1 = self.attachAsset('wheelSection1', { anchorX: 0.5, anchorY: 0.5, x: -80, y: -80 }); var section2 = self.attachAsset('wheelSection2', { anchorX: 0.5, anchorY: 0.5, x: 80, y: -80 }); var section3 = self.attachAsset('wheelSection3', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 80 }); // Character labels var blossomText = new Text2('Blossom', { size: 24, fill: '#FFFFFF' }); blossomText.anchor.set(0.5, 0.5); blossomText.x = -80; blossomText.y = -80; self.addChild(blossomText); var bubblesText = new Text2('Bubbles', { size: 24, fill: '#FFFFFF' }); bubblesText.anchor.set(0.5, 0.5); bubblesText.x = 80; bubblesText.y = -80; self.addChild(bubblesText); var buttercupText = new Text2('Buttercup', { size: 24, fill: '#FFFFFF' }); buttercupText.anchor.set(0.5, 0.5); buttercupText.x = 0; buttercupText.y = 80; self.addChild(buttercupText); self.spinning = false; self.selectedCharacter = null; self.spin = function () { if (self.spinning) return; self.spinning = true; LK.getSound('wheelSpin').play(); var randomRotation = Math.PI * 4 + Math.random() * Math.PI * 2; tween(self, { rotation: self.rotation + randomRotation }, { duration: 2000, easing: tween.easeOut, onFinish: function onFinish() { self.spinning = false; var normalizedRotation = (self.rotation % (Math.PI * 2) + Math.PI * 2) % (Math.PI * 2); if (normalizedRotation < Math.PI * 2 / 3) { self.selectedCharacter = 'blossom'; } else if (normalizedRotation < Math.PI * 4 / 3) { self.selectedCharacter = 'bubbles'; } else { self.selectedCharacter = 'buttercup'; } characterSelected = true; } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Sounds // UI elements // Daily transformation targets // Factory elements // Powerpuff Girls // Character wheel assets // Game state variables var gamePhase = 'selection'; // 'selection', 'factory', 'complete' var characterSelected = false; var currentCharacter = null; var wheel = null; var spinButton = null; var conveyorBelt = null; var stations = []; var stationProgress = 0; var totalStations = 3; var transformationProgress = 0; // Daily themes var dailyThemes = ['gingerbread', 'bell', 'pudding', 'gift']; var currentTheme = dailyThemes[Math.floor(Math.random() * dailyThemes.length)]; // UI elements var titleText = new Text2('Powerpuff Factory Adventures', { size: 60, fill: '#FF1493' }); titleText.anchor.set(0.5, 0); LK.gui.top.addChild(titleText); var instructionText = new Text2('Spin the wheel to choose your Powerpuff Girl!', { size: 40, fill: '#FFFFFF' }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 1000; game.addChild(instructionText); var progressBarBg = LK.getAsset('progressBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 200 }); var progressBar = LK.getAsset('progressBar', { anchorX: 0, anchorY: 0.5, x: 824, y: 200, scaleX: 0 }); LK.gui.addChild(progressBarBg); LK.gui.addChild(progressBar); // Create spin wheel wheel = game.addChild(new SpinWheel()); wheel.x = 1024; wheel.y = 1366; // Create spin button spinButton = LK.getAsset('spinButton', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1800 }); game.addChild(spinButton); var spinButtonText = new Text2('SPIN!', { size: 36, fill: '#000000' }); spinButtonText.anchor.set(0.5, 0.5); spinButtonText.x = 1024; spinButtonText.y = 1800; game.addChild(spinButtonText); function initializeFactory() { gamePhase = 'factory'; // Hide wheel and button wheel.visible = false; spinButton.visible = false; spinButtonText.visible = false; instructionText.setText('Tap the factory stations to transform your character!'); // Create conveyor belt conveyorBelt = LK.getAsset('conveyorBelt', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 2000 }); game.addChild(conveyorBelt); // Create factory stations var stationTypes = ['mixer', 'oven', 'normal']; for (var i = 0; i < totalStations; i++) { var station = new FactoryStation(stationTypes[i % stationTypes.length]); station.x = 400 + i * 600; station.y = 1800; stations.push(station); game.addChild(station); } // Create character currentCharacter = new PowerpuffCharacter(wheel.selectedCharacter); currentCharacter.x = 200; currentCharacter.y = 1800; game.addChild(currentCharacter); // Move character along conveyor currentCharacter.moveToPosition(stations[0].x, stations[0].y + 100, 2000); } function updateProgress() { var progress = stationProgress / totalStations; tween(progressBar, { scaleX: progress }, { duration: 500 }); if (progress >= 1) { completeTransformation(); } } function completeTransformation() { gamePhase = 'complete'; instructionText.setText('Transformation Complete! Today\'s theme: ' + currentTheme); // Transform character to daily theme currentCharacter.transform(currentTheme); LK.setTimeout(function () { LK.setScore(LK.getScore() + 100); LK.showYouWin(); }, 2000); } // Event handlers spinButton.down = function (x, y, obj) { if (gamePhase === 'selection' && !wheel.spinning) { wheel.spin(); } }; game.update = function () { if (characterSelected && gamePhase === 'selection') { LK.setTimeout(function () { initializeFactory(); }, 1000); characterSelected = false; // Prevent multiple calls } if (gamePhase === 'factory') { // Update progress var currentProgress = stationProgress / totalStations; if (Math.abs(progressBar.scaleX - currentProgress) > 0.01) { updateProgress(); } // Move character to next station when current completes if (stationProgress > 0 && stationProgress <= totalStations && currentCharacter) { var nextStationIndex = Math.min(stationProgress, totalStations - 1); if (stations[nextStationIndex] && !stations[nextStationIndex].active) { currentCharacter.moveToPosition(stations[nextStationIndex].x, stations[nextStationIndex].y + 100, 1000); } } } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,371 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var FactoryStation = Container.expand(function (stationType) {
+ var self = Container.call(this);
+ var station = self.attachAsset('factoryStation', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ if (stationType === 'mixer') {
+ var mixer = self.attachAsset('mixer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -20
+ });
+ self.mixer = mixer;
+ } else if (stationType === 'oven') {
+ var oven = self.attachAsset('oven', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -20
+ });
+ self.oven = oven;
+ }
+ self.stationType = stationType;
+ self.active = false;
+ self.completed = false;
+ self.activate = function () {
+ if (self.completed) return;
+ self.active = true;
+ LK.getSound('factorySound').play();
+ if (self.mixer) {
+ tween(self.mixer, {
+ rotation: self.mixer.rotation + Math.PI * 4
+ }, {
+ duration: 2000,
+ easing: tween.linear,
+ onFinish: function onFinish() {
+ self.completed = true;
+ self.active = false;
+ stationProgress++;
+ }
+ });
+ } else if (self.oven) {
+ tween(station, {
+ tint: 0xFF4500
+ }, {
+ duration: 1000
+ });
+ LK.setTimeout(function () {
+ tween(station, {
+ tint: 0xFFFFFF
+ }, {
+ duration: 1000
+ });
+ self.completed = true;
+ self.active = false;
+ stationProgress++;
+ }, 2000);
+ } else {
+ LK.setTimeout(function () {
+ self.completed = true;
+ self.active = false;
+ stationProgress++;
+ }, 1500);
+ }
+ };
+ self.down = function (x, y, obj) {
+ if (!self.completed && !self.active && characterSelected && currentCharacter) {
+ self.activate();
+ }
+ };
+ return self;
+});
+var PowerpuffCharacter = Container.expand(function (characterType) {
+ var self = Container.call(this);
+ var character = self.attachAsset(characterType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.characterType = characterType;
+ self.transformProgress = 0;
+ self.moveToPosition = function (targetX, targetY, duration) {
+ tween(self, {
+ x: targetX,
+ y: targetY
+ }, {
+ duration: duration || 1000,
+ easing: tween.easeInOut
+ });
+ };
+ self.transform = function (targetType) {
+ LK.getSound('transform').play();
+ // Visual transformation effect
+ tween(character, {
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 500
+ });
+ tween(character, {
+ alpha: 0.5
+ }, {
+ duration: 500,
+ onFinish: function onFinish() {
+ // Replace with target asset
+ self.removeChild(character);
+ character = self.attachAsset(targetType, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 0.5
+ });
+ tween(character, {
+ scaleX: 1,
+ scaleY: 1,
+ alpha: 1
+ }, {
+ duration: 500
+ });
+ }
+ });
+ };
+ return self;
+});
+var SpinWheel = Container.expand(function () {
+ var self = Container.call(this);
+ var background = self.attachAsset('wheelBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var section1 = self.attachAsset('wheelSection1', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -80,
+ y: -80
+ });
+ var section2 = self.attachAsset('wheelSection2', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 80,
+ y: -80
+ });
+ var section3 = self.attachAsset('wheelSection3', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: 80
+ });
+ // Character labels
+ var blossomText = new Text2('Blossom', {
+ size: 24,
+ fill: '#FFFFFF'
+ });
+ blossomText.anchor.set(0.5, 0.5);
+ blossomText.x = -80;
+ blossomText.y = -80;
+ self.addChild(blossomText);
+ var bubblesText = new Text2('Bubbles', {
+ size: 24,
+ fill: '#FFFFFF'
+ });
+ bubblesText.anchor.set(0.5, 0.5);
+ bubblesText.x = 80;
+ bubblesText.y = -80;
+ self.addChild(bubblesText);
+ var buttercupText = new Text2('Buttercup', {
+ size: 24,
+ fill: '#FFFFFF'
+ });
+ buttercupText.anchor.set(0.5, 0.5);
+ buttercupText.x = 0;
+ buttercupText.y = 80;
+ self.addChild(buttercupText);
+ self.spinning = false;
+ self.selectedCharacter = null;
+ self.spin = function () {
+ if (self.spinning) return;
+ self.spinning = true;
+ LK.getSound('wheelSpin').play();
+ var randomRotation = Math.PI * 4 + Math.random() * Math.PI * 2;
+ tween(self, {
+ rotation: self.rotation + randomRotation
+ }, {
+ duration: 2000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.spinning = false;
+ var normalizedRotation = (self.rotation % (Math.PI * 2) + Math.PI * 2) % (Math.PI * 2);
+ if (normalizedRotation < Math.PI * 2 / 3) {
+ self.selectedCharacter = 'blossom';
+ } else if (normalizedRotation < Math.PI * 4 / 3) {
+ self.selectedCharacter = 'bubbles';
+ } else {
+ self.selectedCharacter = 'buttercup';
+ }
+ characterSelected = true;
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+// Sounds
+// UI elements
+// Daily transformation targets
+// Factory elements
+// Powerpuff Girls
+// Character wheel assets
+// Game state variables
+var gamePhase = 'selection'; // 'selection', 'factory', 'complete'
+var characterSelected = false;
+var currentCharacter = null;
+var wheel = null;
+var spinButton = null;
+var conveyorBelt = null;
+var stations = [];
+var stationProgress = 0;
+var totalStations = 3;
+var transformationProgress = 0;
+// Daily themes
+var dailyThemes = ['gingerbread', 'bell', 'pudding', 'gift'];
+var currentTheme = dailyThemes[Math.floor(Math.random() * dailyThemes.length)];
+// UI elements
+var titleText = new Text2('Powerpuff Factory Adventures', {
+ size: 60,
+ fill: '#FF1493'
+});
+titleText.anchor.set(0.5, 0);
+LK.gui.top.addChild(titleText);
+var instructionText = new Text2('Spin the wheel to choose your Powerpuff Girl!', {
+ size: 40,
+ fill: '#FFFFFF'
+});
+instructionText.anchor.set(0.5, 0.5);
+instructionText.x = 1024;
+instructionText.y = 1000;
+game.addChild(instructionText);
+var progressBarBg = LK.getAsset('progressBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 200
+});
+var progressBar = LK.getAsset('progressBar', {
+ anchorX: 0,
+ anchorY: 0.5,
+ x: 824,
+ y: 200,
+ scaleX: 0
+});
+LK.gui.addChild(progressBarBg);
+LK.gui.addChild(progressBar);
+// Create spin wheel
+wheel = game.addChild(new SpinWheel());
+wheel.x = 1024;
+wheel.y = 1366;
+// Create spin button
+spinButton = LK.getAsset('spinButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1800
+});
+game.addChild(spinButton);
+var spinButtonText = new Text2('SPIN!', {
+ size: 36,
+ fill: '#000000'
+});
+spinButtonText.anchor.set(0.5, 0.5);
+spinButtonText.x = 1024;
+spinButtonText.y = 1800;
+game.addChild(spinButtonText);
+function initializeFactory() {
+ gamePhase = 'factory';
+ // Hide wheel and button
+ wheel.visible = false;
+ spinButton.visible = false;
+ spinButtonText.visible = false;
+ instructionText.setText('Tap the factory stations to transform your character!');
+ // Create conveyor belt
+ conveyorBelt = LK.getAsset('conveyorBelt', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 2000
+ });
+ game.addChild(conveyorBelt);
+ // Create factory stations
+ var stationTypes = ['mixer', 'oven', 'normal'];
+ for (var i = 0; i < totalStations; i++) {
+ var station = new FactoryStation(stationTypes[i % stationTypes.length]);
+ station.x = 400 + i * 600;
+ station.y = 1800;
+ stations.push(station);
+ game.addChild(station);
+ }
+ // Create character
+ currentCharacter = new PowerpuffCharacter(wheel.selectedCharacter);
+ currentCharacter.x = 200;
+ currentCharacter.y = 1800;
+ game.addChild(currentCharacter);
+ // Move character along conveyor
+ currentCharacter.moveToPosition(stations[0].x, stations[0].y + 100, 2000);
+}
+function updateProgress() {
+ var progress = stationProgress / totalStations;
+ tween(progressBar, {
+ scaleX: progress
+ }, {
+ duration: 500
+ });
+ if (progress >= 1) {
+ completeTransformation();
+ }
+}
+function completeTransformation() {
+ gamePhase = 'complete';
+ instructionText.setText('Transformation Complete! Today\'s theme: ' + currentTheme);
+ // Transform character to daily theme
+ currentCharacter.transform(currentTheme);
+ LK.setTimeout(function () {
+ LK.setScore(LK.getScore() + 100);
+ LK.showYouWin();
+ }, 2000);
+}
+// Event handlers
+spinButton.down = function (x, y, obj) {
+ if (gamePhase === 'selection' && !wheel.spinning) {
+ wheel.spin();
+ }
+};
+game.update = function () {
+ if (characterSelected && gamePhase === 'selection') {
+ LK.setTimeout(function () {
+ initializeFactory();
+ }, 1000);
+ characterSelected = false; // Prevent multiple calls
+ }
+ if (gamePhase === 'factory') {
+ // Update progress
+ var currentProgress = stationProgress / totalStations;
+ if (Math.abs(progressBar.scaleX - currentProgress) > 0.01) {
+ updateProgress();
+ }
+ // Move character to next station when current completes
+ if (stationProgress > 0 && stationProgress <= totalStations && currentCharacter) {
+ var nextStationIndex = Math.min(stationProgress, totalStations - 1);
+ if (stations[nextStationIndex] && !stations[nextStationIndex].active) {
+ currentCharacter.moveToPosition(stations[nextStationIndex].x, stations[nextStationIndex].y + 100, 1000);
+ }
+ }
+ }
+};
\ No newline at end of file