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 = 0.5 + Math.random() * 1.5;
self.update = function () {
self.x += Math.cos(self.floatDirection) * self.floatSpeed;
self.y += Math.sin(self.floatDirection) * self.floatSpeed;
// Bounce off edges
if (self.x < 40 || self.x > 2008) {
self.floatDirection = Math.PI - self.floatDirection;
}
if (self.y < 40 || self.y > 2692) {
self.floatDirection = -self.floatDirection;
}
// Keep bubbles in bounds
self.x = Math.max(40, Math.min(2008, self.x));
self.y = Math.max(40, Math.min(2692, self.y));
};
return self;
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 0;
self.speedY = 0;
self.speed = 12;
self.setDirection = function (angle) {
self.speedX = Math.cos(angle) * self.speed;
self.speedY = Math.sin(angle) * self.speed;
};
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
};
return self;
});
var Gun = Container.expand(function () {
var self = Container.call(this);
var gunGraphics = self.attachAsset('gun', {
anchorX: 0.5,
anchorY: 1.0
});
self.targetX = 1024;
self.targetY = 1366;
self.update = function () {
// Smoothly rotate gun towards target
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var targetRotation = Math.atan2(dy, dx) - Math.PI / 2;
// Smooth rotation
var rotDiff = targetRotation - self.rotation;
while (rotDiff > Math.PI) rotDiff -= Math.PI * 2;
while (rotDiff < -Math.PI) rotDiff += Math.PI * 2;
self.rotation += rotDiff * 0.15;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001122
});
/****
* Game Code
****/
// Game variables
var bubbles = [];
var bullets = [];
var gun;
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);
// Create gun
gun = game.addChild(new Gun());
gun.x = 1024;
gun.y = 2600;
// Function to spawn a bubble at random position
function spawnBubble() {
var bubble = new Bubble();
bubble.x = 100 + Math.random() * 1848;
bubble.y = 100 + Math.random() * 2300;
bubbles.push(bubble);
game.addChild(bubble);
}
// Initialize bubbles
for (var i = 0; i < 5; i++) {
spawnBubble();
}
// Function to fire bullet
function fireBullet() {
if (!isGameActive) return;
var bullet = new Bullet();
bullet.x = gun.x;
bullet.y = gun.y - 50;
// Calculate direction from gun to target
var dx = gun.targetX - gun.x;
var dy = gun.targetY - gun.y;
var angle = Math.atan2(dy, dx);
bullet.setDirection(angle);
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
// Game start
gameStartTime = Date.now();
// Touch controls for gun
game.move = function (x, y, obj) {
if (!isGameActive) return;
gun.targetX = x;
gun.targetY = y;
};
game.down = function (x, y, obj) {
if (!isGameActive) return;
gun.targetX = x;
gun.targetY = y;
fireBullet();
};
// 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);
// Update bullets and check collisions
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
// Remove bullets that go off screen
if (bullet.x < -20 || bullet.x > 2068 || bullet.y < -20 || bullet.y > 2752) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check collision with bubbles
var hitBubble = false;
for (var j = bubbles.length - 1; j >= 0; j--) {
var bubble = bubbles[j];
if (bullet.intersects(bubble)) {
// Hit bubble
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
// Play pop sound
LK.getSound('pop').play();
// Add pop effect
LK.effects.flashObject(bubble, 0xffffff, 200);
// Remove bubble and bullet
bubble.destroy();
bubbles.splice(j, 1);
bullet.destroy();
bullets.splice(i, 1);
// Spawn new bubble
spawnBubble();
hitBubble = true;
break;
}
}
if (hitBubble) continue;
}
// Auto-fire every 10 ticks (6 times per second)
if (LK.ticks % 10 === 0) {
fireBullet();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,203 @@
-/****
+/****
+* 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 = 0.5 + Math.random() * 1.5;
+ self.update = function () {
+ self.x += Math.cos(self.floatDirection) * self.floatSpeed;
+ self.y += Math.sin(self.floatDirection) * self.floatSpeed;
+ // Bounce off edges
+ if (self.x < 40 || self.x > 2008) {
+ self.floatDirection = Math.PI - self.floatDirection;
+ }
+ if (self.y < 40 || self.y > 2692) {
+ self.floatDirection = -self.floatDirection;
+ }
+ // Keep bubbles in bounds
+ self.x = Math.max(40, Math.min(2008, self.x));
+ self.y = Math.max(40, Math.min(2692, self.y));
+ };
+ return self;
+});
+var Bullet = Container.expand(function () {
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speedX = 0;
+ self.speedY = 0;
+ self.speed = 12;
+ self.setDirection = function (angle) {
+ self.speedX = Math.cos(angle) * self.speed;
+ self.speedY = Math.sin(angle) * self.speed;
+ };
+ self.update = function () {
+ self.x += self.speedX;
+ self.y += self.speedY;
+ };
+ return self;
+});
+var Gun = Container.expand(function () {
+ var self = Container.call(this);
+ var gunGraphics = self.attachAsset('gun', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ self.targetX = 1024;
+ self.targetY = 1366;
+ self.update = function () {
+ // Smoothly rotate gun towards target
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ var targetRotation = Math.atan2(dy, dx) - Math.PI / 2;
+ // Smooth rotation
+ var rotDiff = targetRotation - self.rotation;
+ while (rotDiff > Math.PI) rotDiff -= Math.PI * 2;
+ while (rotDiff < -Math.PI) rotDiff += Math.PI * 2;
+ self.rotation += rotDiff * 0.15;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x001122
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var bubbles = [];
+var bullets = [];
+var gun;
+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);
+// Create gun
+gun = game.addChild(new Gun());
+gun.x = 1024;
+gun.y = 2600;
+// Function to spawn a bubble at random position
+function spawnBubble() {
+ var bubble = new Bubble();
+ bubble.x = 100 + Math.random() * 1848;
+ bubble.y = 100 + Math.random() * 2300;
+ bubbles.push(bubble);
+ game.addChild(bubble);
+}
+// Initialize bubbles
+for (var i = 0; i < 5; i++) {
+ spawnBubble();
+}
+// Function to fire bullet
+function fireBullet() {
+ if (!isGameActive) return;
+ var bullet = new Bullet();
+ bullet.x = gun.x;
+ bullet.y = gun.y - 50;
+ // Calculate direction from gun to target
+ var dx = gun.targetX - gun.x;
+ var dy = gun.targetY - gun.y;
+ var angle = Math.atan2(dy, dx);
+ bullet.setDirection(angle);
+ bullets.push(bullet);
+ game.addChild(bullet);
+ LK.getSound('shoot').play();
+}
+// Game start
+gameStartTime = Date.now();
+// Touch controls for gun
+game.move = function (x, y, obj) {
+ if (!isGameActive) return;
+ gun.targetX = x;
+ gun.targetY = y;
+};
+game.down = function (x, y, obj) {
+ if (!isGameActive) return;
+ gun.targetX = x;
+ gun.targetY = y;
+ fireBullet();
+};
+// 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);
+ // Update bullets and check collisions
+ for (var i = bullets.length - 1; i >= 0; i--) {
+ var bullet = bullets[i];
+ // Remove bullets that go off screen
+ if (bullet.x < -20 || bullet.x > 2068 || bullet.y < -20 || bullet.y > 2752) {
+ bullet.destroy();
+ bullets.splice(i, 1);
+ continue;
+ }
+ // Check collision with bubbles
+ var hitBubble = false;
+ for (var j = bubbles.length - 1; j >= 0; j--) {
+ var bubble = bubbles[j];
+ if (bullet.intersects(bubble)) {
+ // Hit bubble
+ LK.setScore(LK.getScore() + 10);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ // Play pop sound
+ LK.getSound('pop').play();
+ // Add pop effect
+ LK.effects.flashObject(bubble, 0xffffff, 200);
+ // Remove bubble and bullet
+ bubble.destroy();
+ bubbles.splice(j, 1);
+ bullet.destroy();
+ bullets.splice(i, 1);
+ // Spawn new bubble
+ spawnBubble();
+ hitBubble = true;
+ break;
+ }
+ }
+ if (hitBubble) continue;
+ }
+ // Auto-fire every 10 ticks (6 times per second)
+ if (LK.ticks % 10 === 0) {
+ fireBullet();
+ }
+};
\ No newline at end of file