User prompt
ok görselini geliştir
User prompt
ok eklendiği zaman ekranın sol köşesinde ortada dursun ve 2 saniyede bir balonu patlatsın
User prompt
dükkana 100 puanlık bir ok ekle
User prompt
Dükkanda auto shooter ın üstüne 100 puan değerinde bir ok koy ve bu ok 2 saniyede bir baloncuk patlatsın
User prompt
shopdan extra time ve speed boost kaldır
User prompt
2 tane silah alındığı zaman 2. sini ise tam simetrik olarak diğer tarafa koy
User prompt
promo code bölümünü kaldır
User prompt
dükkanda sadece auto shooter kalsın
User prompt
promosyon yerinde hata var yazılmıyo düzelt
User prompt
promosyon kodunu yazınca ekranda göster
User prompt
promosyon bölümündeki close yazsını biraz sola al
User prompt
promo bölümünü biraz aşağı al
User prompt
sol üst köşeyede promosyon kodu butonu ekle ve kod olarak axtra yazıldığında 150 puan ver
User prompt
silahın ateş etme efektini büyüt
User prompt
otomatik silahı sağ tarafa tam ortaya koy
User prompt
otomatik silah gösresilin değiştir ve bir silah görseli koy
User prompt
dükkana 150 pts karşılığında otomatik bir silah koy ve silah her saniye 1 baloncuğu patlatsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
shop yazısının arkasındaki maviliği büyüt
User prompt
shop yazısını büyüt
User prompt
zamanı kaldır zaman sonsuz
User prompt
En üst sağ köşeye dükkan butonu koy ve basınca dükkan açılsın
Code edit (1 edits merged)
Please save this source code
User prompt
Bubble Pop Frenzy
Initial prompt
baloncuk patlatma
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var AutoShooter = Container.expand(function () {
var self = Container.call(this);
self.isActive = false;
self.timer = null;
// Visual representation of auto-shooter as a gun
var shooterGraphics = self.attachAsset('gunImage', {
anchorX: 0.5,
anchorY: 0.5
});
// Customize appearance
shooterGraphics.scale.set(1.2);
// Add visual indicator
var shooterText = new Text2('AUTO', {
size: 50,
fill: 0xFFFFFF
});
shooterText.anchor.set(0.5, 0.5);
self.addChild(shooterText);
// Start the auto-shooter
self.activate = function () {
if (self.isActive) {
return;
}
self.isActive = true;
// Pulse animation to show it's active
tween(shooterGraphics, {
scaleX: 1.8,
scaleY: 1.8
}, {
duration: 1000,
easing: tween.easeInOut
});
// Set up timer to pop a bubble every second
self.timer = LK.setInterval(function () {
self.popRandomBubble();
}, 1000);
};
self.deactivate = function () {
if (!self.isActive) {
return;
}
self.isActive = false;
if (self.timer) {
LK.clearInterval(self.timer);
self.timer = null;
}
// Return to normal size
tween(shooterGraphics, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 500,
easing: tween.easeOut
});
};
// Function to pop a random bubble
self.popRandomBubble = function () {
// Find valid bubbles (not bombs, and active)
var validBubbles = bubbles.filter(function (bubble) {
return bubble.isActive && bubble.type !== 'bomb';
});
if (validBubbles.length > 0) {
// Get a random bubble from valid ones
var randomIndex = Math.floor(Math.random() * validBubbles.length);
var targetBubble = validBubbles[randomIndex];
// Pop it
targetBubble.pop();
// Visual effect from auto-shooter to bubble - resembles a bullet
var beam = LK.getAsset('gunImage', {
anchorX: 0.5,
anchorY: 0.5
});
beam.scale.set(0.3, 0.15); // Larger beam size
beam.tint = 0xFF0000;
beam.x = self.x;
beam.y = self.y;
game.addChild(beam);
// Add glow effect
beam.alpha = 0.9;
// Animate beam to target bubble with more dramatic effect
tween(beam, {
x: targetBubble.x,
y: targetBubble.y,
scaleX: 0.5,
// Grow while traveling
scaleY: 0.25,
alpha: 0
}, {
duration: 400,
// Slightly longer duration for better visibility
easing: tween.linear,
onFinish: function onFinish() {
game.removeChild(beam);
}
});
}
};
return self;
});
var Bubble = Container.expand(function (type, speed) {
var self = Container.call(this);
self.type = type || 'standard';
self.speed = speed || 2;
self.points = 1;
self.isActive = true;
var assetId = 'standardBubble';
if (self.type === 'bonus') {
assetId = 'bonusBubble';
self.points = 5;
} else if (self.type === 'bomb') {
assetId = 'bombBubble';
self.points = -10;
} else if (self.type === 'powerup') {
assetId = 'powerupBubble';
self.points = 2;
}
var bubbleGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
if (self.type === 'bonus') {
bubbleGraphics.scale.set(1.2);
} else if (self.type === 'powerup') {
bubbleGraphics.scale.set(0.9);
}
// Add some interactivity by scaling bubble on press
self.down = function (x, y, obj) {
if (!self.isActive) {
return;
}
// Scale down bubble when pressed
tween(bubbleGraphics, {
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 100,
easing: tween.easeOut
});
self.pop();
};
self.pop = function () {
if (!self.isActive) {
return;
}
self.isActive = false;
// Play sound based on bubble type
if (self.type === 'bomb') {
LK.getSound('explosion').play();
} else if (self.type === 'bonus') {
LK.getSound('bonus').play();
} else if (self.type === 'powerup') {
LK.getSound('powerup').play();
} else {
LK.getSound('pop').play();
}
// Animation for popping
tween(bubbleGraphics, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
if (self.parent) {
self.parent.removeChild(self);
}
}
});
// Update score
LK.setScore(LK.getScore() + self.points);
// Handle special effects
if (self.type === 'bomb') {
// Flash screen red for bomb
LK.effects.flashScreen(0xe74c3c, 300);
} else if (self.type === 'powerup') {
// Slow down all bubbles
if (slowDownTimer) {
LK.clearTimeout(slowDownTimer);
}
bubbleSpeed = baseSpeed * 0.5;
slowDownTimer = LK.setTimeout(function () {
bubbleSpeed = baseSpeed;
}, 5000);
}
};
self.update = function () {
if (!self.isActive) {
return;
}
// Move bubble upward
self.y -= self.speed;
// Slight side-to-side movement
self.x += Math.sin(LK.ticks / 20 + self.id * 0.3) * 0.8;
// Remove if bubble goes off-screen
if (self.y < -150) {
// If bomb escapes screen, that's good
if (self.type === 'bomb') {
LK.setScore(LK.getScore() + 2);
}
// If it's a bonus and escapes, that's bad
else if (self.type === 'bonus') {
LK.setScore(LK.getScore() - 2);
}
if (self.parent) {
self.parent.removeChild(self);
}
}
};
return self;
});
var PromoCodeButton = Container.expand(function () {
var self = Container.call(this);
// Create promo button visual
var buttonGraphics = self.attachAsset('standardBubble', {
anchorX: 0.5,
anchorY: 0.5
});
// Customize appearance
buttonGraphics.scale.set(1.2);
buttonGraphics.tint = 0x3498db;
// Add text label
var buttonText = new Text2('PROMO', {
size: 50,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
// Handle click
self.down = function (x, y, obj) {
tween(buttonGraphics, {
scaleX: 0.7,
scaleY: 0.7
}, {
duration: 100,
easing: tween.easeOut
});
// Open promo code dialog
openPromoDialog();
};
self.up = function (x, y, obj) {
tween(buttonGraphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
easing: tween.easeOut
});
};
return self;
});
var PromoDialog = Container.expand(function () {
var self = Container.call(this);
// Create dialog background
var dialogBg = self.attachAsset('standardBubble', {
anchorX: 0.5,
anchorY: 0.5
});
// Stretch to make panel
dialogBg.scale.set(7, 4);
dialogBg.alpha = 0.9;
// Add title
var titleText = new Text2('Enter Promo Code', {
size: 80,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.y = -150;
self.addChild(titleText);
// Add input display
var inputText = new Text2('_', {
size: 60,
fill: 0xFFFFFF
});
inputText.anchor.set(0.5, 0.5);
inputText.y = 0;
self.addChild(inputText);
// Add close button
var closeButton = new Text2('Close', {
size: 60,
fill: 0xFFFFFF
});
closeButton.anchor.set(0.5, 0.5);
closeButton.y = 150;
closeButton.interactive = true;
closeButton.down = function () {
closePromoDialog();
};
self.addChild(closeButton);
// Add submit button
var submitButton = new Text2('Submit', {
size: 60,
fill: 0xFFFFFF
});
submitButton.anchor.set(0.5, 0.5);
submitButton.x = 150;
submitButton.y = 150;
submitButton.interactive = true;
submitButton.down = function () {
checkPromoCode(currentInput);
};
self.addChild(submitButton);
// Virtual keyboard buttons
var keys = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '←'];
var keyboardContainer = new Container();
var keySize = 60;
var keysPerRow = 9;
var keyPadding = 10;
for (var i = 0; i < keys.length; i++) {
var keyX = i % keysPerRow * (keySize + keyPadding) - (keysPerRow - 1) * (keySize + keyPadding) / 2;
var keyY = Math.floor(i / keysPerRow) * (keySize + keyPadding) + 250;
var keyBg = LK.getAsset('standardBubble', {
anchorX: 0.5,
anchorY: 0.5
});
keyBg.scale.set(0.6, 0.6);
keyBg.x = keyX;
keyBg.y = keyY;
keyBg.tint = 0x3498db;
var keyLabel = new Text2(keys[i], {
size: 40,
fill: 0xFFFFFF
});
keyLabel.anchor.set(0.5, 0.5);
keyLabel.x = keyX;
keyLabel.y = keyY;
// Make key interactive
keyBg.interactive = true;
keyBg.key = keys[i];
keyBg.down = function (x, y, obj) {
var key = obj.key;
if (key === '←') {
// Backspace key
if (currentInput.length > 0) {
currentInput = currentInput.substring(0, currentInput.length - 1);
}
} else {
// Add letter to input
if (currentInput.length < 10) {
currentInput += key;
}
}
// Update input display
inputText.setText(currentInput + '_');
};
keyboardContainer.addChild(keyBg);
keyboardContainer.addChild(keyLabel);
}
self.addChild(keyboardContainer);
// Initialize with hidden state
self.visible = false;
return self;
});
var Shop = Container.expand(function () {
var self = Container.call(this);
// Create shop panel background
var panelBg = self.attachAsset('standardBubble', {
anchorX: 0.5,
anchorY: 0.5
});
// Stretch to make panel
panelBg.scale.set(10, 6);
panelBg.alpha = 0.9;
// Add title
var titleText = new Text2('Bubble Shop', {
size: 100,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.y = -300;
self.addChild(titleText);
// Add close button
var closeButton = new Text2('Close', {
size: 60,
fill: 0xFFFFFF
});
closeButton.anchor.set(0.5, 0.5);
closeButton.y = 300;
closeButton.interactive = true;
closeButton.down = function () {
closeShop();
};
self.addChild(closeButton);
// Add shop items (placeholders)
var item1 = new Text2('Extra Time: 50 pts', {
size: 60,
fill: 0xFFFFFF
});
item1.anchor.set(0.5, 0.5);
item1.y = -100;
self.addChild(item1);
var item2 = new Text2('Speed Boost: 100 pts', {
size: 60,
fill: 0xFFFFFF
});
item2.anchor.set(0.5, 0.5);
item2.y = 0;
self.addChild(item2);
var item3 = new Text2('Auto Shooter: 150 pts', {
size: 60,
fill: 0xFFFFFF
});
item3.anchor.set(0.5, 0.5);
item3.y = 100;
item3.interactive = true;
item3.down = function () {
// Check if player has enough points
if (LK.getScore() >= 150 && !autoShooterActive) {
// Deduct points
LK.setScore(LK.getScore() - 150);
// Activate auto-shooter
activateAutoShooter();
// Visual feedback
tween(item3, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(item3, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100,
easing: tween.easeIn
});
}
});
// Close shop after purchase
closeShop();
}
};
self.addChild(item3);
// Initialize with hidden state
self.visible = false;
return self;
});
var ShopButton = Container.expand(function () {
var self = Container.call(this);
// Create shop button visual
var buttonGraphics = self.attachAsset('standardBubble', {
anchorX: 0.5,
anchorY: 0.5
});
// Customize appearance
buttonGraphics.scale.set(1.2);
// Add text label
var buttonText = new Text2('Shop', {
size: 70,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
// Handle click
self.down = function (x, y, obj) {
tween(buttonGraphics, {
scaleX: 0.7,
scaleY: 0.7
}, {
duration: 100,
easing: tween.easeOut
});
// Open shop
openShop();
};
self.up = function (x, y, obj) {
tween(buttonGraphics, {
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 100,
easing: tween.easeOut
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var bubbles = [];
var level = 1;
var baseSpeed = 2;
var bubbleSpeed = baseSpeed;
var spawnRate = 60; // Ticks between bubble spawns
var maxBubbles = 10;
var timer = 0;
var scoreDisplay;
var levelDisplay;
var slowDownTimer = null;
var bubbleIdCounter = 0;
var shopButton;
var shopPanel;
var isShopOpen = false;
var autoShooter;
var autoShooterActive = false;
var promoButton;
var promoDialog;
var isPromoDialogOpen = false;
var currentInput = "";
var redeemedCodes = [];
// Auto-shooter functions
function activateAutoShooter() {
if (!autoShooterActive) {
autoShooterActive = true;
// Create auto-shooter if it doesn't exist
if (!autoShooter) {
autoShooter = new AutoShooter();
autoShooter.x = 2048 - 100; // Position at right side of screen
autoShooter.y = 2732 / 2; // Position at vertical center
game.addChild(autoShooter);
}
// Activate it
autoShooter.activate();
}
}
function deactivateAutoShooter() {
if (autoShooterActive && autoShooter) {
autoShooterActive = false;
autoShooter.deactivate();
}
}
// Shop functions
function openShop() {
if (!isShopOpen) {
isShopOpen = true;
shopPanel.visible = true;
// Animate shop opening
shopPanel.scale.set(0.1);
tween(shopPanel, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeOut
});
}
}
function closeShop() {
if (isShopOpen) {
// Animate shop closing
tween(shopPanel, {
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
shopPanel.visible = false;
isShopOpen = false;
}
});
}
}
// Promo code functions
function openPromoDialog() {
if (!isPromoDialogOpen) {
isPromoDialogOpen = true;
currentInput = "";
promoDialog.visible = true;
// Update input display
var inputText = promoDialog.getChildAt(2);
inputText.setText('_');
// Animate dialog opening
promoDialog.scale.set(0.1);
tween(promoDialog, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeOut
});
}
}
function closePromoDialog() {
if (isPromoDialogOpen) {
// Animate dialog closing
tween(promoDialog, {
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
promoDialog.visible = false;
isPromoDialogOpen = false;
}
});
}
}
function checkPromoCode(code) {
// Convert code to lowercase for case-insensitive comparison
var lowerCode = code.toLowerCase();
// Check if already redeemed
if (redeemedCodes.indexOf(lowerCode) !== -1) {
showPromoMessage("Code already used!");
return;
}
// Check if valid code
if (lowerCode === "axtra") {
// Add points
LK.setScore(LK.getScore() + 150);
// Add to redeemed codes
redeemedCodes.push(lowerCode);
// Show success message
showPromoMessage("Success! +150 points");
// Close dialog after short delay
LK.setTimeout(function () {
closePromoDialog();
}, 1000);
} else {
// Invalid code
showPromoMessage("Invalid code!");
}
}
function showPromoMessage(message) {
// Find or create message text
var messageText = null;
for (var i = 0; i < promoDialog.children.length; i++) {
if (promoDialog.children[i].isPromoMessage) {
messageText = promoDialog.children[i];
break;
}
}
if (!messageText) {
messageText = new Text2("", {
size: 50,
fill: 0xFFFFFF
});
messageText.isPromoMessage = true;
messageText.anchor.set(0.5, 0.5);
messageText.y = 70;
promoDialog.addChild(messageText);
}
// Set message and animate
messageText.setText(message);
messageText.alpha = 0;
tween(messageText, {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut
});
}
// Set up UI
function setupUI() {
// Score display
scoreDisplay = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreDisplay);
// Level display
levelDisplay = new Text2('Level: ' + level, {
size: 80,
fill: 0xFFFFFF
});
levelDisplay.anchor.set(1, 0);
LK.gui.topLeft.addChild(levelDisplay);
// Position them properly
levelDisplay.x = -120;
levelDisplay.y = 120; // Keep away from top left corner
scoreDisplay.y = 20;
// Add shop button to top right
shopButton = new ShopButton();
shopButton.x = -100;
shopButton.y = 100;
LK.gui.topRight.addChild(shopButton);
// Add promo code button to top left
promoButton = new PromoCodeButton();
promoButton.x = 120;
promoButton.y = 120; // Positioned below level display to keep away from corner
LK.gui.topLeft.addChild(promoButton);
// Create shop panel
shopPanel = new Shop();
shopPanel.visible = false;
LK.gui.center.addChild(shopPanel);
// Create promo dialog
promoDialog = new PromoDialog();
promoDialog.visible = false;
LK.gui.center.addChild(promoDialog);
}
// Spawn a new bubble
function spawnBubble() {
if (bubbles.length >= maxBubbles) {
return;
}
var type = 'standard';
var rand = Math.random();
// Determine bubble type based on probability
if (rand < 0.05) {
type = 'bomb';
} else if (rand < 0.15) {
type = 'bonus';
} else if (rand < 0.20) {
type = 'powerup';
}
// Create bubble
var bubble = new Bubble(type, bubbleSpeed);
bubble.id = bubbleIdCounter++;
// Position at random X at bottom of screen
bubble.x = Math.random() * (2048 - 200) + 100;
bubble.y = 2732 + 100;
// Add bubble to game and array
game.addChild(bubble);
bubbles.push(bubble);
}
// Remove bubble from array
function removeBubble(bubble) {
var index = bubbles.indexOf(bubble);
if (index > -1) {
bubbles.splice(index, 1);
}
}
// Update game difficulty based on level
function updateDifficulty() {
baseSpeed = 2 + level * 0.5;
bubbleSpeed = baseSpeed;
spawnRate = Math.max(20, 60 - level * 5);
maxBubbles = 10 + level;
}
// Update level based on score
function checkLevelUp() {
var newLevel = Math.floor(LK.getScore() / 50) + 1;
if (newLevel > level) {
level = newLevel;
levelDisplay.setText('Level: ' + level);
updateDifficulty();
// Flash screen to indicate level up
LK.effects.flashScreen(0x2ecc71, 500);
}
}
// Initialize game
function initGame() {
LK.setScore(0);
level = 1;
timer = 0;
// No gameTime limit - infinite gameplay
bubbleSpeed = baseSpeed;
bubbleIdCounter = 0;
// Reset promo code variables
currentInput = "";
isPromoDialogOpen = false;
redeemedCodes = [];
// Reset auto-shooter
if (autoShooter && autoShooter.parent) {
autoShooter.deactivate();
game.removeChild(autoShooter);
}
autoShooter = null;
autoShooterActive = false;
// Clear any existing bubbles
for (var i = bubbles.length - 1; i >= 0; i--) {
game.removeChild(bubbles[i]);
}
bubbles = [];
// Set up UI
setupUI();
// Update difficulty
updateDifficulty();
// Start background music
LK.playMusic('bgMusic', {
fade: {
start: 0,
end: 0.4,
duration: 1000
}
});
}
// No update timer function needed for infinite gameplay
// End game - will only be called manually when reaching score milestones
function endGame() {
if (LK.getScore() >= 100) {
LK.showYouWin();
} else {
LK.showGameOver();
}
}
// Initialize the game
initGame();
// Main game update function
game.update = function () {
timer++;
// Update score display
scoreDisplay.setText('Score: ' + LK.getScore());
// Check for level up
checkLevelUp();
// Spawn bubbles at regular intervals
if (timer % spawnRate === 0) {
spawnBubble();
}
// Clean up bubbles that are no longer in the scene
for (var i = bubbles.length - 1; i >= 0; i--) {
if (!bubbles[i].parent) {
removeBubble(bubbles[i]);
}
}
};
// Handle game clicks/taps
game.down = function (x, y, obj) {
// Just handle click/tap on the game background
// Bubbles have their own click handlers
};
// Handle mouse/touch movement
game.move = function (x, y, obj) {
// No implementation needed for this game
}; ===================================================================
--- original.js
+++ change.js
@@ -43,9 +43,8 @@
self.timer = LK.setInterval(function () {
self.popRandomBubble();
}, 1000);
};
- // Stop the auto-shooter
self.deactivate = function () {
if (!self.isActive) {
return;
}
@@ -218,8 +217,150 @@
}
};
return self;
});
+var PromoCodeButton = Container.expand(function () {
+ var self = Container.call(this);
+ // Create promo button visual
+ var buttonGraphics = self.attachAsset('standardBubble', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Customize appearance
+ buttonGraphics.scale.set(1.2);
+ buttonGraphics.tint = 0x3498db;
+ // Add text label
+ var buttonText = new Text2('PROMO', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ // Handle click
+ self.down = function (x, y, obj) {
+ tween(buttonGraphics, {
+ scaleX: 0.7,
+ scaleY: 0.7
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
+ // Open promo code dialog
+ openPromoDialog();
+ };
+ self.up = function (x, y, obj) {
+ tween(buttonGraphics, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
+ };
+ return self;
+});
+var PromoDialog = Container.expand(function () {
+ var self = Container.call(this);
+ // Create dialog background
+ var dialogBg = self.attachAsset('standardBubble', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Stretch to make panel
+ dialogBg.scale.set(7, 4);
+ dialogBg.alpha = 0.9;
+ // Add title
+ var titleText = new Text2('Enter Promo Code', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0);
+ titleText.y = -150;
+ self.addChild(titleText);
+ // Add input display
+ var inputText = new Text2('_', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ inputText.anchor.set(0.5, 0.5);
+ inputText.y = 0;
+ self.addChild(inputText);
+ // Add close button
+ var closeButton = new Text2('Close', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ closeButton.anchor.set(0.5, 0.5);
+ closeButton.y = 150;
+ closeButton.interactive = true;
+ closeButton.down = function () {
+ closePromoDialog();
+ };
+ self.addChild(closeButton);
+ // Add submit button
+ var submitButton = new Text2('Submit', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ submitButton.anchor.set(0.5, 0.5);
+ submitButton.x = 150;
+ submitButton.y = 150;
+ submitButton.interactive = true;
+ submitButton.down = function () {
+ checkPromoCode(currentInput);
+ };
+ self.addChild(submitButton);
+ // Virtual keyboard buttons
+ var keys = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '←'];
+ var keyboardContainer = new Container();
+ var keySize = 60;
+ var keysPerRow = 9;
+ var keyPadding = 10;
+ for (var i = 0; i < keys.length; i++) {
+ var keyX = i % keysPerRow * (keySize + keyPadding) - (keysPerRow - 1) * (keySize + keyPadding) / 2;
+ var keyY = Math.floor(i / keysPerRow) * (keySize + keyPadding) + 250;
+ var keyBg = LK.getAsset('standardBubble', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ keyBg.scale.set(0.6, 0.6);
+ keyBg.x = keyX;
+ keyBg.y = keyY;
+ keyBg.tint = 0x3498db;
+ var keyLabel = new Text2(keys[i], {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ keyLabel.anchor.set(0.5, 0.5);
+ keyLabel.x = keyX;
+ keyLabel.y = keyY;
+ // Make key interactive
+ keyBg.interactive = true;
+ keyBg.key = keys[i];
+ keyBg.down = function (x, y, obj) {
+ var key = obj.key;
+ if (key === '←') {
+ // Backspace key
+ if (currentInput.length > 0) {
+ currentInput = currentInput.substring(0, currentInput.length - 1);
+ }
+ } else {
+ // Add letter to input
+ if (currentInput.length < 10) {
+ currentInput += key;
+ }
+ }
+ // Update input display
+ inputText.setText(currentInput + '_');
+ };
+ keyboardContainer.addChild(keyBg);
+ keyboardContainer.addChild(keyLabel);
+ }
+ self.addChild(keyboardContainer);
+ // Initialize with hidden state
+ self.visible = false;
+ return self;
+});
var Shop = Container.expand(function () {
var self = Container.call(this);
// Create shop panel background
var panelBg = self.attachAsset('standardBubble', {
@@ -370,8 +511,13 @@
var shopPanel;
var isShopOpen = false;
var autoShooter;
var autoShooterActive = false;
+var promoButton;
+var promoDialog;
+var isPromoDialogOpen = false;
+var currentInput = "";
+var redeemedCodes = [];
// Auto-shooter functions
function activateAutoShooter() {
if (!autoShooterActive) {
autoShooterActive = true;
@@ -423,8 +569,98 @@
}
});
}
}
+// Promo code functions
+function openPromoDialog() {
+ if (!isPromoDialogOpen) {
+ isPromoDialogOpen = true;
+ currentInput = "";
+ promoDialog.visible = true;
+ // Update input display
+ var inputText = promoDialog.getChildAt(2);
+ inputText.setText('_');
+ // Animate dialog opening
+ promoDialog.scale.set(0.1);
+ tween(promoDialog, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ }
+}
+function closePromoDialog() {
+ if (isPromoDialogOpen) {
+ // Animate dialog closing
+ tween(promoDialog, {
+ scaleX: 0.1,
+ scaleY: 0.1
+ }, {
+ duration: 300,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ promoDialog.visible = false;
+ isPromoDialogOpen = false;
+ }
+ });
+ }
+}
+function checkPromoCode(code) {
+ // Convert code to lowercase for case-insensitive comparison
+ var lowerCode = code.toLowerCase();
+ // Check if already redeemed
+ if (redeemedCodes.indexOf(lowerCode) !== -1) {
+ showPromoMessage("Code already used!");
+ return;
+ }
+ // Check if valid code
+ if (lowerCode === "axtra") {
+ // Add points
+ LK.setScore(LK.getScore() + 150);
+ // Add to redeemed codes
+ redeemedCodes.push(lowerCode);
+ // Show success message
+ showPromoMessage("Success! +150 points");
+ // Close dialog after short delay
+ LK.setTimeout(function () {
+ closePromoDialog();
+ }, 1000);
+ } else {
+ // Invalid code
+ showPromoMessage("Invalid code!");
+ }
+}
+function showPromoMessage(message) {
+ // Find or create message text
+ var messageText = null;
+ for (var i = 0; i < promoDialog.children.length; i++) {
+ if (promoDialog.children[i].isPromoMessage) {
+ messageText = promoDialog.children[i];
+ break;
+ }
+ }
+ if (!messageText) {
+ messageText = new Text2("", {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ messageText.isPromoMessage = true;
+ messageText.anchor.set(0.5, 0.5);
+ messageText.y = 70;
+ promoDialog.addChild(messageText);
+ }
+ // Set message and animate
+ messageText.setText(message);
+ messageText.alpha = 0;
+ tween(messageText, {
+ alpha: 1
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+}
// Set up UI
function setupUI() {
// Score display
scoreDisplay = new Text2('Score: 0', {
@@ -448,12 +684,21 @@
shopButton = new ShopButton();
shopButton.x = -100;
shopButton.y = 100;
LK.gui.topRight.addChild(shopButton);
+ // Add promo code button to top left
+ promoButton = new PromoCodeButton();
+ promoButton.x = 120;
+ promoButton.y = 120; // Positioned below level display to keep away from corner
+ LK.gui.topLeft.addChild(promoButton);
// Create shop panel
shopPanel = new Shop();
shopPanel.visible = false;
LK.gui.center.addChild(shopPanel);
+ // Create promo dialog
+ promoDialog = new PromoDialog();
+ promoDialog.visible = false;
+ LK.gui.center.addChild(promoDialog);
}
// Spawn a new bubble
function spawnBubble() {
if (bubbles.length >= maxBubbles) {
@@ -511,8 +756,12 @@
timer = 0;
// No gameTime limit - infinite gameplay
bubbleSpeed = baseSpeed;
bubbleIdCounter = 0;
+ // Reset promo code variables
+ currentInput = "";
+ isPromoDialogOpen = false;
+ redeemedCodes = [];
// Reset auto-shooter
if (autoShooter && autoShooter.parent) {
autoShooter.deactivate();
game.removeChild(autoShooter);