Code edit (1 edits merged)
Please save this source code
User prompt
Powerpuff Girls: Hidden Heroes
Initial prompt
Toca finding buttercup 💚 bubbles 💙 and blossom 🩷 (2015). It’s bedtime. But suddenly where are they!! Have you spot them in level 1 lava, level 2 water, level 3 sandstorm, level 4 snowstorm, or level 5 dino land? Tap to choose a level.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var EnvironmentObject = Container.expand(function (objectType, x, y, scale) { var self = Container.call(this); var objectGraphics = self.attachAsset(objectType, { anchorX: 0.5, anchorY: 0.5, scaleX: scale || 1, scaleY: scale || 1 }); self.x = x; self.y = y; return self; }); var MenuButton = Container.expand(function (levelName, color, x, y) { var self = Container.call(this); var buttonGraphics = self.attachAsset(levelName + 'Button', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2(levelName.toUpperCase(), { size: 40, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.x = x; self.y = y; self.levelName = levelName; self.down = function (x, y, obj) { LK.getSound('buttonClick').play(); tween(self, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); currentLevel = self.levelName; showLevel(); }; self.up = function (x, y, obj) { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100 }); }; return self; }); var PowerpuffGirl = Container.expand(function (girlType, x, y) { var self = Container.call(this); var girlGraphics = self.attachAsset(girlType, { anchorX: 0.5, anchorY: 0.5 }); self.x = x; self.y = y; self.girlType = girlType; self.found = false; self.alpha = 0.8; // Slightly transparent to make them harder to spot self.down = function (x, y, obj) { if (!self.found) { self.found = true; LK.getSound('found').play(); // Visual feedback - flash and grow tween(self, { scaleX: 1.5, scaleY: 1.5, alpha: 1 }, { duration: 300 }); LK.effects.flashObject(self, 0xffffff, 500); charactersFound++; updateFoundCounter(); if (charactersFound >= 3) { LK.setTimeout(function () { levelComplete(); }, 800); } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c2c54 }); /**** * Game Code ****/ // Sound effects // Environment objects // Powerpuff Girls characters // Menu level buttons // Background environments var currentScreen = 'menu'; // 'menu' or 'level' var currentLevel = ''; var charactersFound = 0; var levelContainer = null; var menuContainer = null; var foundCounterText = null; // Level completion tracking var completedLevels = storage.completedLevels || []; // Initialize menu function createMenu() { menuContainer = new Container(); game.addChild(menuContainer); // Title var titleText = new Text2('POWERPUFF GIRLS\nHIDDEN HEROES', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 400; menuContainer.addChild(titleText); // Instruction text var instructionText = new Text2('Find Buttercup, Bubbles & Blossom!', { size: 50, fill: 0xFFFF99 }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 2048 / 2; instructionText.y = 550; menuContainer.addChild(instructionText); // Level buttons in a grid var levels = ['lava', 'water', 'sandstorm', 'snowstorm', 'dino']; var buttonSpacing = 350; var startX = 2048 / 2 - buttonSpacing; var startY = 800; for (var i = 0; i < levels.length; i++) { var x = startX + i % 3 * buttonSpacing; var y = startY + Math.floor(i / 3) * 280; var button = new MenuButton(levels[i], 0x4a4a4a, x, y); menuContainer.addChild(button); } } function showLevel() { if (menuContainer) { menuContainer.destroy(); menuContainer = null; } currentScreen = 'level'; charactersFound = 0; levelContainer = new Container(); game.addChild(levelContainer); // Add background var background = levelContainer.attachAsset(currentLevel + 'Background', { anchorX: 0, anchorY: 0 }); // Add environment objects based on level createEnvironmentObjects(); // Add hidden Powerpuff Girls createHiddenCharacters(); // Add UI elements createLevelUI(); } function createEnvironmentObjects() { var objects = []; switch (currentLevel) { case 'lava': objects = [{ type: 'lavaRock', x: 300, y: 800, scale: 1.2 }, { type: 'lavaRock', x: 800, y: 1200, scale: 0.8 }, { type: 'lavaRock', x: 1500, y: 900, scale: 1.5 }, { type: 'lavaRock', x: 1200, y: 1800, scale: 1.0 }, { type: 'lavaRock', x: 600, y: 2000, scale: 1.3 }]; break; case 'water': objects = [{ type: 'coral', x: 200, y: 1000, scale: 1.0 }, { type: 'coral', x: 700, y: 1500, scale: 1.2 }, { type: 'coral', x: 1300, y: 800, scale: 0.9 }, { type: 'coral', x: 1600, y: 1700, scale: 1.1 }, { type: 'coral', x: 400, y: 2200, scale: 0.8 }]; break; case 'sandstorm': objects = [{ type: 'sandDune', x: 350, y: 700, scale: 1.1 }, { type: 'sandDune', x: 900, y: 1100, scale: 1.4 }, { type: 'sandDune', x: 1400, y: 1400, scale: 0.9 }, { type: 'sandDune', x: 500, y: 1900, scale: 1.2 }, { type: 'sandDune', x: 1100, y: 2300, scale: 1.0 }]; break; case 'snowstorm': objects = [{ type: 'snowPile', x: 250, y: 900, scale: 1.3 }, { type: 'snowPile', x: 750, y: 1300, scale: 1.0 }, { type: 'snowPile', x: 1350, y: 1000, scale: 1.2 }, { type: 'snowPile', x: 1000, y: 1800, scale: 0.9 }, { type: 'snowPile', x: 1700, y: 2100, scale: 1.1 }]; break; case 'dino': objects = [{ type: 'tree', x: 200, y: 800, scale: 1.0 }, { type: 'tree', x: 800, y: 1200, scale: 1.2 }, { type: 'dinosaur', x: 1300, y: 1500, scale: 0.8 }, { type: 'tree', x: 1600, y: 900, scale: 0.9 }, { type: 'dinosaur', x: 600, y: 2000, scale: 1.0 }]; break; } for (var i = 0; i < objects.length; i++) { var obj = objects[i]; var envObj = new EnvironmentObject(obj.type, obj.x, obj.y, obj.scale); levelContainer.addChild(envObj); } } function createHiddenCharacters() { var positions = getCharacterPositions(); var girls = ['buttercup', 'bubbles', 'blossom']; for (var i = 0; i < girls.length; i++) { var girl = new PowerpuffGirl(girls[i], positions[i].x, positions[i].y); levelContainer.addChild(girl); } } function getCharacterPositions() { var positions = []; switch (currentLevel) { case 'lava': positions = [{ x: 280, y: 780 }, // Near first lava rock { x: 820, y: 1180 }, // Near second lava rock { x: 1480, y: 880 } // Near third lava rock ]; break; case 'water': positions = [{ x: 220, y: 980 }, // Near first coral { x: 720, y: 1480 }, // Near second coral { x: 1320, y: 780 } // Near third coral ]; break; case 'sandstorm': positions = [{ x: 370, y: 680 }, // Near first sand dune { x: 920, y: 1080 }, // Near second sand dune { x: 1420, y: 1380 } // Near third sand dune ]; break; case 'snowstorm': positions = [{ x: 270, y: 880 }, // Near first snow pile { x: 770, y: 1280 }, // Near second snow pile { x: 1370, y: 980 } // Near third snow pile ]; break; case 'dino': positions = [{ x: 220, y: 780 }, // Near first tree { x: 820, y: 1180 }, // Near second tree { x: 1320, y: 1480 } // Near dinosaur ]; break; } return positions; } function createLevelUI() { // Back button var backButton = new Text2('← BACK', { size: 60, fill: 0xFFFFFF }); backButton.anchor.set(0, 0); backButton.x = 150; backButton.y = 150; levelContainer.addChild(backButton); backButton.down = function (x, y, obj) { LK.getSound('buttonClick').play(); showMenu(); }; // Found counter foundCounterText = new Text2('Found: 0/3', { size: 50, fill: 0xFFFFFF }); foundCounterText.anchor.set(1, 0); foundCounterText.x = 1900; foundCounterText.y = 150; levelContainer.addChild(foundCounterText); // Level name var levelNameText = new Text2(currentLevel.toUpperCase() + ' LEVEL', { size: 60, fill: 0xFFFF99 }); levelNameText.anchor.set(0.5, 0); levelNameText.x = 2048 / 2; levelNameText.y = 150; levelContainer.addChild(levelNameText); } function updateFoundCounter() { if (foundCounterText) { foundCounterText.setText('Found: ' + charactersFound + '/3'); } } function levelComplete() { LK.getSound('levelComplete').play(); // Add to completed levels if (completedLevels.indexOf(currentLevel) === -1) { completedLevels.push(currentLevel); storage.completedLevels = completedLevels; } // Show completion message var completeText = new Text2('LEVEL COMPLETE!\nAll Heroes Found!', { size: 80, fill: 0x00FF00 }); completeText.anchor.set(0.5, 0.5); completeText.x = 2048 / 2; completeText.y = 2732 / 2; levelContainer.addChild(completeText); // Flash screen LK.effects.flashScreen(0x00ff00, 1000); // Auto return to menu after delay LK.setTimeout(function () { showMenu(); }, 3000); } function showMenu() { if (levelContainer) { levelContainer.destroy(); levelContainer = null; } currentScreen = 'menu'; createMenu(); } // Initialize the game createMenu(); game.update = function () { // Game logic updates if needed };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,494 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var EnvironmentObject = Container.expand(function (objectType, x, y, scale) {
+ var self = Container.call(this);
+ var objectGraphics = self.attachAsset(objectType, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: scale || 1,
+ scaleY: scale || 1
+ });
+ self.x = x;
+ self.y = y;
+ return self;
+});
+var MenuButton = Container.expand(function (levelName, color, x, y) {
+ var self = Container.call(this);
+ var buttonGraphics = self.attachAsset(levelName + 'Button', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var buttonText = new Text2(levelName.toUpperCase(), {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ self.x = x;
+ self.y = y;
+ self.levelName = levelName;
+ self.down = function (x, y, obj) {
+ LK.getSound('buttonClick').play();
+ tween(self, {
+ scaleX: 0.9,
+ scaleY: 0.9
+ }, {
+ duration: 100
+ });
+ currentLevel = self.levelName;
+ showLevel();
+ };
+ self.up = function (x, y, obj) {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ };
+ return self;
+});
+var PowerpuffGirl = Container.expand(function (girlType, x, y) {
+ var self = Container.call(this);
+ var girlGraphics = self.attachAsset(girlType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.x = x;
+ self.y = y;
+ self.girlType = girlType;
+ self.found = false;
+ self.alpha = 0.8; // Slightly transparent to make them harder to spot
+ self.down = function (x, y, obj) {
+ if (!self.found) {
+ self.found = true;
+ LK.getSound('found').play();
+ // Visual feedback - flash and grow
+ tween(self, {
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 1
+ }, {
+ duration: 300
+ });
+ LK.effects.flashObject(self, 0xffffff, 500);
+ charactersFound++;
+ updateFoundCounter();
+ if (charactersFound >= 3) {
+ LK.setTimeout(function () {
+ levelComplete();
+ }, 800);
+ }
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2c2c54
+});
+
+/****
+* Game Code
+****/
+// Sound effects
+// Environment objects
+// Powerpuff Girls characters
+// Menu level buttons
+// Background environments
+var currentScreen = 'menu'; // 'menu' or 'level'
+var currentLevel = '';
+var charactersFound = 0;
+var levelContainer = null;
+var menuContainer = null;
+var foundCounterText = null;
+// Level completion tracking
+var completedLevels = storage.completedLevels || [];
+// Initialize menu
+function createMenu() {
+ menuContainer = new Container();
+ game.addChild(menuContainer);
+ // Title
+ var titleText = new Text2('POWERPUFF GIRLS\nHIDDEN HEROES', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0.5);
+ titleText.x = 2048 / 2;
+ titleText.y = 400;
+ menuContainer.addChild(titleText);
+ // Instruction text
+ var instructionText = new Text2('Find Buttercup, Bubbles & Blossom!', {
+ size: 50,
+ fill: 0xFFFF99
+ });
+ instructionText.anchor.set(0.5, 0.5);
+ instructionText.x = 2048 / 2;
+ instructionText.y = 550;
+ menuContainer.addChild(instructionText);
+ // Level buttons in a grid
+ var levels = ['lava', 'water', 'sandstorm', 'snowstorm', 'dino'];
+ var buttonSpacing = 350;
+ var startX = 2048 / 2 - buttonSpacing;
+ var startY = 800;
+ for (var i = 0; i < levels.length; i++) {
+ var x = startX + i % 3 * buttonSpacing;
+ var y = startY + Math.floor(i / 3) * 280;
+ var button = new MenuButton(levels[i], 0x4a4a4a, x, y);
+ menuContainer.addChild(button);
+ }
+}
+function showLevel() {
+ if (menuContainer) {
+ menuContainer.destroy();
+ menuContainer = null;
+ }
+ currentScreen = 'level';
+ charactersFound = 0;
+ levelContainer = new Container();
+ game.addChild(levelContainer);
+ // Add background
+ var background = levelContainer.attachAsset(currentLevel + 'Background', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ // Add environment objects based on level
+ createEnvironmentObjects();
+ // Add hidden Powerpuff Girls
+ createHiddenCharacters();
+ // Add UI elements
+ createLevelUI();
+}
+function createEnvironmentObjects() {
+ var objects = [];
+ switch (currentLevel) {
+ case 'lava':
+ objects = [{
+ type: 'lavaRock',
+ x: 300,
+ y: 800,
+ scale: 1.2
+ }, {
+ type: 'lavaRock',
+ x: 800,
+ y: 1200,
+ scale: 0.8
+ }, {
+ type: 'lavaRock',
+ x: 1500,
+ y: 900,
+ scale: 1.5
+ }, {
+ type: 'lavaRock',
+ x: 1200,
+ y: 1800,
+ scale: 1.0
+ }, {
+ type: 'lavaRock',
+ x: 600,
+ y: 2000,
+ scale: 1.3
+ }];
+ break;
+ case 'water':
+ objects = [{
+ type: 'coral',
+ x: 200,
+ y: 1000,
+ scale: 1.0
+ }, {
+ type: 'coral',
+ x: 700,
+ y: 1500,
+ scale: 1.2
+ }, {
+ type: 'coral',
+ x: 1300,
+ y: 800,
+ scale: 0.9
+ }, {
+ type: 'coral',
+ x: 1600,
+ y: 1700,
+ scale: 1.1
+ }, {
+ type: 'coral',
+ x: 400,
+ y: 2200,
+ scale: 0.8
+ }];
+ break;
+ case 'sandstorm':
+ objects = [{
+ type: 'sandDune',
+ x: 350,
+ y: 700,
+ scale: 1.1
+ }, {
+ type: 'sandDune',
+ x: 900,
+ y: 1100,
+ scale: 1.4
+ }, {
+ type: 'sandDune',
+ x: 1400,
+ y: 1400,
+ scale: 0.9
+ }, {
+ type: 'sandDune',
+ x: 500,
+ y: 1900,
+ scale: 1.2
+ }, {
+ type: 'sandDune',
+ x: 1100,
+ y: 2300,
+ scale: 1.0
+ }];
+ break;
+ case 'snowstorm':
+ objects = [{
+ type: 'snowPile',
+ x: 250,
+ y: 900,
+ scale: 1.3
+ }, {
+ type: 'snowPile',
+ x: 750,
+ y: 1300,
+ scale: 1.0
+ }, {
+ type: 'snowPile',
+ x: 1350,
+ y: 1000,
+ scale: 1.2
+ }, {
+ type: 'snowPile',
+ x: 1000,
+ y: 1800,
+ scale: 0.9
+ }, {
+ type: 'snowPile',
+ x: 1700,
+ y: 2100,
+ scale: 1.1
+ }];
+ break;
+ case 'dino':
+ objects = [{
+ type: 'tree',
+ x: 200,
+ y: 800,
+ scale: 1.0
+ }, {
+ type: 'tree',
+ x: 800,
+ y: 1200,
+ scale: 1.2
+ }, {
+ type: 'dinosaur',
+ x: 1300,
+ y: 1500,
+ scale: 0.8
+ }, {
+ type: 'tree',
+ x: 1600,
+ y: 900,
+ scale: 0.9
+ }, {
+ type: 'dinosaur',
+ x: 600,
+ y: 2000,
+ scale: 1.0
+ }];
+ break;
+ }
+ for (var i = 0; i < objects.length; i++) {
+ var obj = objects[i];
+ var envObj = new EnvironmentObject(obj.type, obj.x, obj.y, obj.scale);
+ levelContainer.addChild(envObj);
+ }
+}
+function createHiddenCharacters() {
+ var positions = getCharacterPositions();
+ var girls = ['buttercup', 'bubbles', 'blossom'];
+ for (var i = 0; i < girls.length; i++) {
+ var girl = new PowerpuffGirl(girls[i], positions[i].x, positions[i].y);
+ levelContainer.addChild(girl);
+ }
+}
+function getCharacterPositions() {
+ var positions = [];
+ switch (currentLevel) {
+ case 'lava':
+ positions = [{
+ x: 280,
+ y: 780
+ },
+ // Near first lava rock
+ {
+ x: 820,
+ y: 1180
+ },
+ // Near second lava rock
+ {
+ x: 1480,
+ y: 880
+ } // Near third lava rock
+ ];
+ break;
+ case 'water':
+ positions = [{
+ x: 220,
+ y: 980
+ },
+ // Near first coral
+ {
+ x: 720,
+ y: 1480
+ },
+ // Near second coral
+ {
+ x: 1320,
+ y: 780
+ } // Near third coral
+ ];
+ break;
+ case 'sandstorm':
+ positions = [{
+ x: 370,
+ y: 680
+ },
+ // Near first sand dune
+ {
+ x: 920,
+ y: 1080
+ },
+ // Near second sand dune
+ {
+ x: 1420,
+ y: 1380
+ } // Near third sand dune
+ ];
+ break;
+ case 'snowstorm':
+ positions = [{
+ x: 270,
+ y: 880
+ },
+ // Near first snow pile
+ {
+ x: 770,
+ y: 1280
+ },
+ // Near second snow pile
+ {
+ x: 1370,
+ y: 980
+ } // Near third snow pile
+ ];
+ break;
+ case 'dino':
+ positions = [{
+ x: 220,
+ y: 780
+ },
+ // Near first tree
+ {
+ x: 820,
+ y: 1180
+ },
+ // Near second tree
+ {
+ x: 1320,
+ y: 1480
+ } // Near dinosaur
+ ];
+ break;
+ }
+ return positions;
+}
+function createLevelUI() {
+ // Back button
+ var backButton = new Text2('← BACK', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ backButton.anchor.set(0, 0);
+ backButton.x = 150;
+ backButton.y = 150;
+ levelContainer.addChild(backButton);
+ backButton.down = function (x, y, obj) {
+ LK.getSound('buttonClick').play();
+ showMenu();
+ };
+ // Found counter
+ foundCounterText = new Text2('Found: 0/3', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ foundCounterText.anchor.set(1, 0);
+ foundCounterText.x = 1900;
+ foundCounterText.y = 150;
+ levelContainer.addChild(foundCounterText);
+ // Level name
+ var levelNameText = new Text2(currentLevel.toUpperCase() + ' LEVEL', {
+ size: 60,
+ fill: 0xFFFF99
+ });
+ levelNameText.anchor.set(0.5, 0);
+ levelNameText.x = 2048 / 2;
+ levelNameText.y = 150;
+ levelContainer.addChild(levelNameText);
+}
+function updateFoundCounter() {
+ if (foundCounterText) {
+ foundCounterText.setText('Found: ' + charactersFound + '/3');
+ }
+}
+function levelComplete() {
+ LK.getSound('levelComplete').play();
+ // Add to completed levels
+ if (completedLevels.indexOf(currentLevel) === -1) {
+ completedLevels.push(currentLevel);
+ storage.completedLevels = completedLevels;
+ }
+ // Show completion message
+ var completeText = new Text2('LEVEL COMPLETE!\nAll Heroes Found!', {
+ size: 80,
+ fill: 0x00FF00
+ });
+ completeText.anchor.set(0.5, 0.5);
+ completeText.x = 2048 / 2;
+ completeText.y = 2732 / 2;
+ levelContainer.addChild(completeText);
+ // Flash screen
+ LK.effects.flashScreen(0x00ff00, 1000);
+ // Auto return to menu after delay
+ LK.setTimeout(function () {
+ showMenu();
+ }, 3000);
+}
+function showMenu() {
+ if (levelContainer) {
+ levelContainer.destroy();
+ levelContainer = null;
+ }
+ currentScreen = 'menu';
+ createMenu();
+}
+// Initialize the game
+createMenu();
+game.update = function () {
+ // Game logic updates if needed
+};
\ No newline at end of file