User prompt
arkaplan için assets dosyası oluştur
User prompt
spawn faster when i click the buble spawn new one fast with 0 delay ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
now delete all bubles and add 1 buble.one i hit the one buble spawn in the random location new one.when i hit the buble spawn in the new location fast and buble must move everytime ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make bubbles movement faster ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
if we did not hit the bubles in 5 seconds remove their position and spawn in the new random position.and make bubles smaller and when we hit the bubles add sound ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
not like this i want this like aim training dont add gun.i need to fire the bubles with mouse.
Code edit (1 edits merged)
Please save this source code
User prompt
Bubble Shooter Blitz
Initial prompt
can you create 5 small bubles and add a gun.when we hit the one of the small bubles.create new one in the random position.and add 1 minute for hit the bubles
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bubble = Container.expand(function () {
var self = Container.call(this);
var bubbleGraphics = self.attachAsset('bubble', {
anchorX: 0.5,
anchorY: 0.5
});
// Add floating animation
self.floatDirection = Math.random() * Math.PI * 2;
self.floatSpeed = 2.0 + Math.random() * 4.0;
self.isDestroyed = false;
self.update = function () {
if (self.isDestroyed) return;
// Continuous movement
self.x += Math.cos(self.floatDirection) * self.floatSpeed;
self.y += Math.sin(self.floatDirection) * self.floatSpeed;
// Bounce off edges
if (self.x < 25 || self.x > 2023) {
self.floatDirection = Math.PI - self.floatDirection;
}
if (self.y < 25 || self.y > 2707) {
self.floatDirection = -self.floatDirection;
}
// Keep bubbles in bounds
self.x = Math.max(25, Math.min(2023, self.x));
self.y = Math.max(25, Math.min(2707, self.y));
};
self.down = function (x, y, obj) {
if (!isGameActive || self.isDestroyed) return;
// Mark as destroyed
self.isDestroyed = true;
// Pop this bubble
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
// Play pop sound
LK.getSound('pop').play();
// Add pop effect with tween
tween(self, {
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
// Remove this bubble from array
for (var i = 0; i < bubbles.length; i++) {
if (bubbles[i] === self) {
bubbles.splice(i, 1);
break;
}
}
// Destroy this bubble
self.destroy();
// Instantly spawn a new bubble at random location
spawnBubble();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001122
});
/****
* Game Code
****/
// Game variables
var bubbles = [];
var gameTimer = 60000; // 1 minute in milliseconds
var gameStartTime;
var isGameActive = true;
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var timerTxt = new Text2('1:00', {
size: 60,
fill: 0xFFAA00
});
timerTxt.anchor.set(0.5, 0);
timerTxt.y = 80;
LK.gui.top.addChild(timerTxt);
// Function to spawn a bubble at random position
function spawnBubble() {
var bubble = new Bubble();
bubble.x = 50 + Math.random() * 1948;
bubble.y = 50 + Math.random() * 2632;
bubbles.push(bubble);
game.addChild(bubble);
}
// Initialize bubbles - start with just 1 bubble
spawnBubble();
// Game start
gameStartTime = Date.now();
// Main game update loop
game.update = function () {
if (!isGameActive) return;
// Update timer
var elapsed = Date.now() - gameStartTime;
var remaining = Math.max(0, gameTimer - elapsed);
if (remaining <= 0) {
isGameActive = false;
LK.showGameOver();
return;
}
var minutes = Math.floor(remaining / 60000);
var seconds = Math.floor(remaining % 60000 / 1000);
timerTxt.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
}; ===================================================================
--- original.js
+++ change.js
@@ -14,32 +14,12 @@
});
// Add floating animation
self.floatDirection = Math.random() * Math.PI * 2;
self.floatSpeed = 2.0 + Math.random() * 4.0;
- // Add 5-second timer for respawn
- self.spawnTime = Date.now();
- self.lifespan = 5000; // 5 seconds
self.isDestroyed = false;
self.update = function () {
if (self.isDestroyed) return;
- // Check if 5 seconds have passed
- var currentTime = Date.now();
- if (currentTime - self.spawnTime >= self.lifespan) {
- // Time to respawn - mark as destroyed and respawn
- self.isDestroyed = true;
- // Remove from bubbles array
- for (var i = 0; i < bubbles.length; i++) {
- if (bubbles[i] === self) {
- bubbles.splice(i, 1);
- break;
- }
- }
- // Destroy current bubble
- self.destroy();
- // Spawn new bubble
- spawnBubble();
- return;
- }
+ // Continuous movement
self.x += Math.cos(self.floatDirection) * self.floatSpeed;
self.y += Math.sin(self.floatDirection) * self.floatSpeed;
// Bounce off edges
if (self.x < 25 || self.x > 2023) {
@@ -53,28 +33,37 @@
self.y = Math.max(25, Math.min(2707, self.y));
};
self.down = function (x, y, obj) {
if (!isGameActive || self.isDestroyed) return;
- // Mark as destroyed to prevent timer respawn
+ // Mark as destroyed
self.isDestroyed = true;
// Pop this bubble
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
// Play pop sound
LK.getSound('pop').play();
- // Add pop effect
- LK.effects.flashObject(self, 0xffffff, 200);
- // Remove this bubble from array
- for (var i = 0; i < bubbles.length; i++) {
- if (bubbles[i] === self) {
- bubbles.splice(i, 1);
- break;
+ // Add pop effect with tween
+ tween(self, {
+ alpha: 0,
+ scaleX: 0.1,
+ scaleY: 0.1
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ // Remove this bubble from array
+ for (var i = 0; i < bubbles.length; i++) {
+ if (bubbles[i] === self) {
+ bubbles.splice(i, 1);
+ break;
+ }
+ }
+ // Destroy this bubble
+ self.destroy();
+ // Instantly spawn a new bubble at random location
+ spawnBubble();
}
- }
- // Destroy this bubble
- self.destroy();
- // Spawn a new bubble
- spawnBubble();
+ });
};
return self;
});
@@ -114,12 +103,10 @@
bubble.y = 50 + Math.random() * 2632;
bubbles.push(bubble);
game.addChild(bubble);
}
-// Initialize bubbles
-for (var i = 0; i < 5; i++) {
- spawnBubble();
-}
+// Initialize bubbles - start with just 1 bubble
+spawnBubble();
// Game start
gameStartTime = Date.now();
// Main game update loop
game.update = function () {