User prompt
Süper meteor yap. Bu meteor %1 şansla oluşsun ve hızlı meteor ile aynı hızda olsun
User prompt
score 25’i geçince hızlı meteor oluşsun
User prompt
score arttıkça zorluk artmasını kaldır
User prompt
uydunun assetini satellite yap
User prompt
hızlı meteoru azıcık yavaşlat
User prompt
hızlı meteorun assetini FastMeteorite Yap
User prompt
%5 şansla doğan çok hızlı bir meteor yap
User prompt
uyduyu çok az yukarı taşı
User prompt
uydunun mermisi meteoyu yok etsin
User prompt
uyduyu parmak veya mouse ile sürükleyerek belli bir yatayda hareket ettirelim
User prompt
Uydu ateş etsin
User prompt
1- uydu sabit dursun
User prompt
bir uydu ekle ondan meteor yok edelim
User prompt
meteorlar tıklanınca yok olsun
User prompt
1- meteorları yavaşlat. 2- meteora bir hitbox ekle
User prompt
mermiyi kaldır
User prompt
turreti kaldır tıklayarak meteorları yok edelim
User prompt
turreti yönlendirmek için ok yönlü butonlar yap
User prompt
turreti döndürürken ekranın soluna tıklayınca sola dönsün sağa tıklanınca sağa dönsün
User prompt
butonları turretin altına getir
User prompt
butonları ekranın altının ortaına getir
User prompt
Butonları ortala ve üzerine yönünü yaz
User prompt
meteorları azalt
User prompt
dünya ve turret assetlerini yukarı doğru taşı ve yön butonlarını belirgin yap
User prompt
turreti yönlendirmek için butonlar ekle
/****
* Classes
****/
// Left/right arrow button for turret control
var ArrowButton = Container.expand(function () {
var self = Container.call(this);
// dir: -1 for left, 1 for right
self.dir = 0;
self.isDown = false;
// Use a simple colored box as arrow background
var bg = self.attachAsset('arrowBtnBg_' + Math.random(), {
width: 180,
height: 180,
color: 0x222a36,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
// Draw arrow using a colored box as a triangle (simulate with rotation)
var arrow = self.attachAsset('arrowBtnArrow_' + Math.random(), {
width: 60,
height: 120,
color: 0x6ec6ff,
shape: 'box',
anchorX: 0.5,
anchorY: 0.2
});
self.arrow = arrow;
// Set direction
self.setDirection = function (dir) {
self.dir = dir;
// Left: rotate -90deg, Right: rotate +90deg
arrow.rotation = dir < 0 ? -Math.PI / 2 : Math.PI / 2;
};
// Touch events
self.down = function () {
self.isDown = true;
};
self.up = function () {
self.isDown = false;
};
return self;
});
// Meteor class: Falling enemy
var Meteor = Container.expand(function () {
var self = Container.call(this);
var meteor = self.attachAsset('meteor', {
anchorX: 0.5,
anchorY: 0.5
});
// Randomize speed and rotation
self.speed = 12 + Math.random() * meteorSpeedBoost;
self.rotationSpeed = (Math.random() - 0.5) * 0.08;
// For intersection tracking
self.lastIntersecting = false;
self.update = function () {
self.y += self.speed;
self.rotation += self.rotationSpeed;
};
return self;
});
// Projectile class: Player's bullet
var Projectile = Container.expand(function () {
var self = Container.call(this);
var proj = self.attachAsset('projectile', {
anchorX: 0.5,
anchorY: 1
});
// Default direction: straight up
self.vx = 0;
self.vy = -38;
self.setDirection = function (dx, dy) {
// Normalize and scale to projectile speed
var len = Math.sqrt(dx * dx + dy * dy);
if (len === 0) {
self.vx = 0;
self.vy = -38;
} else {
var speed = 38;
self.vx = dx / len * speed;
self.vy = dy / len * speed;
}
// Set rotation of projectile to match direction
self.rotation = Math.atan2(self.vx, -self.vy);
};
self.update = function () {
self.x += self.vx;
self.y += self.vy;
};
return self;
});
// Turret class: Player's cannon at the bottom
var Turret = Container.expand(function () {
var self = Container.call(this);
// Barrel
var barrel = self.attachAsset('turretBarrel', {
anchorX: 0.5,
anchorY: 1,
x: 0,
y: 0
});
// Base
var base = self.attachAsset('turretBase', {
anchorX: 0.5,
anchorY: 0,
x: 0,
y: 0
});
// For drag offset
self.dragOffsetX = 0;
// For firing cooldown
self.canShoot = true;
// Store barrel for aiming
self.barrel = barrel;
// Fire projectile toward (targetX, targetY)
self.shoot = function (targetX, targetY) {
if (!self.canShoot) return;
self.canShoot = false;
// Cooldown (fast)
LK.setTimeout(function () {
self.canShoot = true;
}, 180);
// If no target, shoot straight up
var shootX = self.x;
var shootY = self.y - barrel.height;
var dx = 0,
dy = -1;
if (typeof targetX === "number" && typeof targetY === "number") {
// Calculate direction from barrel tip to target
var barrelTipX = self.x;
var barrelTipY = self.y - barrel.height;
dx = targetX - barrelTipX;
dy = targetY - barrelTipY;
// Prevent shooting downward
if (dy > 0) {
dx = 0;
dy = -1;
}
// Aim barrel
self.barrel.rotation = Math.atan2(dx, -dy);
} else {
// Reset barrel to straight up
self.barrel.rotation = 0;
}
var proj = new Projectile();
proj.x = self.x;
proj.y = self.y - barrel.height;
proj.setDirection(dx, dy);
projectiles.push(proj);
game.addChild(proj);
LK.getSound('shoot').play();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0a2233
});
/****
* Game Code
****/
// Sound effects
// Explosion effect (for future use)
// Earth: Ground at the bottom
// Meteor: Falling enemy
// Projectile: Player's bullet
// Turret: Defense cannon at the bottom
// Game variables
var turret;
var projectiles = [];
var meteors = [];
var earth;
var scoreTxt;
var livesTxt;
var dragNode = null;
var lastTouchX = 0;
var lives = 5;
var score = 0;
var meteorSpawnInterval = 60; // frames
var meteorSpeedBoost = 0; // increases as game progresses
var meteorTimer = 0;
// Add earth at the bottom
earth = LK.getAsset('earth', {
anchorX: 0.5,
anchorY: 1,
x: 2048 / 2,
y: 2732
});
game.addChild(earth);
// Add turret
turret = new Turret();
turret.x = 2048 / 2;
turret.y = 2732 - earth.height + 20;
game.addChild(turret);
// Score text (top center)
scoreTxt = new Text2('Score: 0', {
size: 100,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Lives text (top right, avoid top left 100x100)
livesTxt = new Text2('Lives: 5', {
size: 80,
fill: 0xFFB300
});
livesTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(livesTxt);
// Add left/right arrow buttons for turret control (bottom left/right)
var leftArrowBtn = new ArrowButton();
leftArrowBtn.setDirection(-1);
leftArrowBtn.x = 200;
leftArrowBtn.y = 2732 - 220;
LK.gui.bottomLeft.addChild(leftArrowBtn);
var rightArrowBtn = new ArrowButton();
rightArrowBtn.setDirection(1);
rightArrowBtn.x = 2048 - 200;
rightArrowBtn.y = 2732 - 220;
LK.gui.bottomRight.addChild(rightArrowBtn);
// Register button events
leftArrowBtn.down = function () {
leftArrowBtn.isDown = true;
};
leftArrowBtn.up = function () {
leftArrowBtn.isDown = false;
};
rightArrowBtn.down = function () {
rightArrowBtn.isDown = true;
};
rightArrowBtn.up = function () {
rightArrowBtn.isDown = false;
};
// Handle dragging turret horizontally
game.down = function (x, y, obj) {
// Only allow drag if touch is on or near the turret
var local = game.toLocal({
x: x,
y: y
});
if (local.y > turret.y - 120 && local.y < turret.y + 80 && local.x > turret.x - 180 && local.x < turret.x + 180) {
dragNode = turret;
dragNode.dragOffsetX = local.x - turret.x;
lastTouchX = local.x;
}
};
game.move = function (x, y, obj) {
if (dragNode) {
var local = game.toLocal({
x: x,
y: y
});
var newX = local.x - dragNode.dragOffsetX;
// Clamp within screen
var minX = 110 + 60; // avoid left edge
var maxX = 2048 - 60;
dragNode.x = Math.max(minX, Math.min(maxX, newX));
lastTouchX = local.x;
// Rotate barrel to point toward drag/touch position
var dx = local.x - dragNode.x;
var dy = local.y - (dragNode.y - dragNode.barrel.height);
// Prevent aiming downward
if (dy > 0) {
dx = 0;
dy = -1;
}
dragNode.barrel.rotation = Math.atan2(dx, -dy);
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Remove tap-to-shoot. Turret will auto-fire in the direction it is facing.
// Main update loop
game.update = function () {
// Move turret with arrow buttons
var moveSpeed = 32;
if (typeof leftArrowBtn !== "undefined" && leftArrowBtn.isDown) {
turret.x = Math.max(110 + 60, turret.x - moveSpeed);
}
if (typeof rightArrowBtn !== "undefined" && rightArrowBtn.isDown) {
turret.x = Math.min(2048 - 60, turret.x + moveSpeed);
}
// Spawn meteors
meteorTimer++;
var spawnRate = Math.max(18, meteorSpawnInterval - Math.floor(score / 10) * 4);
if (meteorTimer >= spawnRate) {
meteorTimer = 0;
var m = new Meteor();
// Random X, avoid edges
m.x = 120 + Math.random() * (2048 - 240);
m.y = -80;
meteors.push(m);
game.addChild(m);
}
// Increase difficulty
meteorSpeedBoost = Math.min(18, Math.floor(score / 8) * 2);
// Auto-fire projectiles from turret at a fixed interval
if (!turret.lastShotTick) turret.lastShotTick = 0;
if (LK.ticks - turret.lastShotTick > 12) {
// fire every 12 frames (~5 shots/sec)
// Calculate direction from barrel rotation
var angle = turret.barrel.rotation;
var dx = Math.sin(angle);
var dy = -Math.cos(angle);
var proj = new Projectile();
proj.x = turret.x;
proj.y = turret.y - turret.barrel.height;
proj.setDirection(dx, dy);
projectiles.push(proj);
game.addChild(proj);
LK.getSound('shoot').play();
turret.lastShotTick = LK.ticks;
}
// Update projectiles
for (var i = projectiles.length - 1; i >= 0; i--) {
var p = projectiles[i];
p.update();
// Remove if off screen
if (p.y < -100) {
p.destroy();
projectiles.splice(i, 1);
continue;
}
// Check collision with meteors
for (var j = meteors.length - 1; j >= 0; j--) {
var m = meteors[j];
if (p.intersects(m)) {
// Destroy both
LK.getSound('hit').play();
p.destroy();
m.destroy();
projectiles.splice(i, 1);
meteors.splice(j, 1);
score += 1;
scoreTxt.setText('Score: ' + score);
break;
}
}
}
// Update meteors
for (var k = meteors.length - 1; k >= 0; k--) {
var mtr = meteors[k];
mtr.update();
// If meteor hits earth
if (mtr.y + 60 >= earth.y - earth.height / 2) {
LK.getSound('lose').play();
mtr.destroy();
meteors.splice(k, 1);
lives -= 1;
livesTxt.setText('Lives: ' + lives);
// Flash screen
LK.effects.flashScreen(0xff0000, 400);
if (lives <= 0) {
LK.showGameOver();
return;
}
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,47 @@
/****
* Classes
****/
+// Left/right arrow button for turret control
+var ArrowButton = Container.expand(function () {
+ var self = Container.call(this);
+ // dir: -1 for left, 1 for right
+ self.dir = 0;
+ self.isDown = false;
+ // Use a simple colored box as arrow background
+ var bg = self.attachAsset('arrowBtnBg_' + Math.random(), {
+ width: 180,
+ height: 180,
+ color: 0x222a36,
+ shape: 'box',
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Draw arrow using a colored box as a triangle (simulate with rotation)
+ var arrow = self.attachAsset('arrowBtnArrow_' + Math.random(), {
+ width: 60,
+ height: 120,
+ color: 0x6ec6ff,
+ shape: 'box',
+ anchorX: 0.5,
+ anchorY: 0.2
+ });
+ self.arrow = arrow;
+ // Set direction
+ self.setDirection = function (dir) {
+ self.dir = dir;
+ // Left: rotate -90deg, Right: rotate +90deg
+ arrow.rotation = dir < 0 ? -Math.PI / 2 : Math.PI / 2;
+ };
+ // Touch events
+ self.down = function () {
+ self.isDown = true;
+ };
+ self.up = function () {
+ self.isDown = false;
+ };
+ return self;
+});
// Meteor class: Falling enemy
var Meteor = Container.expand(function () {
var self = Container.call(this);
var meteor = self.attachAsset('meteor', {
@@ -169,8 +209,32 @@
fill: 0xFFB300
});
livesTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(livesTxt);
+// Add left/right arrow buttons for turret control (bottom left/right)
+var leftArrowBtn = new ArrowButton();
+leftArrowBtn.setDirection(-1);
+leftArrowBtn.x = 200;
+leftArrowBtn.y = 2732 - 220;
+LK.gui.bottomLeft.addChild(leftArrowBtn);
+var rightArrowBtn = new ArrowButton();
+rightArrowBtn.setDirection(1);
+rightArrowBtn.x = 2048 - 200;
+rightArrowBtn.y = 2732 - 220;
+LK.gui.bottomRight.addChild(rightArrowBtn);
+// Register button events
+leftArrowBtn.down = function () {
+ leftArrowBtn.isDown = true;
+};
+leftArrowBtn.up = function () {
+ leftArrowBtn.isDown = false;
+};
+rightArrowBtn.down = function () {
+ rightArrowBtn.isDown = true;
+};
+rightArrowBtn.up = function () {
+ rightArrowBtn.isDown = false;
+};
// Handle dragging turret horizontally
game.down = function (x, y, obj) {
// Only allow drag if touch is on or near the turret
var local = game.toLocal({
@@ -194,25 +258,33 @@
var minX = 110 + 60; // avoid left edge
var maxX = 2048 - 60;
dragNode.x = Math.max(minX, Math.min(maxX, newX));
lastTouchX = local.x;
- // Determine if touch is on left or right half of the screen
- var screenMid = 2048 / 2;
- if (local.x < screenMid) {
- // Touch is on left half: rotate barrel left (limit to -60 degrees)
- dragNode.barrel.rotation = Math.max(-Math.PI / 3, dragNode.barrel.rotation - 0.10);
- } else {
- // Touch is on right half: rotate barrel right (limit to +60 degrees)
- dragNode.barrel.rotation = Math.min(Math.PI / 3, dragNode.barrel.rotation + 0.10);
+ // Rotate barrel to point toward drag/touch position
+ var dx = local.x - dragNode.x;
+ var dy = local.y - (dragNode.y - dragNode.barrel.height);
+ // Prevent aiming downward
+ if (dy > 0) {
+ dx = 0;
+ dy = -1;
}
+ dragNode.barrel.rotation = Math.atan2(dx, -dy);
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Remove tap-to-shoot. Turret will auto-fire in the direction it is facing.
// Main update loop
game.update = function () {
+ // Move turret with arrow buttons
+ var moveSpeed = 32;
+ if (typeof leftArrowBtn !== "undefined" && leftArrowBtn.isDown) {
+ turret.x = Math.max(110 + 60, turret.x - moveSpeed);
+ }
+ if (typeof rightArrowBtn !== "undefined" && rightArrowBtn.isDown) {
+ turret.x = Math.min(2048 - 60, turret.x + moveSpeed);
+ }
// Spawn meteors
meteorTimer++;
var spawnRate = Math.max(18, meteorSpawnInterval - Math.floor(score / 10) * 4);
if (meteorTimer >= spawnRate) {
meteor . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
dünya yüzeyi. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
blue meteor. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
green meteorite. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
spaceship. In-Game asset. 2d. High contrast. No shadows
spaceship debris. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
laser projectile. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
space with only stars. In-Game asset. real. High contrast. with shadows. high resolution
dünyanın bir bölümünün yüzeyi. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
alien. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
golden dolar symbol. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
yellow meteor. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
game heart. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
shield. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
red meteor with x2 write. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat