User prompt
Make the level text in a black box that fits the text
User prompt
When player on next level hide found Labubu on the level that the player completed
User prompt
When it is the next level hide the found labubus
User prompt
Make it so when the player is on next level hide found Labubus
Code edit (1 edits merged)
Please save this source code
User prompt
Labubu Hide & Seek Adventure
Initial prompt
Labubu hide & seek
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var HidingSpot = Container.expand(function (spotType, isCorrectSpot) { var self = Container.call(this); var spotGraphics = self.attachAsset(spotType, { anchorX: 0.5, anchorY: 0.5 }); self.isCorrect = isCorrectSpot; self.hasBeenSearched = false; self.down = function (x, y, obj) { if (self.hasBeenSearched) return; self.hasBeenSearched = true; if (self.isCorrect) { // Found Labubu! LK.getSound('foundLabubu').play(); foundLabubu = true; // Show Labubu with celebration animation var labubuSprite = game.addChild(LK.getAsset('labubu', { anchorX: 0.5, anchorY: 0.5, x: self.x, y: self.y, scaleX: 0.1, scaleY: 0.1 })); // Animate Labubu appearing tween(labubuSprite, { scaleX: 1.5, scaleY: 1.5 }, { duration: 500, easing: tween.bounceOut, onFinish: function onFinish() { tween(labubuSprite, { scaleX: 1, scaleY: 1 }, { duration: 200 }); } }); // Flash the hiding spot green LK.effects.flashObject(self, 0x00FF00, 1000); } else { // Wrong spot LK.getSound('wrongSearch').play(); // Flash red and shake LK.effects.flashObject(self, 0xFF0000, 500); // Shake animation var originalX = self.x; tween(self, { x: originalX - 10 }, { duration: 50, onFinish: function onFinish() { tween(self, { x: originalX + 10 }, { duration: 50, onFinish: function onFinish() { tween(self, { x: originalX }, { duration: 50 }); } }); } }); } // Create search effect var effect = game.addChild(LK.getAsset('searchEffect', { anchorX: 0.5, anchorY: 0.5, x: self.x, y: self.y, alpha: 0.7 })); // Animate search effect tween(effect, { scaleX: 2, scaleY: 2, alpha: 0 }, { duration: 300, onFinish: function onFinish() { effect.destroy(); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game state variables var currentLevel = storage.currentLevel || 1; var foundLabubu = false; var searchAttempts = 0; var maxAttempts = 5; var hidingSpots = []; var hintTimer = null; // Create background var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0 })); // Create UI elements var levelTextBg = new LK.getAsset('background', { width: 300, height: 120, color: 0x000000, anchorX: 0.5, anchorY: 0 }); var levelText = new Text2('Level ' + currentLevel, { size: 80, fill: 0xFFFFFF }); levelText.anchor.set(0.5, 0.5); levelTextBg.addChild(levelText); levelText.x = 0; levelText.y = 0; LK.gui.top.addChild(levelTextBg); levelTextBg.y = 100; var instructionText = new Text2('Tap to find Labubu!', { size: 60, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 0); LK.gui.top.addChild(instructionText); instructionText.y = 200; var attemptsText = new Text2('Searches: ' + searchAttempts + '/' + maxAttempts, { size: 50, fill: 0xFFFFFF }); attemptsText.anchor.set(0, 0); LK.gui.topLeft.addChild(attemptsText); attemptsText.x = 120; attemptsText.y = 50; // Function to create a new level function createLevel() { // Hide any found Labubu sprites from previous level var labubuSprites = game.children.filter(function (child) { return child.texture && child.texture.baseTexture && child.texture.baseTexture.resource && child.texture.baseTexture.resource.url && child.texture.baseTexture.resource.url.includes('6872480361ffa48d4b84136a'); }); for (var i = 0; i < labubuSprites.length; i++) { labubuSprites[i].destroy(); } // Clear existing hiding spots for (var i = 0; i < hidingSpots.length; i++) { hidingSpots[i].destroy(); } hidingSpots = []; // Reset game state foundLabubu = false; searchAttempts = 0; // Update UI levelText.setText('Level ' + currentLevel); // Update background box width to fit new text var textWidth = levelText.width + 40; // Add padding levelTextBg.width = Math.max(textWidth, 200); // Minimum width attemptsText.setText('Searches: ' + searchAttempts + '/' + maxAttempts); // Create hiding spots based on level var numSpots = Math.min(3 + currentLevel, 8); var correctSpotIndex = Math.floor(Math.random() * numSpots); for (var i = 0; i < numSpots; i++) { var spotType = 'hidingSpot' + (Math.floor(Math.random() * 5) + 1); var isCorrect = i === correctSpotIndex; var spot = game.addChild(new HidingSpot(spotType, isCorrect)); // Position spots randomly but ensure they don't overlap var placed = false; var attempts = 0; while (!placed && attempts < 50) { spot.x = 200 + Math.random() * 1648; spot.y = 400 + Math.random() * 1800; var overlapping = false; for (var j = 0; j < hidingSpots.length; j++) { var distance = Math.sqrt(Math.pow(spot.x - hidingSpots[j].x, 2) + Math.pow(spot.y - hidingSpots[j].y, 2)); if (distance < 250) { overlapping = true; break; } } if (!overlapping) { placed = true; } attempts++; } hidingSpots.push(spot); } // Start hint timer if (hintTimer) { LK.clearTimeout(hintTimer); } hintTimer = LK.setTimeout(function () { showHint(); }, 10000); // Show hint after 10 seconds } // Function to show hint function showHint() { // Find the correct hiding spot for (var i = 0; i < hidingSpots.length; i++) { if (hidingSpots[i].isCorrect) { // Subtle glow effect as hint tween(hidingSpots[i], { alpha: 0.7 }, { duration: 500, onFinish: function onFinish() { tween(hidingSpots[i], { alpha: 1 }, { duration: 500 }); } }); break; } } } // Game over function function gameOver() { // Show game over message var gameOverText = new Text2('Game Over! Try Again!', { size: 80, fill: 0xFF0000 }); gameOverText.anchor.set(0.5, 0.5); gameOverText.x = 1024; gameOverText.y = 1366; game.addChild(gameOverText); // Reset to level 1 after delay LK.setTimeout(function () { currentLevel = 1; storage.currentLevel = currentLevel; createLevel(); gameOverText.destroy(); }, 2000); } // Level complete function function completeLevel() { currentLevel++; storage.currentLevel = currentLevel; // Add score for completing level LK.setScore(LK.getScore() + 100 * currentLevel); // Hide the found Labubu sprite before showing completion message var labubuSprites = game.children.filter(function (child) { return child.texture && child.texture.baseTexture && child.texture.baseTexture.resource && child.texture.baseTexture.resource.url && child.texture.baseTexture.resource.url.includes('6872480361ffa48d4b84136a'); }); for (var i = 0; i < labubuSprites.length; i++) { labubuSprites[i].destroy(); } // Show level complete message var completeText = new Text2('Labubu Found! Next Level!', { size: 80, fill: 0x00FF00 }); completeText.anchor.set(0.5, 0.5); completeText.x = 1024; completeText.y = 1366; game.addChild(completeText); // Check for win condition if (currentLevel > 10) { LK.setTimeout(function () { LK.showYouWin(); }, 2000); return; } // Continue to next level LK.setTimeout(function () { // Ensure any remaining Labubu sprites are hidden before new level var remainingLabubuSprites = game.children.filter(function (child) { return child.texture && child.texture.baseTexture && child.texture.baseTexture.resource && child.texture.baseTexture.resource.url && child.texture.baseTexture.resource.url.includes('6872480361ffa48d4b84136a'); }); for (var i = 0; i < remainingLabubuSprites.length; i++) { remainingLabubuSprites[i].destroy(); } createLevel(); completeText.destroy(); }, 2000); } // Game events game.down = function (x, y, obj) { if (foundLabubu) return; searchAttempts++; attemptsText.setText('Searches: ' + searchAttempts + '/' + maxAttempts); // Check if search limit reached if (searchAttempts >= maxAttempts && !foundLabubu) { gameOver(); } }; // Game update loop game.update = function () { // Check if Labubu was found if (foundLabubu) { // Clear hint timer if (hintTimer) { LK.clearTimeout(hintTimer); hintTimer = null; } // Wait a moment then complete level LK.setTimeout(function () { completeLevel(); }, 1500); foundLabubu = false; // Reset for next check } }; // Initialize first level createLevel();
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var HidingSpot = Container.expand(function (spotType, isCorrectSpot) {
var self = Container.call(this);
var spotGraphics = self.attachAsset(spotType, {
anchorX: 0.5,
anchorY: 0.5
});
self.isCorrect = isCorrectSpot;
self.hasBeenSearched = false;
self.down = function (x, y, obj) {
if (self.hasBeenSearched) return;
self.hasBeenSearched = true;
if (self.isCorrect) {
// Found Labubu!
LK.getSound('foundLabubu').play();
foundLabubu = true;
// Show Labubu with celebration animation
var labubuSprite = game.addChild(LK.getAsset('labubu', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
scaleX: 0.1,
scaleY: 0.1
}));
// Animate Labubu appearing
tween(labubuSprite, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 500,
easing: tween.bounceOut,
onFinish: function onFinish() {
tween(labubuSprite, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
// Flash the hiding spot green
LK.effects.flashObject(self, 0x00FF00, 1000);
} else {
// Wrong spot
LK.getSound('wrongSearch').play();
// Flash red and shake
LK.effects.flashObject(self, 0xFF0000, 500);
// Shake animation
var originalX = self.x;
tween(self, {
x: originalX - 10
}, {
duration: 50,
onFinish: function onFinish() {
tween(self, {
x: originalX + 10
}, {
duration: 50,
onFinish: function onFinish() {
tween(self, {
x: originalX
}, {
duration: 50
});
}
});
}
});
}
// Create search effect
var effect = game.addChild(LK.getAsset('searchEffect', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
alpha: 0.7
}));
// Animate search effect
tween(effect, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
effect.destroy();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game state variables
var currentLevel = storage.currentLevel || 1;
var foundLabubu = false;
var searchAttempts = 0;
var maxAttempts = 5;
var hidingSpots = [];
var hintTimer = null;
// Create background
var background = game.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Create UI elements
var levelTextBg = new LK.getAsset('background', {
width: 300,
height: 120,
color: 0x000000,
anchorX: 0.5,
anchorY: 0
});
var levelText = new Text2('Level ' + currentLevel, {
size: 80,
fill: 0xFFFFFF
});
levelText.anchor.set(0.5, 0.5);
levelTextBg.addChild(levelText);
levelText.x = 0;
levelText.y = 0;
LK.gui.top.addChild(levelTextBg);
levelTextBg.y = 100;
var instructionText = new Text2('Tap to find Labubu!', {
size: 60,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionText);
instructionText.y = 200;
var attemptsText = new Text2('Searches: ' + searchAttempts + '/' + maxAttempts, {
size: 50,
fill: 0xFFFFFF
});
attemptsText.anchor.set(0, 0);
LK.gui.topLeft.addChild(attemptsText);
attemptsText.x = 120;
attemptsText.y = 50;
// Function to create a new level
function createLevel() {
// Hide any found Labubu sprites from previous level
var labubuSprites = game.children.filter(function (child) {
return child.texture && child.texture.baseTexture && child.texture.baseTexture.resource && child.texture.baseTexture.resource.url && child.texture.baseTexture.resource.url.includes('6872480361ffa48d4b84136a');
});
for (var i = 0; i < labubuSprites.length; i++) {
labubuSprites[i].destroy();
}
// Clear existing hiding spots
for (var i = 0; i < hidingSpots.length; i++) {
hidingSpots[i].destroy();
}
hidingSpots = [];
// Reset game state
foundLabubu = false;
searchAttempts = 0;
// Update UI
levelText.setText('Level ' + currentLevel);
// Update background box width to fit new text
var textWidth = levelText.width + 40; // Add padding
levelTextBg.width = Math.max(textWidth, 200); // Minimum width
attemptsText.setText('Searches: ' + searchAttempts + '/' + maxAttempts);
// Create hiding spots based on level
var numSpots = Math.min(3 + currentLevel, 8);
var correctSpotIndex = Math.floor(Math.random() * numSpots);
for (var i = 0; i < numSpots; i++) {
var spotType = 'hidingSpot' + (Math.floor(Math.random() * 5) + 1);
var isCorrect = i === correctSpotIndex;
var spot = game.addChild(new HidingSpot(spotType, isCorrect));
// Position spots randomly but ensure they don't overlap
var placed = false;
var attempts = 0;
while (!placed && attempts < 50) {
spot.x = 200 + Math.random() * 1648;
spot.y = 400 + Math.random() * 1800;
var overlapping = false;
for (var j = 0; j < hidingSpots.length; j++) {
var distance = Math.sqrt(Math.pow(spot.x - hidingSpots[j].x, 2) + Math.pow(spot.y - hidingSpots[j].y, 2));
if (distance < 250) {
overlapping = true;
break;
}
}
if (!overlapping) {
placed = true;
}
attempts++;
}
hidingSpots.push(spot);
}
// Start hint timer
if (hintTimer) {
LK.clearTimeout(hintTimer);
}
hintTimer = LK.setTimeout(function () {
showHint();
}, 10000); // Show hint after 10 seconds
}
// Function to show hint
function showHint() {
// Find the correct hiding spot
for (var i = 0; i < hidingSpots.length; i++) {
if (hidingSpots[i].isCorrect) {
// Subtle glow effect as hint
tween(hidingSpots[i], {
alpha: 0.7
}, {
duration: 500,
onFinish: function onFinish() {
tween(hidingSpots[i], {
alpha: 1
}, {
duration: 500
});
}
});
break;
}
}
}
// Game over function
function gameOver() {
// Show game over message
var gameOverText = new Text2('Game Over! Try Again!', {
size: 80,
fill: 0xFF0000
});
gameOverText.anchor.set(0.5, 0.5);
gameOverText.x = 1024;
gameOverText.y = 1366;
game.addChild(gameOverText);
// Reset to level 1 after delay
LK.setTimeout(function () {
currentLevel = 1;
storage.currentLevel = currentLevel;
createLevel();
gameOverText.destroy();
}, 2000);
}
// Level complete function
function completeLevel() {
currentLevel++;
storage.currentLevel = currentLevel;
// Add score for completing level
LK.setScore(LK.getScore() + 100 * currentLevel);
// Hide the found Labubu sprite before showing completion message
var labubuSprites = game.children.filter(function (child) {
return child.texture && child.texture.baseTexture && child.texture.baseTexture.resource && child.texture.baseTexture.resource.url && child.texture.baseTexture.resource.url.includes('6872480361ffa48d4b84136a');
});
for (var i = 0; i < labubuSprites.length; i++) {
labubuSprites[i].destroy();
}
// Show level complete message
var completeText = new Text2('Labubu Found! Next Level!', {
size: 80,
fill: 0x00FF00
});
completeText.anchor.set(0.5, 0.5);
completeText.x = 1024;
completeText.y = 1366;
game.addChild(completeText);
// Check for win condition
if (currentLevel > 10) {
LK.setTimeout(function () {
LK.showYouWin();
}, 2000);
return;
}
// Continue to next level
LK.setTimeout(function () {
// Ensure any remaining Labubu sprites are hidden before new level
var remainingLabubuSprites = game.children.filter(function (child) {
return child.texture && child.texture.baseTexture && child.texture.baseTexture.resource && child.texture.baseTexture.resource.url && child.texture.baseTexture.resource.url.includes('6872480361ffa48d4b84136a');
});
for (var i = 0; i < remainingLabubuSprites.length; i++) {
remainingLabubuSprites[i].destroy();
}
createLevel();
completeText.destroy();
}, 2000);
}
// Game events
game.down = function (x, y, obj) {
if (foundLabubu) return;
searchAttempts++;
attemptsText.setText('Searches: ' + searchAttempts + '/' + maxAttempts);
// Check if search limit reached
if (searchAttempts >= maxAttempts && !foundLabubu) {
gameOver();
}
};
// Game update loop
game.update = function () {
// Check if Labubu was found
if (foundLabubu) {
// Clear hint timer
if (hintTimer) {
LK.clearTimeout(hintTimer);
hintTimer = null;
}
// Wait a moment then complete level
LK.setTimeout(function () {
completeLevel();
}, 1500);
foundLabubu = false; // Reset for next check
}
};
// Initialize first level
createLevel();
Pink Labubu. In-Game asset. 2d. High contrast. No shadows
Tree. In-Game asset. 2d. High contrast. No shadows
Purple box. In-Game asset. 2d. High contrast. No shadows
Fish statue. In-Game asset. 2d. High contrast. No shadows
Green bush. In-Game asset. 2d. High contrast. No shadows
Red car. In-Game asset. 2d. High contrast. No shadows