User prompt
menü için menu görselini kullan
User prompt
Design a dynamic 2D space-themed main menu interface for a game. The background features a slowly scrolling starfield with distant galaxies, nebulae, and occasional asteroid flybys. A holographic-style interface floats in the center, with buttons like 'Start Game', 'Load', 'Settings', and 'Exit' arranged vertically or in a futuristic arc. Each button has glowing effects, slight hover animations, and emits soft electronic sounds when hovered or clicked. The logo of the game hovers above the menu, gently pulsing with energy. Include subtle animations such as distant ship silhouettes flying by, blinking satellite beacons, or particle trails. The entire interface should feel alive, high-tech, and immersive.
User prompt
seçeneklerden ürünleri kaldır ve satın alınabilir ürünleri ekleyebileceğim bir menüye çevir
User prompt
Please fix the bug: '[object Object]addChildAt: The index 1 supplied is out of bounds 0' in or related to this line: 'game.addChildAt(starBgContainer, 1); // Galaksi'nin üstünde, menünün arkasında' Line Number: 402
User prompt
galaksi görselini kaldır
User prompt
menüde galaksi arkaplandan kaldır
User prompt
blackholl ekranda sabit olmasın oyunun ilerleyen bölümlerinde çıksın
User prompt
menüyü yeniden dizayn edelim dinamik ve güzel bir görüntü ve arkaplan ekleyelim
User prompt
düşmanların hareketleri mantığa uygun olarak güncelle
User prompt
oyuncu gemisi mermi hızı için hız gifti alındığında artış olsun
User prompt
gift sistemini tekrar ayarla kalkan, sağlık ve mermi hızı için 3 farklı gift var ve random olarak çıkıyorlar
User prompt
oyuna mermi hızı arttırmak için gift ekle ve bunun için mermispeedgift görsleini kullan
User prompt
düşman daha akıllı hareket etsin
User prompt
sağlık hediyesi ekle ve healthgift görselini kullan
User prompt
kalkanshield için sadece kalkan hediyesini kullan
User prompt
gift random çıksın
User prompt
sağlık için gift ekle healtgift görselini kullan
User prompt
oyuncu gemesi kalkanın tam ortasında olsun
User prompt
playership shildin içine sığacak şekilde ayarla
User prompt
gift sadece shield versin
User prompt
kalkan oyuncu gemisini merkezden ortalasın
User prompt
shield, playership' i ortalasın
User prompt
boss görünmeden önce öldürülecek düşman sayısını 50 ye yükselt
User prompt
gift hareketli olsun
User prompt
karadelik mekaniğini grliştirelim
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Asteroid - SAĞDAN SOLA
var Asteroid = Container.expand(function () {
var self = Container.call(this);
var width = 120 + Math.random() * 60;
var height = 120 + Math.random() * 60;
var objAsset = self.attachAsset('spaceObject', {
anchorX: 0.5,
anchorY: 0.5
});
objAsset.width = width;
objAsset.height = height;
objAsset.color = 0x888888;
self.radius = width / 2;
// Always spawn at right edge, random Y, move left
self.x = 2048 + width;
self.y = 200 + Math.random() * (2732 - 400);
// Dynamic spawn effect: scale up and fade in
self.scaleX = 0.6;
self.scaleY = 0.6;
self.alpha = 0.0;
tween(self, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
// Speed will be set on spawn
self.vx = -8;
self.vy = (Math.random() - 0.5) * 2;
self.update = function () {
self.x += self.vx;
self.y += self.vy;
};
return self;
});
// Kara Delik (Black Hole) - Rastgele spawn, yakındaki objeleri çeker
var BlackHole = Container.expand(function () {
var self = Container.call(this);
// Görsel: sun görseli, koyu renkli, büyükçe
var bhAsset = self.attachAsset('sun', {
anchorX: 0.5,
anchorY: 0.5
});
bhAsset.width = 180 + Math.random() * 60;
bhAsset.height = bhAsset.width;
bhAsset.alpha = 0.85;
bhAsset.color = 0x222244; // Koyu mor/siyah
self.radius = bhAsset.width / 2;
// Ekranda rastgele bir yere spawn olsun (kenarlardan uzak)
self.x = 400 + Math.random() * (2048 - 800);
self.y = 400 + Math.random() * (2732 - 800);
// Dinamik spawn efekti: büyüyerek ve fade-in ile gelsin
self.scaleX = 0.5;
self.scaleY = 0.5;
self.alpha = 0.0;
tween(self, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 600,
easing: tween.easeOut
});
// Kara delik çekim gücü ve menzili
self.pullRadius = bhAsset.width * 3.2;
self.pullStrength = 0.7 + Math.random() * 0.5; // 0.7-1.2 arası
// Hafif döndürme efekti
self._rotSpeed = (Math.random() - 0.5) * 0.02;
// Kara delik ömrü (10-16 saniye arası)
self.lifeTicks = 600 + Math.floor(Math.random() * 360);
self.age = 0;
// Hafif nabız efekti
self._pulseBase = self.scaleX;
self.update = function () {
// Hafif döndürme
bhAsset.rotation += self._rotSpeed;
// Nabız efekti
var t = LK.ticks % 60 / 60;
var pulse = 1.0 + 0.08 * Math.sin(t * Math.PI * 2);
self.scaleX = self._pulseBase * pulse;
self.scaleY = self._pulseBase * pulse;
// Çekim alanı: yakındaki objeleri kendine çeker
var allObjs = [];
if (typeof spaceObjects !== "undefined" && spaceObjects.length) {
for (var i = 0; i < spaceObjects.length; i++) {
allObjs.push(spaceObjects[i]);
}
}
if (typeof bullets !== "undefined" && bullets.length) {
for (var i = 0; i < bullets.length; i++) {
allObjs.push(bullets[i]);
}
}
// Oyuncu gemisi de çekilsin
if (typeof playerShip !== "undefined" && playerShip && !playerShip._autoMovingToPortal) {
allObjs.push(playerShip);
}
for (var j = 0; j < allObjs.length; j++) {
var obj = allObjs[j];
if (!obj || typeof obj.x === "undefined" || typeof obj.y === "undefined") continue;
var dx = self.x - obj.x;
var dy = self.y - obj.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < self.pullRadius && dist > 10) {
// Çekim kuvveti: mesafe azaldıkça artar
var force = self.pullStrength * (1 - dist / self.pullRadius);
// Objeye hız ekle (vx/vy varsa)
if (typeof obj.vx !== "undefined" && typeof obj.vy !== "undefined") {
obj.vx += dx / dist * force * 0.7;
obj.vy += dy / dist * force * 0.7;
} else {
// Pozisyonu doğrudan değiştir (ör: playerShip)
obj.x += dx / dist * force * 2.2;
obj.y += dy / dist * force * 2.2;
}
}
}
// Kara delik ömrü
self.age++;
if (self.age > self.lifeTicks) {
// Fade out ve yok ol
tween(self, {
alpha: 0,
scaleX: 0.2,
scaleY: 0.2
}, {
duration: 600,
onFinish: function onFinish() {
if (self && self.parent) self.destroy();
}
});
}
};
return self;
});
// Mermi (Bullet) - SAĞA DOĞRU
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletAsset = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
// Asset: ellipse, width: 32, height: 32, color: 0xffe066
bulletAsset.width = 32;
bulletAsset.height = 32;
bulletAsset.color = 0xffe066;
self.speed = typeof game !== "undefined" && game._bulletSpeedUp ? 32 : 18; // bulletspeed power-up aktifse hızlı
// Dynamic spawn effect: scale up and fade in
self.scaleX = 0.5;
self.scaleY = 0.5;
self.alpha = 0.0;
tween(self, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 200,
easing: tween.easeOut
});
self.update = function () {
self.x += self.speed;
};
return self;
});
// EnemyBullet - DÜŞMAN MERMİSİ (sola doğru)
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletAsset = self.attachAsset('dusmanmermi', {
anchorX: 0.5,
anchorY: 0.5
});
bulletAsset.width = 32;
bulletAsset.height = 32;
bulletAsset.color = 0xff4444;
self.speed = -10; // Sola doğru (reduced speed)
// Dynamic spawn effect: scale up and fade in
self.scaleX = 0.5;
self.scaleY = 0.5;
self.alpha = 0.0;
tween(self, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 200,
easing: tween.easeOut
});
self.update = function () {
self.x += self.speed;
};
return self;
});
// EnemyShip - SAĞDAN SOLA
var EnemyShip = Container.expand(function () {
var self = Container.call(this);
var width = 100;
var height = 100;
var objAsset = self.attachAsset('uzayNesnesi2', {
anchorX: 0.5,
anchorY: 0.5
});
objAsset.width = width;
objAsset.height = height;
objAsset.color = 0xff4444;
self.radius = width / 2;
self.x = 2048 + width;
self.y = 200 + Math.random() * (2732 - 400);
// Dynamic spawn effect: scale up and fade in
self.scaleX = 0.6;
self.scaleY = 0.6;
self.alpha = 0.0;
tween(self, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
// Speed will be set on spawn
self.vx = -10;
self.vy = (Math.random() - 0.5) * 3;
self.update = function () {
self.x += self.vx;
self.y += self.vy;
};
return self;
});
// MeteorStone - SAĞDAN SOLA, rastgele gelen düşman türü
var MeteorStone = Container.expand(function () {
var self = Container.call(this);
var width = 120 + Math.random() * 60;
var height = 120 + Math.random() * 60;
var objAsset = self.attachAsset('meteorstone', {
anchorX: 0.5,
anchorY: 0.5
});
objAsset.width = width;
objAsset.height = height;
self.radius = width / 2;
// Always spawn at right edge, random Y, move left
self.x = 2048 + width;
self.y = 200 + Math.random() * (2732 - 400);
// Dynamic spawn effect: scale up and fade in
self.scaleX = 0.6;
self.scaleY = 0.6;
self.alpha = 0.0;
tween(self, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
// Hız: asteroidlerden biraz daha hızlı olabilir
var baseSpeed = 3 + Math.random() * 2;
self.vx = -baseSpeed;
self.vy = (Math.random() - 0.5) * 2.5;
self.update = function () {
self.x += self.vx;
self.y += self.vy;
};
return self;
});
// Uzay Aracı (Player Ship)
var PlayerShip = Container.expand(function () {
var self = Container.call(this);
// Ship asset: blue ellipse
var shipAsset = self.attachAsset('playerShip', {
anchorX: 0.5,
anchorY: 0.5
});
// Asset will be created as: ellipse, width: 140, height: 100, color: 0x3a9cff
shipAsset.width = 140;
shipAsset.height = 100;
shipAsset.color = 0x3a9cff;
self.radius = 70; // For collision
self.update = function () {
// Otomatik sağa ilerleme kaldırıldı, sadece otomatik portal hareketi sırasında hareket etsin
};
return self;
});
// Uzay Cismi (Asteroid/Enemy) - SAĞDAN SOLA
var SpaceObject = Container.expand(function () {
var self = Container.call(this);
// Randomly choose asteroid or enemy
var isAsteroid = Math.random() < 0.7;
var color = isAsteroid ? 0x888888 : 0xff4444;
var width = isAsteroid ? 120 + Math.random() * 60 : 100;
var height = isAsteroid ? 120 + Math.random() * 60 : 100;
var objAsset = self.attachAsset('spaceObject', {
anchorX: 0.5,
anchorY: 0.5
});
objAsset.width = width;
objAsset.height = height;
objAsset.color = color;
self.radius = width / 2;
// Always spawn at right edge, random Y, move left
self.x = 2048 + width;
self.y = 200 + Math.random() * (2732 - 400);
// Dynamic spawn effect: scale up and fade in
self.scaleX = 0.6;
self.scaleY = 0.6;
self.alpha = 0.0;
tween(self, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
var speed = 6 + Math.random() * 4;
self.vx = -speed;
self.vy = (Math.random() - 0.5) * 2; // hafif yukarı/aşağı varyasyon
self.update = function () {
self.x += self.vx;
self.y += self.vy;
};
return self;
});
/****
* Initialize Game
****/
// Create and add stars to the background
var game = new LK.Game({
backgroundColor: 0x000010
});
/****
* Game Code
****/
// --- DYNAMIC SPACE BACKGROUND FOR MAIN MENU ---
// Starfield, nebula, galaxies, asteroids, ship silhouettes, satellites, particles
var starBgCount = 120;
var stars = [];
var starBgContainer = new Container();
for (var i = 0; i < starBgCount; i++) {
var starSize = 1.5 + Math.random() * 3.5;
var star = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 2732,
width: starSize,
height: starSize
});
star.alpha = 0.18 + Math.random() * 0.82;
star._vx = 0.3 + Math.random() * 1.1;
star._rotSpeed = (Math.random() - 0.5) * 0.008;
star._twinkle = Math.random() * Math.PI * 2;
stars.push(star);
starBgContainer.addChild(star);
}
// Add distant nebulae (soft colored, slow parallax)
var nebulae = [];
for (var n = 0; n < 2; n++) {
var nebula = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: 400 + Math.random() * 1200,
y: 400 + Math.random() * 1800,
width: 900 + Math.random() * 400,
height: 400 + Math.random() * 300
});
nebula.alpha = 0.13 + Math.random() * 0.09;
nebula.color = n === 0 ? 0x6e4fff : 0x2fd6c7;
nebula._vx = 0.08 + Math.random() * 0.07;
nebula._vy = 0.01 + Math.random() * 0.03;
nebula._pulse = Math.random() * Math.PI * 2;
nebulae.push(nebula);
starBgContainer.addChild(nebula);
}
// Add distant galaxies (faint, slow, colored ellipses)
var galaxies = [];
for (var g = 0; g < 2; g++) {
var galaxy = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: 300 + Math.random() * 1400,
y: 300 + Math.random() * 1800,
width: 600 + Math.random() * 300,
height: 220 + Math.random() * 120
});
galaxy.alpha = 0.09 + Math.random() * 0.07;
galaxy.color = g === 0 ? 0xf7b32b : 0x9b59b6;
galaxy._vx = 0.04 + Math.random() * 0.04;
galaxy._vy = 0.01 + Math.random() * 0.02;
galaxy._rotSpeed = (Math.random() - 0.5) * 0.002;
galaxies.push(galaxy);
starBgContainer.addChild(galaxy);
}
// Add asteroid flybys (move right to left, fade in/out)
var menuAsteroids = [];
function spawnMenuAsteroid() {
var y = 100 + Math.random() * (2732 - 200);
var size = 60 + Math.random() * 60;
var asteroid = LK.getAsset('meteorstone', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 + size,
y: y,
width: size,
height: size
});
asteroid.alpha = 0.0;
asteroid._vx = 2.5 + Math.random() * 2.5;
asteroid._fadeIn = true;
asteroid._fadeOut = false;
menuAsteroids.push(asteroid);
starBgContainer.addChild(asteroid);
tween(asteroid, {
alpha: 0.7
}, {
duration: 400,
onFinish: function onFinish() {
asteroid._fadeIn = false;
}
});
}
var asteroidSpawnTick = 0;
// Add ship silhouettes (fly by, faint, slow)
var menuShips = [];
function spawnMenuShip() {
var y = 200 + Math.random() * (2732 - 400);
var size = 80 + Math.random() * 40;
var ship = LK.getAsset('playership2', {
anchorX: 0.5,
anchorY: 0.5,
x: -size,
y: y,
width: size,
height: size * 0.7
});
ship.alpha = 0.13 + Math.random() * 0.09;
ship._vx = 2.2 + Math.random() * 1.2;
ship._fadeOut = false;
menuShips.push(ship);
starBgContainer.addChild(ship);
}
var shipSpawnTick = 0;
// Add satellites (blink, move slowly)
var menuSatellites = [];
function spawnMenuSatellite() {
var y = 150 + Math.random() * (2732 - 300);
var size = 38 + Math.random() * 18;
var sat = LK.getAsset('spaceObject', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 + size,
y: y,
width: size,
height: size
});
sat.alpha = 0.22 + Math.random() * 0.13;
sat._vx = 0.7 + Math.random() * 0.7;
sat._blink = Math.random() * Math.PI * 2;
menuSatellites.push(sat);
starBgContainer.addChild(sat);
}
var satelliteSpawnTick = 0;
// Add particle trails (random, faint, slow)
var menuParticles = [];
function spawnMenuParticle() {
var x = Math.random() * 2048;
var y = Math.random() * 2732;
var size = 8 + Math.random() * 12;
var p = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y,
width: size,
height: size
});
p.alpha = 0.08 + Math.random() * 0.08;
p._vy = 0.5 + Math.random() * 0.7;
p._life = 60 + Math.floor(Math.random() * 60);
menuParticles.push(p);
starBgContainer.addChild(p);
}
var particleSpawnTick = 0;
game.addChild(starBgContainer); // Add all menu background elements
// --- HOLOGRAPHIC-STYLE FLOATING MENU & LOGO ---
// Centered floating menu container
var startMenuContainer = new Container();
if (!startMenuContainer.parent) {
startMenuContainer.alpha = 1;
startMenuContainer.scaleX = 1;
startMenuContainer.scaleY = 1;
game.addChild(startMenuContainer);
}
// Menu colors and layout
var menuBgColor = 0x181c2b;
var menuButtonColors = [0x3a9cff, 0x4e5d94, 0x7cbb37, 0xf7b32b];
var menuWidth = 1000;
var menuHeight = 1100;
// Holographic menu background (glow, border, glass effect)
var borderBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: menuWidth / 2,
y: menuHeight / 2,
width: menuWidth + 54,
height: menuHeight + 54
});
borderBg.alpha = 0.22;
borderBg.color = 0x0a0e1a;
startMenuContainer.addChild(borderBg);
var startMenuBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: menuWidth / 2,
y: menuHeight / 2,
width: menuWidth,
height: menuHeight
});
startMenuBg.alpha = 0.93;
startMenuBg.color = menuBgColor;
startMenuContainer.addChild(startMenuBg);
// Holographic glass overlay
var holoOverlay = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: menuWidth / 2,
y: menuHeight / 2,
width: menuWidth,
height: menuHeight
});
holoOverlay.alpha = 0.13;
holoOverlay.color = 0x3a9cff;
startMenuContainer.addChild(holoOverlay);
// --- LOGO: floating, pulsing, above menu ---
var logoText = new Text2("UZAY MACERASI", {
size: 160,
fill: 0xFFE066
});
logoText.anchor.set(0.5, 0.5);
logoText.x = menuWidth / 2;
logoText.y = 60;
logoText.alpha = 0.97;
startMenuContainer.addChild(logoText);
// Logo energy pulse effect (handled in update below)
logoText._pulseBase = 1.0;
// --- HOLOGRAPHIC BUTTONS ---
// Button layout: arc or vertical
var menuButtons = [{
label: "Start Game",
key: "start",
color: 0x3a9cff
}, {
label: "Load",
key: "load",
color: 0x4e5d94
}, {
label: "Settings",
key: "options",
color: 0x7cbb37
}, {
label: "Exit",
key: "exit",
color: 0xf7b32b
}];
var buttonHeight = 140;
var buttonWidth = 600;
var buttonSpacing = 48;
var firstBtnY = 320;
var btnBgList = [];
var btnTextList = [];
for (var i = 0; i < menuButtons.length; i++) {
// Arc layout: slight curve, or vertical
var arcAngle = (i - (menuButtons.length - 1) / 2) * 0.18;
var btnY = firstBtnY + i * (buttonHeight + buttonSpacing) + Math.sin(arcAngle) * 40;
var btnX = menuWidth / 2 + Math.sin(arcAngle) * 120;
// Button shadow
var btnBgShadow = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: btnX + 8,
y: btnY + 10,
width: buttonWidth + 24,
height: buttonHeight + 18
});
btnBgShadow.alpha = 0.16;
btnBgShadow.color = 0x000000;
startMenuContainer.addChild(btnBgShadow);
// Button background (holographic, glowing)
var btnBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: btnX,
y: btnY,
width: buttonWidth,
height: buttonHeight
});
btnBg.alpha = 0.93;
btnBg.color = menuButtonColors[i % menuButtonColors.length];
btnBg.menuKey = menuButtons[i].key;
btnBg.buttonIndex = i;
btnBg.interactive = true;
btnBg.defaultAlpha = btnBg.alpha;
btnBg._glow = 0.0;
// Button hover/tap effect
btnBg.down = function (btn) {
return function (x, y, obj) {
btn.alpha = 0.65;
tween(btn, {
alpha: btn.defaultAlpha
}, {
duration: 120
});
// TODO: play soft electronic sound here if sound enabled
// Button action
if (btn.menuKey === "start") {
tween(startMenuContainer, {
alpha: 0,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 350,
onFinish: function onFinish() {
if (startMenuContainer && startMenuContainer.parent) startMenuContainer.destroy();
timeLeft = gameDuration;
updateTimerDisplay();
gameStarted = true;
}
});
} else if (btn.menuKey === "exit") {
// Exit: fade out and reload (simulate exit)
tween(startMenuContainer, {
alpha: 0,
scaleX: 0.7,
scaleY: 0.7
}, {
duration: 350,
onFinish: function onFinish() {
if (startMenuContainer && startMenuContainer.parent) startMenuContainer.destroy();
// Simulate exit: reload page
if (typeof window !== "undefined" && window.location) window.location.reload();
}
});
} else {
// Open modal for load/settings
if (startMenuContainer && startMenuContainer.parent) {
startMenuContainer.visible = false;
}
var modalW = 800;
var modalH = 700;
var modalContainer = new Container();
var modalBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2,
y: modalH / 2,
width: modalW,
height: modalH
});
modalBg.alpha = 0.96;
modalBg.color = 0x181c2b;
modalContainer.addChild(modalBg);
var modalTitle = btn.menuKey === "load" ? "Load Game" : "Settings";
var modalContent = btn.menuKey === "load" ? "No saved games found." : "Adjust your settings here.";
var modalTitleText = new Text2(modalTitle, {
size: 100,
fill: 0xFFE066,
maxWidth: modalW - 80
});
modalTitleText.anchor.set(0.5, 0.5);
modalTitleText.x = modalW / 2;
modalTitleText.y = 120;
modalContainer.addChild(modalTitleText);
var modalContentText = new Text2(modalContent, {
size: 60,
fill: "#fff",
maxWidth: modalW - 80
});
modalContentText.anchor.set(0.5, 0);
modalContentText.x = modalW / 2;
modalContentText.y = 220;
modalContainer.addChild(modalContentText);
// Close button
var closeBtnW = 320;
var closeBtnH = 100;
var closeBtnY = modalH - closeBtnH / 2 - 24;
var closeBtnBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2,
y: closeBtnY,
width: closeBtnW,
height: closeBtnH
});
closeBtnBg.alpha = 0.85;
closeBtnBg.color = 0x3a9cff;
closeBtnBg.interactive = true;
closeBtnBg.down = function () {
return function (x, y, obj) {
if (modalContainer && modalContainer.parent) modalContainer.destroy();
if (startMenuContainer && !startMenuContainer.parent) {
startMenuContainer.visible = true;
game.addChild(startMenuContainer);
}
};
}();
modalContainer.addChild(closeBtnBg);
var closeBtnText = new Text2("Close", {
size: 70,
fill: "#fff"
});
closeBtnText.anchor.set(0.5, 0.5);
closeBtnText.x = modalW / 2;
closeBtnText.y = closeBtnY;
closeBtnText.interactive = true;
closeBtnText.down = function (bgRef) {
return function (x, y, obj) {
if (bgRef && bgRef.down) bgRef.down(x, y, obj);
};
}(closeBtnBg);
modalContainer.addChild(closeBtnText);
modalContainer.x = 2048 / 2 - modalW / 2;
modalContainer.y = 2732 / 2 - modalH / 2;
game.addChild(modalContainer);
}
};
}(btnBg);
btnBgList.push(btnBg);
startMenuContainer.addChild(btnBg);
// Button glow overlay
var btnGlow = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: btnX,
y: btnY,
width: buttonWidth * 1.08,
height: buttonHeight * 1.18
});
btnGlow.alpha = 0.0;
btnGlow.color = 0xffffff;
btnBg._glowOverlay = btnGlow;
startMenuContainer.addChild(btnGlow);
// Button highlight
var btnHighlight = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: btnX,
y: btnY - buttonHeight / 3,
width: buttonWidth * 0.92,
height: buttonHeight * 0.38
});
btnHighlight.alpha = 0.18;
btnHighlight.color = 0xffffff;
startMenuContainer.addChild(btnHighlight);
// Button text
var btnText = new Text2(menuButtons[i].label, {
size: 100,
fill: "#fff",
maxWidth: buttonWidth - 60
});
btnText.anchor.set(0.5, 0.5);
btnText.x = btnX;
btnText.y = btnY;
btnText.menuKey = menuButtons[i].key;
btnText.buttonIndex = i;
btnText.interactive = true;
btnText.defaultAlpha = 1;
btnText.down = function (btnBgRef, btnTextRef) {
return function (x, y, obj) {
btnTextRef.alpha = 0.65;
tween(btnTextRef, {
alpha: btnTextRef.defaultAlpha
}, {
duration: 120
});
if (btnBgRef && btnBgRef.down) btnBgRef.down(x, y, obj);
};
}(btnBg, btnText);
btnTextList.push(btnText);
startMenuContainer.addChild(btnText);
}
// Info text
var infoText = new Text2("Drag the ship, shoot space objects!", {
size: 70,
fill: "#fff",
maxWidth: menuWidth - 80
});
infoText.anchor.set(0.5, 0.5);
infoText.x = menuWidth / 2;
infoText.y = startMenuBg.y + startMenuBg.height / 2 + 48;
startMenuContainer.addChild(infoText);
// Copyright
var copyrightText = new Text2("© 2024 FRVR.Ava.Combo[POGAAS]", {
size: 38,
fill: 0xB0E0FF
});
copyrightText.anchor.set(0.5, 0.5);
copyrightText.x = menuWidth / 2;
copyrightText.y = menuHeight - 32;
startMenuContainer.addChild(copyrightText);
// Center menu on screen
startMenuContainer.x = 2048 / 2 - menuWidth / 2;
startMenuContainer.y = 2732 / 2 - menuHeight / 2;
// Dinamik butonlar
var menuButtons = [{
label: "Yeni Oyun",
key: "start",
color: 0x3a9cff
}, {
label: "Seçenekler",
key: "options",
color: 0x4e5d94
}, {
label: "Rekorlar",
key: "scores",
color: 0x7cbb37
}, {
label: "Hakkında",
key: "about",
color: 0xf7b32b
}];
var buttonHeight = 140;
var buttonWidth = 600;
var buttonSpacing = 48;
var firstBtnY = 400;
var btnBgList = [];
var btnTextList = [];
for (var i = 0; i < menuButtons.length; i++) {
var btnY = firstBtnY + i * (buttonHeight + buttonSpacing);
// Butonun arka planı (hafif gölgeli, modern)
var btnBgShadow = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: menuWidth / 2 + 8,
y: btnY + 10,
width: buttonWidth + 24,
height: buttonHeight + 18
});
btnBgShadow.alpha = 0.18;
btnBgShadow.color = 0x000000;
startMenuContainer.addChild(btnBgShadow);
var btnBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: menuWidth / 2,
y: btnY,
width: buttonWidth,
height: buttonHeight
});
btnBg.alpha = 0.92;
btnBg.color = menuButtonColors[i % menuButtonColors.length];
btnBg.menuKey = menuButtons[i].key;
btnBg.buttonIndex = i;
btnBg.interactive = true; // Buton tıklanabilir olsun
btnBg.defaultAlpha = btnBg.alpha; // Tıklama efekti için orijinal alpha
btnBg.down = function (btn) {
return function (x, y, obj) {
// Tıklama efekti: sadece bu buton için kısa bir görsel geri bildirim uygula
btn.alpha = 0.65;
tween(btn, {
alpha: btn.defaultAlpha
}, {
duration: 120
});
// Her butonun kendi işlevi
if (btn.menuKey === "start") {
// Menü animasyonla kaybolsun ve oyun başlasın
tween(startMenuContainer, {
alpha: 0,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 350,
onFinish: function onFinish() {
if (startMenuContainer && startMenuContainer.parent) startMenuContainer.destroy();
// Oyun başladığında süreyi 3 dakikaya (180 saniye) sıfırla
timeLeft = gameDuration;
updateTimerDisplay();
gameStarted = true;
}
});
} else {
// Her menü butonu için yeni bir ekran (modal) aç
// Ana menü ekranını gizle
if (startMenuContainer && startMenuContainer.parent) {
startMenuContainer.visible = false;
}
var modalW = 800;
var modalH = 700;
var modalContainer = new Container();
var modalBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2,
y: modalH / 2,
width: modalW,
height: modalH
});
modalBg.alpha = 0.96;
modalBg.color = 0x181c2b;
modalContainer.addChild(modalBg);
var modalTitle = "";
var modalContent = "";
if (btn.menuKey === "options") {
modalTitle = "Mağaza";
modalContent = "";
// Satın alınabilir ürünler
var storeProducts = [{
name: "Ekstra Can Paketi",
desc: "Canını 3 artırır.",
price: 100
}, {
name: "Mega Lazer",
desc: "Süper güçlü lazer ile 10 saniye boyunca ateş et!",
price: 250
}, {
name: "Kalkan Güçlendirme",
desc: "10 saniye boyunca hasar almazsın.",
price: 180
}, {
name: "Hız Artırıcı",
desc: "Geminin hızı 10 saniye boyunca artar.",
price: 120
}, {
name: "Süper Mermi",
desc: "Mermilerin 10 saniye boyunca çok hızlı gider.",
price: 150
}, {
name: "Uzay Gemisi Kaplaması",
desc: "Geminin görünümünü değiştir.",
price: 300
}];
// Ürünleri listele ve satın al butonları ekle
var productBtnH = 110;
var productBtnW = 600;
var productBtnSpacing = 24;
var firstProductY = 260;
for (var p = 0; p < storeProducts.length; p++) {
var prod = storeProducts[p];
var prodY = firstProductY + p * (productBtnH + productBtnSpacing);
// Ürün kutusu
var prodBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2,
y: prodY,
width: productBtnW,
height: productBtnH
});
prodBg.alpha = 0.92;
prodBg.color = 0x232a3d;
modalContainer.addChild(prodBg);
// Ürün adı
var prodName = new Text2(prod.name, {
size: 54,
fill: "#fff",
maxWidth: productBtnW - 220
});
prodName.anchor.set(0, 0.5);
prodName.x = modalW / 2 - productBtnW / 2 + 32;
prodName.y = prodY;
modalContainer.addChild(prodName);
// Ürün açıklaması
var prodDesc = new Text2(prod.desc, {
size: 36,
fill: 0xB0E0FF,
maxWidth: productBtnW - 220
});
prodDesc.anchor.set(0, 0.5);
prodDesc.x = modalW / 2 - productBtnW / 2 + 32;
prodDesc.y = prodY + 38;
modalContainer.addChild(prodDesc);
// Fiyat etiketi
var priceTag = new Text2(prod.price + " 💎", {
size: 44,
fill: 0xFFE066
});
priceTag.anchor.set(1, 0.5);
priceTag.x = modalW / 2 + productBtnW / 2 - 120;
priceTag.y = prodY;
modalContainer.addChild(priceTag);
// Satın al butonu
var buyBtn = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2 + productBtnW / 2 - 60,
y: prodY,
width: 100,
height: 80
});
buyBtn.alpha = 0.85;
buyBtn.color = 0x3a9cff;
buyBtn.interactive = true;
buyBtn.down = function (prod, buyBtnRef) {
return function (x, y, obj) {
// Satın alma işlemi (örnek: elmas bakiyesi yok, sadece görsel feedback)
buyBtnRef.alpha = 0.65;
tween(buyBtnRef, {
alpha: 0.85
}, {
duration: 120
});
// Satın alma bildirimi
var boughtText = new Text2("Satın alındı!", {
size: 44,
fill: 0x7CBB37
});
boughtText.anchor.set(0.5, 0.5);
boughtText.x = buyBtnRef.x;
boughtText.y = buyBtnRef.y - 60;
modalContainer.addChild(boughtText);
tween(boughtText, {
alpha: 0
}, {
duration: 900,
onFinish: function onFinish() {
boughtText.destroy();
}
});
};
}(prod, buyBtn);
modalContainer.addChild(buyBtn);
// Satın al butonu yazısı
var buyBtnText = new Text2("Satın Al", {
size: 36,
fill: "#fff"
});
buyBtnText.anchor.set(0.5, 0.5);
buyBtnText.x = buyBtn.x;
buyBtnText.y = buyBtn.y;
buyBtnText.interactive = true;
buyBtnText.down = function (buyBtnRef) {
return function (x, y, obj) {
if (buyBtnRef && buyBtnRef.down) buyBtnRef.down(x, y, obj);
};
}(buyBtn);
modalContainer.addChild(buyBtnText);
}
} else if (btn.menuKey === "scores") {
modalTitle = "Rekorlar";
modalContent = "Rekorlar: En yüksek skorlar yakında!";
} else if (btn.menuKey === "about") {
modalTitle = "Hakkında";
modalContent = "Uzay Macerası - FRVR.Ava.Combo[POGAAS].v1.0";
}
var modalTitleText = new Text2(modalTitle, {
size: 100,
fill: 0xFFE066,
maxWidth: modalW - 80 // kutu kenarından taşmasın
});
modalTitleText.anchor.set(0.5, 0.5);
modalTitleText.x = modalW / 2;
modalTitleText.y = 120;
modalContainer.addChild(modalTitleText);
var modalContentText = new Text2(modalContent, {
size: 60,
fill: "#fff",
maxWidth: modalW - 80 // kutu kenarından taşmasın
});
modalContentText.anchor.set(0.5, 0);
modalContentText.x = modalW / 2;
modalContentText.y = 220;
modalContainer.addChild(modalContentText);
// Kapat butonu
var closeBtnW = 320;
var closeBtnH = 100;
// Move close button to the very bottom of the modal
var closeBtnY = modalH - closeBtnH / 2 - 24;
var closeBtnBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2,
y: closeBtnY,
width: closeBtnW,
height: closeBtnH
});
closeBtnBg.alpha = 0.85;
closeBtnBg.color = 0x3a9cff;
closeBtnBg.interactive = true;
closeBtnBg.down = function () {
return function (x, y, obj) {
if (modalContainer && modalContainer.parent) modalContainer.destroy();
// Modal kapatıldığında ana menüyü tekrar göster
if (startMenuContainer && !startMenuContainer.parent) {
startMenuContainer.visible = true;
game.addChild(startMenuContainer);
}
};
}();
modalContainer.addChild(closeBtnBg);
var closeBtnText = new Text2("Kapat", {
size: 70,
fill: "#fff"
});
closeBtnText.anchor.set(0.5, 0.5);
closeBtnText.x = modalW / 2;
closeBtnText.y = closeBtnY;
closeBtnText.interactive = true;
closeBtnText.down = function (bgRef) {
return function (x, y, obj) {
if (bgRef && bgRef.down) bgRef.down(x, y, obj);
};
}(closeBtnBg);
modalContainer.addChild(closeBtnText);
// Kapat butonu artık ana menüye döndürür
closeBtnBg.down = function () {
return function (x, y, obj) {
if (modalContainer && modalContainer.parent) modalContainer.destroy();
// Modal kapatıldığında ana menüyü tekrar göster
if (startMenuContainer) {
startMenuContainer.visible = true;
if (!startMenuContainer.parent) {
game.addChild(startMenuContainer);
}
}
};
}();
// Ortala ve ekrana ekle
modalContainer.x = 2048 / 2 - modalW / 2;
modalContainer.y = 2732 / 2 - modalH / 2;
game.addChild(modalContainer);
}
};
}(btnBg);
btnBgList.push(btnBg);
startMenuContainer.addChild(btnBg);
// Butonun üstüne hafif bir parlaklık efekti (degrade gibi)
var btnHighlight = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: menuWidth / 2,
y: btnY - buttonHeight / 3,
width: buttonWidth * 0.92,
height: buttonHeight * 0.38
});
btnHighlight.alpha = 0.18;
btnHighlight.color = 0xffffff;
startMenuContainer.addChild(btnHighlight);
var btnText = new Text2(menuButtons[i].label, {
size: 100,
fill: "#fff",
maxWidth: buttonWidth - 60 // buton kenarından taşmasın
});
btnText.anchor.set(0.5, 0.5);
btnText.x = menuWidth / 2;
btnText.y = btnY;
btnText.menuKey = menuButtons[i].key;
btnText.buttonIndex = i;
btnText.interactive = true;
btnText.defaultAlpha = 1;
btnText.down = function (btnBgRef, btnTextRef) {
return function (x, y, obj) {
// Text label dokunulduğunda kısa bir görsel geri bildirim uygula
btnTextRef.alpha = 0.65;
tween(btnTextRef, {
alpha: btnTextRef.defaultAlpha
}, {
duration: 120
});
// Sadece kendi butonunun down fonksiyonunu tetikle
if (btnBgRef && btnBgRef.down) {
btnBgRef.down(x, y, obj);
}
};
}(btnBg, btnText);
btnTextList.push(btnText);
startMenuContainer.addChild(btnText);
}
// Bilgilendirici kısa açıklama
var infoText = new Text2("Gemiyi sürükle, mermilerle uzay cisimlerini vur!", {
size: 70,
fill: "#fff",
maxWidth: menuWidth - 80 // kutu kenarından taşmasın
});
infoText.anchor.set(0.5, 0.5);
infoText.x = menuWidth / 2;
// Kırmızı bölümün altına hizala: kırmızı bölümün altı = startMenuBg.y + startMenuBg.height/2
infoText.y = startMenuBg.y + startMenuBg.height / 2 + 48;
startMenuContainer.addChild(infoText);
// Alt kısımda küçük bir imza
var copyrightText = new Text2("© 2024 FRVR.Ava.Combo[POGAAS]", {
size: 38,
fill: 0xB0E0FF
});
copyrightText.anchor.set(0.5, 0.5);
copyrightText.x = menuWidth / 2;
copyrightText.y = menuHeight - 32;
startMenuContainer.addChild(copyrightText);
// Ortala ve ekrana ekle
startMenuContainer.x = 2048 / 2 - menuWidth / 2;
startMenuContainer.y = 2732 / 2 - menuHeight / 2;
// Oyun başında menü ekrana eklenmez, intro bitince eklenir
// game.addChild(startMenuContainer);
// Oyun başlamadan tüm kontrolleri ve update'i devre dışı bırak
var gameStarted = false;
// Ava: Dinamik duraklatma menüsü (Devam et, Yeniden başlat, Menü)
var pauseMenuContainer = null;
function showPauseMenu() {
// Pause menu should not be shown in the main menu
if (!gameStarted) return;
if (pauseMenuContainer && pauseMenuContainer.parent) return;
if (pauseMenuContainer) pauseMenuContainer.destroy();
var pauseMenuW = 800;
var pauseMenuH = 700;
pauseMenuContainer = new Container();
var pauseBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: pauseMenuW / 2,
y: pauseMenuH / 2,
width: pauseMenuW,
height: pauseMenuH
});
pauseBg.alpha = 0.93;
pauseBg.color = 0x181c2b;
pauseMenuContainer.addChild(pauseBg);
var pauseTitle = new Text2("Oyun Duraklatıldı", {
size: 110,
fill: 0xFFE066
});
pauseTitle.anchor.set(0.5, 0.5);
pauseTitle.x = pauseMenuW / 2;
pauseTitle.y = 140;
pauseMenuContainer.addChild(pauseTitle);
// Yeni seçenek menüsü: Oyun duraklatıldığında ekrana gelsin
var optionsMenuButtons = [{
label: "Devam et",
key: "resume",
color: 0x3a9cff
}, {
label: "Yeniden başlat",
key: "restart",
color: 0x7cbb37
}, {
label: "Menü",
key: "menu",
color: 0xf7b32b
}, {
label: "Ses Ayarları",
key: "sound",
color: 0x4e5d94
}, {
label: "Yardım",
key: "help",
color: 0x9b59b6
}];
var pBtnH = 110;
var pBtnW = 420;
var pBtnSpacing = 28;
var pFirstBtnY = 260;
for (var i = 0; i < optionsMenuButtons.length; i++) {
var pBtnY = pFirstBtnY + i * (pBtnH + pBtnSpacing);
var pBtnBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: pauseMenuW / 2,
y: pBtnY,
width: pBtnW,
height: pBtnH
});
pBtnBg.alpha = 0.85;
pBtnBg.color = optionsMenuButtons[i].color;
pBtnBg.pauseKey = optionsMenuButtons[i].key;
pBtnBg.defaultAlpha = pBtnBg.alpha;
pBtnBg.interactive = true;
pBtnBg.down = function (btn) {
return function (x, y, obj) {
btn.alpha = 0.65;
tween(btn, {
alpha: btn.defaultAlpha
}, {
duration: 120
});
if (btn.pauseKey === "resume") {
// Devam et: menüyü kapat, oyuna devam et
if (pauseMenuContainer && pauseMenuContainer.parent) pauseMenuContainer.destroy();
gameStarted = true;
} else if (btn.pauseKey === "restart") {
// Yeniden başlat: oyunu baştan başlat
LK.restartGame();
} else if (btn.pauseKey === "menu") {
// Menü: ana menüyü göster, pause menüsünü kapat
if (pauseMenuContainer && pauseMenuContainer.parent) pauseMenuContainer.destroy();
showMenu();
} else if (btn.pauseKey === "sound") {
// Ses ayarları: yeni bir modal aç
var modalW = 700;
var modalH = 400;
var modalContainer = new Container();
var modalBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2,
y: modalH / 2,
width: modalW,
height: modalH
});
modalBg.alpha = 0.96;
modalBg.color = 0x181c2b;
modalContainer.addChild(modalBg);
var modalTitle = new Text2("Ses Ayarları", {
size: 80,
fill: 0xFFE066,
maxWidth: modalW - 60
});
modalTitle.anchor.set(0.5, 0.5);
modalTitle.x = modalW / 2;
modalTitle.y = 80;
modalContainer.addChild(modalTitle);
var modalContent = new Text2("Ses ayarları burada olacak.", {
size: 50,
fill: "#fff",
maxWidth: modalW - 60
});
modalContent.anchor.set(0.5, 0);
modalContent.x = modalW / 2;
modalContent.y = 160;
modalContainer.addChild(modalContent);
// Kapat butonu
var closeBtnW = 220;
var closeBtnH = 80;
var closeBtnY = modalH - 80;
var closeBtnBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2,
y: closeBtnY,
width: closeBtnW,
height: closeBtnH
});
closeBtnBg.alpha = 0.85;
closeBtnBg.color = 0x3a9cff;
closeBtnBg.interactive = true;
closeBtnBg.down = function () {
return function (x, y, obj) {
if (modalContainer && modalContainer.parent) modalContainer.destroy();
};
}();
modalContainer.addChild(closeBtnBg);
var closeBtnText = new Text2("Kapat", {
size: 60,
fill: "#fff"
});
closeBtnText.anchor.set(0.5, 0.5);
closeBtnText.x = modalW / 2;
closeBtnText.y = closeBtnY;
closeBtnText.interactive = true;
closeBtnText.down = function (bgRef) {
return function (x, y, obj) {
if (bgRef && bgRef.down) bgRef.down(x, y, obj);
};
}(closeBtnBg);
modalContainer.addChild(closeBtnText);
// Ortala ve ekrana ekle
modalContainer.x = 2048 / 2 - modalW / 2;
modalContainer.y = 2732 / 2 - modalH / 2;
game.addChild(modalContainer);
} else if (btn.pauseKey === "help") {
// Yardım: yeni bir modal aç
var modalW = 700;
var modalH = 400;
var modalContainer = new Container();
var modalBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2,
y: modalH / 2,
width: modalW,
height: modalH
});
modalBg.alpha = 0.96;
modalBg.color = 0x181c2b;
modalContainer.addChild(modalBg);
var modalTitle = new Text2("Yardım", {
size: 80,
fill: 0xFFE066,
maxWidth: modalW - 60
});
modalTitle.anchor.set(0.5, 0.5);
modalTitle.x = modalW / 2;
modalTitle.y = 80;
modalContainer.addChild(modalTitle);
var modalContent = new Text2("Gemiyi sürükle, mermilerle uzay cisimlerini vur!", {
size: 50,
fill: "#fff",
maxWidth: modalW - 60
});
modalContent.anchor.set(0.5, 0);
modalContent.x = modalW / 2;
modalContent.y = 160;
modalContainer.addChild(modalContent);
// Kapat butonu
var closeBtnW = 220;
var closeBtnH = 80;
var closeBtnY = modalH - 80;
var closeBtnBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: modalW / 2,
y: closeBtnY,
width: closeBtnW,
height: closeBtnH
});
closeBtnBg.alpha = 0.85;
closeBtnBg.color = 0x3a9cff;
closeBtnBg.interactive = true;
closeBtnBg.down = function () {
return function (x, y, obj) {
if (modalContainer && modalContainer.parent) modalContainer.destroy();
};
}();
modalContainer.addChild(closeBtnBg);
var closeBtnText = new Text2("Kapat", {
size: 60,
fill: "#fff"
});
closeBtnText.anchor.set(0.5, 0.5);
closeBtnText.x = modalW / 2;
closeBtnText.y = closeBtnY;
closeBtnText.interactive = true;
closeBtnText.down = function (bgRef) {
return function (x, y, obj) {
if (bgRef && bgRef.down) bgRef.down(x, y, obj);
};
}(closeBtnBg);
modalContainer.addChild(closeBtnText);
// Ortala ve ekrana ekle
modalContainer.x = 2048 / 2 - modalW / 2;
modalContainer.y = 2732 / 2 - modalH / 2;
game.addChild(modalContainer);
}
};
}(pBtnBg);
pauseMenuContainer.addChild(pBtnBg);
var pBtnText = new Text2(optionsMenuButtons[i].label, {
size: 80,
fill: "#fff",
maxWidth: pBtnW - 40 // buton kenarından taşmasın
});
pBtnText.anchor.set(0.5, 0.5);
pBtnText.x = pauseMenuW / 2;
pBtnText.y = pBtnY;
pBtnText.interactive = true;
pBtnText.defaultAlpha = 1;
pBtnText.down = function (btnBgRef, btnTextRef) {
return function (x, y, obj) {
btnTextRef.alpha = 0.65;
tween(btnTextRef, {
alpha: btnTextRef.defaultAlpha
}, {
duration: 120
});
if (btnBgRef && btnBgRef.down) btnBgRef.down(x, y, obj);
};
}(pBtnBg, pBtnText);
pauseMenuContainer.addChild(pBtnText);
}
// Ortala ve ekrana ekle
pauseMenuContainer.x = 2048 / 2 - pauseMenuW / 2;
pauseMenuContainer.y = 2732 / 2 - pauseMenuH / 2;
game.addChild(pauseMenuContainer);
gameStarted = false;
}
// Ava: Menü oyun durduğunda tekrar gösterilsin
function showMenu() {
if (!startMenuContainer.parent) {
startMenuContainer.alpha = 1;
startMenuContainer.scaleX = 1;
startMenuContainer.scaleY = 1;
game.addChild(startMenuContainer);
}
// Oyun yeniden başlatıldığında süreyi 3 dakikaya (180 saniye) sıfırla
timeLeft = gameDuration;
updateTimerDisplay();
gameStarted = false;
}
// Ava: Oyun durdurulduğunda dinamik pause menüsünü göster
game.onPause = function () {
showPauseMenu();
};
// Ava: Oyun başlatıldığında menüyü gizle (mevcut animasyonlu kod korunuyor)
// (Yukarıdaki "start" butonunun down fonksiyonu zaten menüyü yok ediyor ve gameStarted=true yapıyor.)
// Sağlık, skor ve zaman göstergeleri her zaman görünür (oyun başlamadan önce de)
// Bu kod bloğu kaldırıldı, göstergeler her zaman görünür olacak
// Her butonun kendi down fonksiyonu var, menü container'ı routing yapmaz.
// Tüm ekrana tıklama ile başlatma özelliği kaldırıldı, sadece butonlar bağımsız çalışır.
// Power-up türleri ve süreleri
var powerUpTypes = [{
type: "rapidfire",
label: "Ateş Hızı",
color: 0x3a9cff,
duration: 600
},
// 10 sn
{
type: "shield",
label: "Kalkan",
color: 0x7cbb37,
duration: 480
},
// 8 sn
{
type: "scorex2",
label: "2x Skor",
color: 0xf7b32b,
duration: 600
},
// 10 sn
{
type: "speedup",
label: "Hız",
color: 0xd729b6,
duration: 480
} // 8 sn
];
var activePowerUp = null;
var powerUpEndTick = 0;
var powerUpIcon = null;
var giftBg = null;
var giftSpawnCooldown = 900; // gift nadiren spawn olsun (900 tick ~15 saniye)
var lastGiftSpawnTick = -10000; // ilk başta hemen spawn olmasın
function spawnGift() {
if (giftBg) return; // gift zaten varsa tekrar oluşturma
// 3 farklı gift: shield, health, bulletspeed
var powerUpOptions = [{
type: "shield",
label: "Kalkan",
color: 0x7cbb37,
assetId: "gift"
}, {
type: "health",
label: "Can",
color: 0xf75b5b,
assetId: "healthgift"
}, {
type: "bulletspeed",
label: "Mermi Hızı",
color: 0x3a9cff,
assetId: "mermispeedgift"
}];
// Rastgele birini seç
var pType = powerUpOptions[Math.floor(Math.random() * powerUpOptions.length)];
var assetId = pType.assetId;
giftBg = LK.getAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + 600,
y: 2732 / 2 - 400,
width: 120,
height: 120
});
giftBg.alpha = 0.95;
giftBg.powerUpType = pType.type;
giftBg.powerUpColor = pType.color;
giftBg.interactive = true;
// Hareket için rastgele hızlar belirle
giftBg.vx = -4 - Math.random() * 3; // sola doğru hareket
giftBg.vy = (Math.random() - 0.5) * 2.5; // hafif yukarı/aşağı
// Parlaklık efekti
tween(giftBg, {
alpha: 0.7
}, {
duration: 400,
yoyo: true,
repeat: 9999
});
// Dokunma/çarpışma ile alınabilir ve hareketli
giftBg.update = function () {
// Hareket
giftBg.x += giftBg.vx;
giftBg.y += giftBg.vy;
// Ekran dışına çıkarsa yok et
if (giftBg.x < -150 || giftBg.x > 2048 + 150 || giftBg.y < -150 || giftBg.y > 2732 + 150) {
giftBg.destroy();
giftBg = null;
return;
}
// Oyuncu ile çarpışma
if (playerShip && isCircleHit(giftBg, playerShip)) {
if (giftBg.powerUpType === "health") {
// Can hediyesi: canı artır
var healAmount = 3;
playerHealth += healAmount;
if (playerHealth > playerMaxHealth) playerHealth = playerMaxHealth;
updateCanBar();
updatePlayershipCanBar();
} else {
// Diğer power-up'lar (ör: shield, bulletspeed)
activatePowerUp(giftBg.powerUpType);
}
// Efekt: patlama
var effect = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: giftBg.x,
y: giftBg.y,
width: 120,
height: 120
});
effect.alpha = 0.7;
game.addChild(effect);
tween(effect, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
effect.destroy();
}
});
giftBg.destroy();
giftBg = null;
}
};
game.addChild(giftBg);
lastGiftSpawnTick = LK.ticks;
}
function activatePowerUp(type) {
// Önceki power-up'ı sıfırla
if (activePowerUp && powerUpIcon) {
powerUpIcon.destroy();
powerUpIcon = null;
}
activePowerUp = type;
var pType = powerUpTypes.filter(function (p) {
return p.type === type;
})[0];
powerUpEndTick = LK.ticks + (pType ? pType.duration : 600);
// Power-up ikonunu ekle
powerUpIcon = LK.getAsset('can', {
anchorX: 0,
anchorY: 0.5,
x: 0,
y: 100,
width: 120,
height: 120
});
powerUpIcon.alpha = 0.92;
powerUpIcon.color = pType ? pType.color : 0xffffff;
LK.gui.topLeft.addChild(powerUpIcon);
// Üzerine metin
var txt = new Text2(pType ? pType.label : "Power", {
size: 38,
fill: "#fff"
});
txt.anchor.set(0.5, 0.5);
txt.x = 60;
txt.y = 60;
powerUpIcon.addChild(txt);
// Efekt: kısa parlama
tween(powerUpIcon, {
alpha: 1
}, {
duration: 120,
yoyo: true,
repeat: 1
});
// Power-up efektini uygula
if (type === "rapidfire") {
shootInterval = 80; // Süper hızlı ateş
} else if (type === "shield") {
// Kalkan: bir sonraki hasarı engelle
playerShip._shielded = true;
// Görsel: geminin etrafında halka
if (!playerShip._shieldCircle) {
// Shield asset boyutunu playership'in etrafını tam sarmalayacak şekilde ayarla
// PlayerShip'in en büyük boyutunu baz al (ellipse ise genişlik/yükseklik farklı olabilir)
var maxDim = Math.max(playerShip.width, playerShip.height);
var shieldMargin = 18; // Gemi ile kalkan arasında küçük bir boşluk bırak
var shield = LK.getAsset('shield', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
width: maxDim + shieldMargin * 2,
height: maxDim + shieldMargin * 2
});
// Shield'ı tam olarak playership'in merkezine ortala
shield.x = 0;
shield.y = 0;
shield.alpha = 0.7;
// Kalkanı tam olarak geminin merkezine hizala (anchor 0.5,0.5 ile tam ortalanır)
playerShip.addChild(shield);
playerShip._shieldCircle = shield;
}
} else if (type === "scorex2") {
// Skor çarpanı
game._scoreMultiplier = 2;
} else if (type === "speedup") {
// Geminin hızı artsın (daha hızlı sürüklenebilsin)
playerShip._speedUp = true;
} else if (type === "bulletspeed") {
// Mermi hızı power-up: yeni mermiler daha hızlı gitsin
game._bulletSpeedUp = true;
// Aktifken yeni mermiler hızlı olacak, Bullet sınıfı zaten bu flag'i kontrol ediyor
}
}
function deactivatePowerUp() {
if (!activePowerUp) return;
// Efektleri sıfırla
if (activePowerUp === "rapidfire") {
shootInterval = 250;
} else if (activePowerUp === "shield") {
playerShip._shielded = false;
if (playerShip._shieldCircle) {
playerShip._shieldCircle.destroy();
playerShip._shieldCircle = null;
}
} else if (activePowerUp === "scorex2") {
game._scoreMultiplier = 1;
} else if (activePowerUp === "speedup") {
playerShip._speedUp = false;
} else if (activePowerUp === "bulletspeed") {
game._bulletSpeedUp = false;
// Artık yeni mermiler normal hızda olacak
}
if (powerUpIcon) {
powerUpIcon.destroy();
powerUpIcon = null;
}
activePowerUp = null;
powerUpEndTick = 0;
}
// Oyun değişkenleri
var playerShip = new PlayerShip();
// Oyuncu gemisi sol alt köşeden sağa hareket edecek şekilde konumlandırılır
playerShip.x = 350;
playerShip.y = 2732 / 2;
game.addChild(playerShip);
var playerMaxHealth = 10;
var playerHealth = playerMaxHealth;
var bullets = [];
var spaceObjects = [];
var canShoot = true;
var shootInterval = 250; // ms
var lastShootTick = 0;
var score = 0;
var difficulty = 1;
var spawnInterval = 90; // ticks
var lastSpawnTick = 0;
// Bölüm bitişi için toplam düşman sayacı ve kontrol değişkeni
var totalEnemiesSpawned = 0;
var levelFinished = false;
// --- PLAYERSHIP CAN BAR (HEALTH BAR) ---
// Health bar dimensions
var playershipCanBarWidth = 400;
var playershipCanBarHeight = 40;
// Background bar
var playershipCanBarBg = new Container();
var playershipCanBarBgRect = playershipCanBarBg.attachAsset('can', {
anchorX: 0,
anchorY: 0.5,
x: 0,
y: playershipCanBarHeight / 2,
width: playershipCanBarWidth,
height: playershipCanBarHeight
});
playershipCanBarBgRect.alpha = 0.25;
// Foreground bar
var playershipCanBarFg = new Container();
var playershipCanBarFgRect = playershipCanBarFg.attachAsset('can', {
anchorX: 0,
anchorY: 0.5,
x: 0,
y: playershipCanBarHeight / 2,
width: playershipCanBarWidth,
height: playershipCanBarHeight
});
playershipCanBarFgRect.alpha = 1;
// Health bar container for positioning
var playershipCanBarContainer = new Container();
playershipCanBarContainer.addChild(playershipCanBarBg);
playershipCanBarContainer.addChild(playershipCanBarFg);
// Position: top left, but not overlapping menu (leave 100px left and top margin)
playershipCanBarContainer.x = 20;
playershipCanBarContainer.y = 20; // Move to top left, just below top margin
LK.gui.topLeft.addChild(playershipCanBarContainer);
playershipCanBarContainer.visible = true; // Her zaman görünür
// Animate health bar width and color
function updatePlayershipCanBar() {
var targetWidth = playershipCanBarWidth * Math.max(0, playerHealth) / playerMaxHealth;
// Animate width using tween
tween(playershipCanBarFgRect, {
width: targetWidth
}, {
duration: 300
});
// Calculate color: green (full) to red (empty)
// 0x00FF00 (green) to 0xFF0000 (red)
var healthRatio = Math.max(0, Math.min(1, playerHealth / playerMaxHealth));
var r = Math.round(0xFF * (1 - healthRatio));
var g = Math.round(0xFF * healthRatio);
var b = 0;
var color = r << 16 | g << 8 | b;
// Animate color using tween
tween(playershipCanBarFgRect, {
color: color
}, {
duration: 300
});
}
updatePlayershipCanBar();
// --- Only one health bar is visible (playershipCanBar) ---
// Animate health bar width and color
function updateCanBar() {
// Forward to playershipCanBar update for compatibility
updatePlayershipCanBar();
}
updateCanBar();
// Skor gösterimi
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.visible = true; // Her zaman görünür
// Süre göstergesi (3 dakika = 180 saniye)
var gameDuration = 180; // saniye
var timeLeft = gameDuration;
var timerTxt = new Text2('03:00', {
size: 100,
fill: "#fff"
});
timerTxt.anchor.set(1, 0); // Anchor right edge
LK.gui.topRight.addChild(timerTxt); // Add to right side of GUI
timerTxt.visible = true; // Her zaman görünür
// Timer'ı güncelleyen fonksiyon
function updateTimerDisplay() {
var min = Math.floor(timeLeft / 60);
var sec = Math.floor(timeLeft % 60);
var minStr = min < 10 ? "0" + min : "" + min;
var secStr = sec < 10 ? "0" + sec : "" + sec;
timerTxt.setText(minStr + ":" + secStr);
}
updateTimerDisplay();
// Her saniye zaman azaltıcı timer
var timerInterval = LK.setInterval(function () {
if (!gameStarted) return;
if (levelFinished) return;
if (timeLeft > 0) {
timeLeft -= 1;
if (timeLeft < 0) timeLeft = 0;
updateTimerDisplay();
// Zaman bittiğinde oyunu otomatik olarak yeniden başlat
if (timeLeft === 0) {
LK.restartGame();
}
}
}, 1000);
// Animate health bar width and color
updateCanBar();
// Dokunma/sürükleme ile gemi hareketi
var dragging = false;
function handleMove(x, y, obj) {
if (!gameStarted) return;
if (dragging) {
// Portal büyüme animasyonu sırasında oyuncu hareket etmesin, ancak büyüme bittiyse tekrar izin ver
var portalGrowing = false;
if (game.portal && !game.portal.isShrinking) {
// Portal büyüme animasyonu devam ediyor mu?
// 1.2'den 3.0'a büyüme: scaleX < 3.0 ise büyüme devam ediyor
if (typeof game.portal._growTweenStarted !== "undefined" && game.portal._growTweenStarted && game.portal.scaleX < 3.0 - 0.01) {
portalGrowing = true;
}
}
if (portalGrowing) {
return;
}
// Sınırları aşmasın - tüm ekranda serbest hareket
var minX = playerShip.width / 2 + 40;
var maxX = 2048 - playerShip.width / 2 - 40;
var minY = playerShip.height / 2 + 40;
var maxY = 2732 - playerShip.height / 2 - 40;
// Sadece sürükleme sırasında, gemi mouse/touch ile birlikte hareket eder
if (activePowerUp === "speedup") {
// Hız power-up'ı: gemi daha hızlı hareket etsin (pozisyona yaklaşma)
playerShip.x += (Math.max(minX, Math.min(maxX, x)) - playerShip.x) * 0.45;
playerShip.y += (Math.max(minY, Math.min(maxY, y)) - playerShip.y) * 0.45;
} else {
playerShip.x = Math.max(minX, Math.min(maxX, x));
playerShip.y = Math.max(minY, Math.min(maxY, y));
}
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Sadece geminin üstüne tıklanırsa sürükleme başlasın
if (!gameStarted) return;
var dx = x - playerShip.x;
var dy = y - playerShip.y;
var r = playerShip.radius || (playerShip.width ? playerShip.width / 2 : 70);
// Portal büyüme animasyonu devam ediyorsa sürükleme başlatılamasın
var portalGrowing = false;
if (game.portal && !game.portal.isShrinking) {
if (!game.portal._growTweenStarted || game.portal.scaleX < 1.8 - 0.01) {
portalGrowing = true;
}
}
if (portalGrowing) {
dragging = false;
return;
}
if (dx * dx + dy * dy <= r * r) {
dragging = true;
handleMove(x, y, obj);
} else {
dragging = false;
}
};
game.up = function (x, y, obj) {
if (!gameStarted) return;
dragging = false;
};
// Otomatik ateş (her shootInterval ms'de bir)
function tryShoot() {
if (!canShoot) return;
var bullet = new Bullet();
// Mermi geminin sağ tarafından ateşlensin
bullet.x = playerShip.x + playerShip.width / 2 + 10;
bullet.y = playerShip.y;
bullets.push(bullet);
game.addChild(bullet);
canShoot = false;
LK.setTimeout(function () {
canShoot = true;
}, shootInterval);
}
// Uzay cismi oluştur
function spawnSpaceObject() {
// 0: uzayNesnesi2 (enemy), 1: spaceObject (asteroid), 2: meteorstone (yeni düşman)
var rand = Math.random();
var obj;
if (rand < 0.4) {
// uzayNesnesi2 (enemy ship)
obj = new Container();
var width = 100;
var height = 100;
var objAsset = obj.attachAsset('uzayNesnesi2', {
anchorX: 0.5,
anchorY: 0.5
});
objAsset.width = width;
objAsset.height = height;
objAsset.color = 0xff4444;
obj.radius = width / 2;
obj.x = 2048 + width;
obj.y = 200 + Math.random() * (2732 - 400);
// Düşman hızı: kolayda yavaş, zorda hızlı
// 1. zorlukta ~3, 10. zorlukta ~9
var baseSpeed = 3 + (difficulty - 1) * 0.7;
var speed = baseSpeed + Math.random() * (1.5 + difficulty * 0.2);
obj.vx = -speed;
obj.vy = (Math.random() - 0.5) * (2.5 + difficulty * 0.2);
// Enemy bullet fire timer
obj.enemyBulletCooldown = 40 + Math.floor(Math.random() * 40); // ticks
obj.lastEnemyBulletTick = LK.ticks;
obj.update = function () {
// Akıllı hareket: oyuncuya doğru yavaşça yönel
if (playerShip && typeof playerShip.x !== "undefined" && typeof playerShip.y !== "undefined") {
// Yalnızca ekranda ise takip et
var dx = playerShip.x - obj.x;
var dy = playerShip.y - obj.y;
var dist = Math.sqrt(dx * dx + dy * dy);
// X ekseninde oyuncuya yaklaşmak için vx'yi ayarla (mantıklı takip)
var targetVx = -Math.max(2, Math.min(10, Math.abs(dx) / 40));
if (obj.x > playerShip.x) {
obj.vx += (targetVx - obj.vx) * 0.08;
}
// Y ekseninde oyuncuya yaklaşmak için vy'yi ayarla (smooth takip)
var targetVy = 0;
if (dist > 1) {
targetVy = dy / Math.max(80, Math.abs(dx)); // X uzaklığı arttıkça daha az dikey hareket
// Sınırla, çok hızlı olmasın
if (targetVy > 4) targetVy = 4;
if (targetVy < -4) targetVy = -4;
}
// Yavaşça vy'ye yaklaş
obj.vy += (targetVy - obj.vy) * 0.12;
}
obj.x += obj.vx;
obj.y += obj.vy;
// Ateş etme (her cooldown süresi dolduğunda)
if (LK.ticks - obj.lastEnemyBulletTick > obj.enemyBulletCooldown) {
// Akıllı ateş: oyuncu ile aynı yatay hizadaysa ateş et
var shouldFire = false;
if (playerShip && Math.abs(obj.y - playerShip.y) < 80 && obj.x > playerShip.x) {
shouldFire = true;
} else if (Math.random() < 0.12) {
// Rastgele de bazen ateş etsin
shouldFire = true;
}
if (shouldFire) {
var eb = new EnemyBullet();
eb.x = obj.x - 60;
eb.y = obj.y;
if (!game.enemyBullets) game.enemyBullets = [];
game.enemyBullets.push(eb);
game.addChild(eb);
obj.lastEnemyBulletTick = LK.ticks;
obj.enemyBulletCooldown = 40 + Math.floor(Math.random() * 40);
}
}
};
} else if (rand < 0.8) {
// spaceObject (asteroid)
obj = new Container();
var width = 120 + Math.random() * 60;
var height = 120 + Math.random() * 60;
var objAsset = obj.attachAsset('spaceObject', {
anchorX: 0.5,
anchorY: 0.5
});
objAsset.width = width;
objAsset.height = height;
objAsset.color = 0x888888;
obj.radius = width / 2;
obj.x = 2048 + width;
obj.y = 200 + Math.random() * (2732 - 400);
// Asteroid hızı: kolayda yavaş, zorda hızlı
// 1. zorlukta ~2.5, 10. zorlukta ~8
var baseSpeed = 2.5 + (difficulty - 1) * 0.6;
var speed = baseSpeed + Math.random() * (1.5 + difficulty * 0.2);
obj.vx = -speed;
obj.vy = (Math.random() - 0.5) * (2 + difficulty * 0.2);
obj.update = function () {
obj.x += obj.vx;
obj.y += obj.vy;
};
} else {
// meteorstone (yeni düşman)
// MeteorStone: kolayda yavaş, zorda hızlı
obj = new MeteorStone();
if (obj && obj.vx !== undefined) {
// 1. zorlukta ~-3, 10. zorlukta ~-8
var meteorBaseSpeed = 3 + (difficulty - 1) * 0.6;
obj.vx = -meteorBaseSpeed - Math.random() * (1.5 + difficulty * 0.2);
obj.vy = (Math.random() - 0.5) * (2.5 + difficulty * 0.2);
}
}
spaceObjects.push(obj);
game.addChild(obj);
// Düşman sayısını artır ve 10'a ulaştıysa win kontrolü
totalEnemiesSpawned++;
// (Kazanan kontrolü kaldırıldı)
}
// Çarpışma kontrolü (daire-çarpışma)
function isCircleHit(a, b) {
var dx = a.x - b.x;
var dy = a.y - b.y;
var dist = Math.sqrt(dx * dx + dy * dy);
var r1 = a.radius || (a.width ? a.width / 2 : 0);
var r2 = b.radius || (b.width ? b.width / 2 : 0);
return dist < r1 + r2 - 10;
}
// Zorluk arttırma ve oyun hızını kademeli olarak artır
function updateDifficulty() {
// Zorluk: 1-10 arası, her 10 puanda bir artar, maksimum 10
var newDifficulty = 1 + Math.floor(score / 10);
if (newDifficulty > 10) newDifficulty = 10;
if (newDifficulty > difficulty) {
difficulty = newDifficulty;
}
// spawnInterval: Kolayda yavaş (120), zorda hızlı (30)
// 1. zorlukta 120, 10. zorlukta 30
spawnInterval = Math.round(120 - (difficulty - 1) * 10);
if (spawnInterval < 30) spawnInterval = 30;
}
// Oyun döngüsü
game.update = function () {
// (Geri alındı: ekran sağa doğru ilerlemesin, scrollX ve scrollSpeed kaldırıldı)
// --- MAIN MENU BACKGROUND & UI ANIMATIONS ---
// Animate stars (parallax, twinkle)
if (typeof starBgContainer !== "undefined" && stars && stars.length) {
for (var si = 0; si < stars.length; si++) {
var s = stars[si];
s.x -= s._vx;
s.rotation += s._rotSpeed;
s._twinkle += 0.04 + Math.random() * 0.01;
s.alpha = 0.18 + 0.7 * Math.abs(Math.sin(s._twinkle));
if (s.x < -10) {
s.x = 2048 + 10;
s.y = Math.random() * 2732;
}
}
}
// Animate nebulae (slow drift, pulse)
if (typeof nebulae !== "undefined" && nebulae.length) {
for (var ni = 0; ni < nebulae.length; ni++) {
var n = nebulae[ni];
n.x -= n._vx;
n.y += n._vy;
n._pulse += 0.01;
n.alpha = 0.13 + 0.09 * (0.7 + 0.3 * Math.sin(n._pulse));
if (n.x < -n.width / 2) {
n.x = 2048 + n.width / 2;
n.y = 400 + Math.random() * 1800;
}
}
}
// Animate galaxies (slow drift, rotate)
if (typeof galaxies !== "undefined" && galaxies.length) {
for (var gi = 0; gi < galaxies.length; gi++) {
var g = galaxies[gi];
g.x -= g._vx;
g.y += g._vy;
g.rotation += g._rotSpeed;
if (g.x < -g.width / 2) {
g.x = 2048 + g.width / 2;
g.y = 300 + Math.random() * 1800;
}
}
}
// Animate asteroid flybys (fade in/out, move)
if (typeof menuAsteroids !== "undefined") {
if (typeof asteroidSpawnTick === "undefined") asteroidSpawnTick = 0;
asteroidSpawnTick++;
if (asteroidSpawnTick > 120 + Math.random() * 120) {
spawnMenuAsteroid();
asteroidSpawnTick = 0;
}
for (var ai = menuAsteroids.length - 1; ai >= 0; ai--) {
var a = menuAsteroids[ai];
a.x -= a._vx;
if (!a._fadeIn && !a._fadeOut && a.x < 2048 / 2) {
a._fadeOut = true;
tween(a, {
alpha: 0
}, {
duration: 400,
onFinish: function onFinish() {
if (a && a.parent) a.destroy();
}
});
}
if (a.x < -a.width / 2 || a.alpha <= 0.01) {
if (a.parent) a.destroy();
menuAsteroids.splice(ai, 1);
}
}
}
// Animate ship silhouettes (fly by left to right)
if (typeof menuShips !== "undefined") {
if (typeof shipSpawnTick === "undefined") shipSpawnTick = 0;
shipSpawnTick++;
if (shipSpawnTick > 180 + Math.random() * 180) {
spawnMenuShip();
shipSpawnTick = 0;
}
for (var si = menuShips.length - 1; si >= 0; si--) {
var sh = menuShips[si];
sh.x += sh._vx;
if (!sh._fadeOut && sh.x > 2048 + sh.width / 2) {
sh._fadeOut = true;
tween(sh, {
alpha: 0
}, {
duration: 400,
onFinish: function onFinish() {
if (sh && sh.parent) sh.destroy();
}
});
}
if (sh.x > 2048 + sh.width / 2 || sh.alpha <= 0.01) {
if (sh.parent) sh.destroy();
menuShips.splice(si, 1);
}
}
}
// Animate satellites (blink, move)
if (typeof menuSatellites !== "undefined") {
if (typeof satelliteSpawnTick === "undefined") satelliteSpawnTick = 0;
satelliteSpawnTick++;
if (satelliteSpawnTick > 240 + Math.random() * 180) {
spawnMenuSatellite();
satelliteSpawnTick = 0;
}
for (var sa = menuSatellites.length - 1; sa >= 0; sa--) {
var sat = menuSatellites[sa];
sat.x -= sat._vx;
sat._blink += 0.09;
sat.alpha = 0.22 + 0.13 * Math.abs(Math.sin(sat._blink));
if (sat.x < -sat.width / 2 || sat.alpha <= 0.01) {
if (sat.parent) sat.destroy();
menuSatellites.splice(sa, 1);
}
}
}
// Animate particles (fall, fade)
if (typeof menuParticles !== "undefined") {
if (typeof particleSpawnTick === "undefined") particleSpawnTick = 0;
particleSpawnTick++;
if (particleSpawnTick > 12) {
spawnMenuParticle();
particleSpawnTick = 0;
}
for (var pi = menuParticles.length - 1; pi >= 0; pi--) {
var p = menuParticles[pi];
p.y += p._vy;
p._life--;
if (p.y > 2732 + 20 || p._life <= 0) {
if (p.parent) p.destroy();
menuParticles.splice(pi, 1);
}
}
}
// Animate logo pulse
if (typeof logoText !== "undefined") {
var t = LK.ticks % 90 / 90;
var pulse = 1.0 + 0.06 * Math.sin(t * Math.PI * 2);
logoText.scaleX = logoText.scaleY = logoText._pulseBase * pulse;
logoText.alpha = 0.93 + 0.07 * Math.abs(Math.sin(t * Math.PI * 2));
}
// Animate menu button glow/hover
if (typeof btnBgList !== "undefined" && btnBgList.length) {
for (var bi = 0; bi < btnBgList.length; bi++) {
var btn = btnBgList[bi];
// If hovered (touch/click), pulse glow
if (btn._glow > 0.01) {
btn._glow -= 0.04;
if (btn._glow < 0) btn._glow = 0;
}
if (btn._glowOverlay) {
btn._glowOverlay.alpha = btn._glow * 0.7;
}
}
}
// Animate menu button hover on touch (simulate hover for mobile)
if (typeof btnTextList !== "undefined" && btnTextList.length) {
for (var ti = 0; ti < btnTextList.length; ti++) {
var tbtn = btnTextList[ti];
if (tbtn._hovering) {
if (btnBgList[tbtn.buttonIndex]) {
btnBgList[tbtn.buttonIndex]._glow = 1.0;
}
}
}
}
if (!gameStarted) return;
// Playership sağlık barı 0 olduğunda oyun bitsin
if (playerHealth <= 0) {
updateCanBar();
updatePlayershipCanBar();
LK.showGameOver();
return;
}
// Süreyi azalt (her frame ~1/60 saniye)
// Artık sadece timerInterval ile zaman azalacak, burada azaltma yapılmıyor
// 10 düşman spawn olduysa ve can > 0 ve süre > 0 ise win
// (Kazanan kontrolü kaldırıldı)
// Planets removed
// Otomatik ateş
// Portal büyüme veya küçülme animasyonu sırasında mermi atılmasın
var portalBlockingShoot = false;
if (game.portal && !game.portal.isShrinking && typeof game.portal.lastWasIntersecting !== "undefined" && game.portal.lastWasIntersecting) {
portalBlockingShoot = true;
}
if (!portalBlockingShoot && LK.ticks - lastShootTick > Math.floor(shootInterval / 16)) {
tryShoot();
lastShootTick = LK.ticks;
}
// Uzay cismi oluşturma
if (!levelFinished && LK.ticks - lastSpawnTick > spawnInterval) {
spawnSpaceObject();
lastSpawnTick = LK.ticks;
}
// Mermileri güncelle
if (!(game.portal && !game.portal.isShrinking && game.portal.scaleX < (typeof maxScale !== "undefined" ? maxScale : 999))) {
// Portal büyüme animasyonu sırasında mermiler yok edilir
for (var i = bullets.length - 1; i >= 0; i--) {
var b = bullets[i];
b.update();
// Ekran dışıysa sil
if (b.x > 2048 + 50) {
b.destroy();
bullets.splice(i, 1);
}
}
} else {
// Portal büyüme animasyonu sırasında tüm mermileri yok et
for (var i = bullets.length - 1; i >= 0; i--) {
var b = bullets[i];
if (b && b.parent) {
tween(b, {
alpha: 0,
scaleX: 0.2,
scaleY: 0.2
}, {
duration: 200,
onFinish: function (bb) {
return function () {
if (bb && bb.parent) bb.destroy();
};
}(b)
});
}
}
bullets = [];
}
// Uzay cisimlerini güncelle
for (var j = spaceObjects.length - 1; j >= 0; j--) {
var obj = spaceObjects[j];
obj.update();
// Ekran dışıysa sil
if (obj.x < -200 || obj.y < -200 || obj.y > 2732 + 200) {
obj.destroy();
spaceObjects.splice(j, 1);
continue;
}
// Gemiye çarptı mı?
if (isCircleHit(obj, playerShip)) {
// Patlama efekti (patlamaeffekt görseli ile) oyuncu gemisinin üstünde göster
var explosion = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: playerShip.width || 140,
height: playerShip.height || 100
});
game.addChild(explosion);
tween(explosion, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
explosion.destroy();
}
});
// Farklı düşman türlerine göre hasar uygula
var damage = 1;
if (obj instanceof MeteorStone) {
damage = 3;
} else if (obj.attachAsset && obj.attachAsset('spaceObject', {
anchorX: 0.5,
anchorY: 0.5
})) {
// SpaceObject asteroid veya enemy, asteroid ise 1 birim
damage = 1;
} else if (obj.attachAsset && obj.attachAsset('uzayNesnesi2', {
anchorX: 0.5,
anchorY: 0.5
})) {
// EnemyShip ise 1 birim (uzayNesnesi2)
damage = 1;
}
// Kalkan power-up aktifse ilk hasarı engelle
if (activePowerUp === "shield" && playerShip._shielded) {
playerShip._shielded = false;
if (playerShip._shieldCircle) {
tween(playerShip._shieldCircle, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
playerShip._shieldCircle.destroy();
playerShip._shieldCircle = null;
}
});
}
// Kalkan efekti: kısa parlama
var shieldHit = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: playerShip.width * 1.7,
height: playerShip.height * 1.7
});
shieldHit.alpha = 0.5;
shieldHit.color = 0x7cbb37;
game.addChild(shieldHit);
tween(shieldHit, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
shieldHit.destroy();
}
});
// Hasarı engelle, can azalmasın
} else {
playerHealth -= damage;
}
updateCanBar();
updatePlayershipCanBar();
if (playerHealth <= 0) {
updateCanBar();
updatePlayershipCanBar();
LK.showGameOver();
return;
}
obj.destroy();
spaceObjects.splice(j, 1);
continue;
}
// Mermiyle çarpışma
var _loop = function _loop() {
b = bullets[k];
if (isCircleHit(obj, b)) {
// Patlama efekti (patlamaeffekt görseli ile)
explosion = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: obj.x,
y: obj.y,
width: obj.width || 100,
height: obj.height || 100
});
game.addChild(explosion);
tween(explosion, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
explosion.destroy();
}
});
obj.destroy();
spaceObjects.splice(j, 1);
b.destroy();
bullets.splice(k, 1);
// Skor: meteorstone=2, spaceObject=1, enemy ship=3
scoreToAdd = 1;
if (obj instanceof MeteorStone) {
scoreToAdd = 2;
} else if (obj.attachAsset && obj.attachAsset('uzayNesnesi2', {
anchorX: 0.5,
anchorY: 0.5
})) {
scoreToAdd = 3;
}
// Power-up skor çarpanı uygula
var multiplier = game._scoreMultiplier && game._scoreMultiplier > 1 ? game._scoreMultiplier : 1;
score += scoreToAdd * multiplier;
scoreTxt.setText(score);
updateDifficulty();
// Bölüm sonu: 10 düşman öldürüldüyse bitir
if (!levelFinished) {
if (typeof game.enemiesKilled === "undefined") game.enemiesKilled = 0;
game.enemiesKilled++;
if (game.enemiesKilled >= 50) {
levelFinished = true;
// Bölüm sonu canavarı görselini göster
if (typeof game.bossImageShown === "undefined" || !game.bossImageShown) {
var _flashBoss = function flashBoss() {
if (!game.bossImg) return;
tween(game.bossImg, {
alpha: 1
}, {
duration: 120,
onFinish: function onFinish() {
tween(game.bossImg, {
alpha: 0
}, {
duration: 120,
onFinish: function onFinish() {
flashCount++;
if (flashCount < 3) {
_flashBoss();
} else {
// Sonunda kalıcı olarak görünür olsun
tween(game.bossImg, {
alpha: 1
}, {
duration: 120
});
}
}
});
}
});
};
// Sağda, birden yanıp sönerek beliren ve aşağı yukarı hareket eden boss
bossImg = LK.getAsset('bolumsonucanavar', {
anchorX: 0.5,
anchorY: 0.5,
// Ekranın sağında, ortalanmış şekilde göster
x: 2048 - 200,
y: 2732 / 2,
width: 400,
height: 400
});
bossImg.alpha = 0;
game.addChild(bossImg);
game.bossImageShown = true;
game.bossImg = bossImg;
game.bossAppearTick = LK.ticks;
// Yanıp sönme animasyonu (3 kez)
flashCount = 0;
_flashBoss();
// Boss'un aşağı yukarı hareketi için tick kaydı
game.bossBaseY = bossImg.y;
// --- SADECE BÖLÜM SONU CANAVARI KALSIN ---
// Tüm uzay cisimlerini sil
for (var jj = spaceObjects.length - 1; jj >= 0; jj--) {
if (spaceObjects[jj]) {
spaceObjects[jj].destroy();
}
}
spaceObjects = [];
// Tüm mermileri sil
for (var ii = bullets.length - 1; ii >= 0; ii--) {
if (bullets[ii]) {
bullets[ii].destroy();
}
}
bullets = [];
// Tüm düşman mermilerini sil
if (game.enemyBullets) {
for (var eb = game.enemyBullets.length - 1; eb >= 0; eb--) {
if (game.enemyBullets[eb]) {
game.enemyBullets[eb].destroy();
}
}
game.enemyBullets = [];
}
// Gift varsa sil
if (giftBg) {
giftBg.destroy();
giftBg = null;
}
}
// Oyun bitmesin, win popup gösterme
return {
v: void 0
};
}
}
return 0; // break
}
},
b,
explosion,
scoreToAdd,
bossImg,
flashCount,
_ret;
for (var k = bullets.length - 1; k >= 0; k--) {
_ret = _loop();
if (_ret === 0) break;
if (_ret) return _ret.v;
}
}
// Düşman mermileri güncelle ve çarpışma kontrolü
if (game.enemyBullets) {
for (var eb = game.enemyBullets.length - 1; eb >= 0; eb--) {
var enemyBullet = game.enemyBullets[eb];
enemyBullet.update();
// Ekran dışıysa sil
if (enemyBullet.x < -100) {
enemyBullet.destroy();
game.enemyBullets.splice(eb, 1);
continue;
}
// Oyuncuya çarptı mı?
if (isCircleHit(enemyBullet, playerShip)) {
// Patlama efekti (patlamaeffekt görseli ile) oyuncu gemisinin üstünde göster
var explosion = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: playerShip.width || 140,
height: playerShip.height || 100
});
game.addChild(explosion);
tween(explosion, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
explosion.destroy();
}
});
// Kalkan power-up aktifse ilk hasarı engelle
if (activePowerUp === "shield" && playerShip._shielded) {
playerShip._shielded = false;
if (playerShip._shieldCircle) {
tween(playerShip._shieldCircle, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
playerShip._shieldCircle.destroy();
playerShip._shieldCircle = null;
}
});
}
var shieldHit = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: playerShip.width * 1.7,
height: playerShip.height * 1.7
});
shieldHit.alpha = 0.5;
shieldHit.color = 0x7cbb37;
game.addChild(shieldHit);
tween(shieldHit, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
shieldHit.destroy();
}
});
// Hasarı engelle, can azalmasın
} else {
playerHealth -= 2;
}
updateCanBar();
updatePlayershipCanBar();
if (playerHealth <= 0) {
updateCanBar();
updatePlayershipCanBar();
LK.showGameOver();
return;
}
enemyBullet.destroy();
game.enemyBullets.splice(eb, 1);
continue;
}
}
}
// Boss varsa, ekranda merkeze kadar her yönde hareket ettir
if (game.bossImg && game.bossBaseY !== undefined) {
// --- BOSS MERMİSİ ATEŞLEME ---
if (typeof game.bossBulletCooldown === "undefined") {
game.bossBulletCooldown = 60 + Math.floor(Math.random() * 40); // 1-1.5 sn arası
game.lastBossBulletTick = LK.ticks;
if (!game.bossBullets) game.bossBullets = [];
}
// Boss 8 saniyede bir bossfire ateşlesin
if (typeof game.lastBossFireTick === "undefined") {
game.lastBossFireTick = LK.ticks;
}
// Bossfire ve bossmermi aynı anda ateşlenmesin
var bossFireJustFired = false;
if (LK.ticks - game.lastBossFireTick > 480) {
// 8 saniye (60fps*8=480)
// Bossfire aynı anda birkaç kez ateşlensin
var fireCount = 3 + Math.floor(Math.random() * 2); // 3 veya 4 tane
var spread = 120; // Y ekseninde yayılma mesafesi
for (var f = 0; f < fireCount; f++) {
var offsetY = -spread / 2 + spread / (fireCount - 1) * f;
var bossFire = LK.getAsset('bossfire', {
anchorX: 0.5,
anchorY: 0.5,
x: game.bossImg.x - (game.bossImg.width || 400) / 2 - 60,
y: game.bossImg.y + offsetY,
width: 80,
height: 80
});
// Bossfire sadece sola doğru hareket etsin
var speedFire = 13; // bossfire biraz hızlı gitsin
bossFire.vx = -speedFire;
bossFire.vy = 0;
// Yanıcı (yakıcı) etki: çarptığında oyuncuya bir süre daha hasar vermeye devam etsin
bossFire.burning = false;
bossFire.burnTicks = 0;
bossFire.update = function (fire) {
return function () {
fire.x += fire.vx;
fire.y += fire.vy;
// Yanıcı etki aktifse, görsel olarak hafif kırmızıya tintlenebilir (isteğe bağlı)
if (fire.burning) {
fire.alpha = 0.7 + 0.3 * Math.sin(LK.ticks / 4);
}
};
}(bossFire);
if (!game.bossFires) game.bossFires = [];
game.bossFires.push(bossFire);
game.addChild(bossFire);
}
game.lastBossFireTick = LK.ticks;
bossFireJustFired = true;
}
// Boss mermisi ateşle
if (!bossFireJustFired && LK.ticks - game.lastBossBulletTick > game.bossBulletCooldown) {
// Boss'un ateşleme slotları: üstten alta eşit aralıklı hizalı slotlar
var slotCount = 5;
var slotOffsets = [];
var bossImgHeight = game.bossImg.height || 400;
var slotSpacing = bossImgHeight / (slotCount + 1);
for (var si = 0; si < slotCount; si++) {
// slotlar boss görselinin üstünden altına eşit aralıklı
var slotY = -bossImgHeight / 2 + slotSpacing * (si + 1);
slotOffsets.push({
y: slotY,
angle: 0 // düz gitsin, dağınık olmasın
});
}
for (var si = 0; si < slotOffsets.length; si++) {
var slot = slotOffsets[si];
var bossBullet = LK.getAsset('bossmermi', {
anchorX: 0.5,
anchorY: 0.5,
x: game.bossImg.x - (game.bossImg.width || 400) / 2 - 40,
y: game.bossImg.y + slot.y,
width: 48,
height: 48
});
// Boss mermileri sadece sola doğru gitsin
var speed = 10; // Reduced boss bullet speed
bossBullet.vx = -speed;
bossBullet.vy = 0;
bossBullet.update = function (bullet) {
return function () {
bullet.x += bullet.vx;
bullet.y += bullet.vy;
};
}(bossBullet);
game.bossBullets.push(bossBullet);
game.addChild(bossBullet);
}
game.lastBossBulletTick = LK.ticks;
game.bossBulletCooldown = 60 + Math.floor(Math.random() * 40);
}
// Bossfire mermilerini güncelle ve çarpışma kontrolü
if (game.bossFires) {
for (var bf = game.bossFires.length - 1; bf >= 0; bf--) {
var fire = game.bossFires[bf];
if (fire.update) fire.update();
// Ekran dışıysa sil
if (fire.x < -150 || fire.x > 2048 + 150 || fire.y < -150 || fire.y > 2732 + 150) {
fire.destroy();
game.bossFires.splice(bf, 1);
continue;
}
// Oyuncuya çarptı mı?
if (isCircleHit(fire, playerShip)) {
// Eğer bossfire zaten yanıcı değilse, yanıcı etki başlat
if (!fire.burning) {
fire.burning = true;
fire.burnTicks = 0;
fire.burnMaxTicks = 90; // 1.5 saniye boyunca yanıcı etki (60fps*1.5)
fire.burnDamageInterval = 18; // Her 0.3 saniyede bir hasar uygula
fire.lastBurnDamageTick = LK.ticks;
// Patlama efekti
var bossFireHit = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: playerShip.width || 140,
height: playerShip.height || 100
});
game.addChild(bossFireHit);
tween(bossFireHit, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
bossFireHit.destroy();
}
});
// Kalkan power-up aktifse ilk hasarı engelle
if (activePowerUp === "shield" && playerShip._shielded) {
playerShip._shielded = false;
if (playerShip._shieldCircle) {
tween(playerShip._shieldCircle, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
playerShip._shieldCircle.destroy();
playerShip._shieldCircle = null;
}
});
}
var shieldHit = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: playerShip.width * 1.7,
height: playerShip.height * 1.7
});
shieldHit.alpha = 0.5;
shieldHit.color = 0x7cbb37;
game.addChild(shieldHit);
tween(shieldHit, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
shieldHit.destroy();
}
});
// Hasarı engelle, can azalmasın
} else {
playerHealth -= 5; // bossfire hasarı 5
}
updateCanBar();
updatePlayershipCanBar();
if (playerHealth <= 0) {
updateCanBar();
updatePlayershipCanBar();
LK.showGameOver();
return;
}
}
// Yanıcı etkiyi oyuncunun üstünde bırak, mermiyi hemen yok etme
// Mermiyi ekranda bırak, yanıcı etki bitince yok edilecek
continue;
}
// Yanıcı (yakıcı) bossfire oyuncunun üstündeyse, periyodik hasar uygula
if (fire.burning) {
fire.burnTicks++;
// Her burnDamageInterval tick'te bir hasar uygula
if (fire.burnTicks === 1 || fire.burnTicks % fire.burnDamageInterval === 0) {
playerHealth -= 1;
updateCanBar();
updatePlayershipCanBar();
// Yanıcı efektin üstünde küçük bir alev efekti gösterebiliriz (isteğe bağlı)
var burnEffect = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: 80,
height: 80
});
burnEffect.alpha = 0.5;
game.addChild(burnEffect);
tween(burnEffect, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 200,
onFinish: function onFinish() {
burnEffect.destroy();
}
});
if (playerHealth <= 0) {
updateCanBar();
LK.showGameOver();
return;
}
}
// Yanıcı etki süresi dolduysa bossfire'ı yok et
if (fire.burnTicks > fire.burnMaxTicks) {
fire.destroy();
game.bossFires.splice(bf, 1);
continue;
}
}
}
}
// Boss mermilerini güncelle ve çarpışma kontrolü
for (var bb = game.bossBullets.length - 1; bb >= 0; bb--) {
var bBullet = game.bossBullets[bb];
if (bBullet.update) bBullet.update();
// Ekran dışıysa sil
if (bBullet.x < -100 || bBullet.x > 2048 + 100 || bBullet.y < -100 || bBullet.y > 2732 + 100) {
bBullet.destroy();
game.bossBullets.splice(bb, 1);
continue;
}
// Oyuncuya çarptı mı?
if (isCircleHit(bBullet, playerShip)) {
// Patlama efekti
var bossBulletHit = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: playerShip.width || 140,
height: playerShip.height || 100
});
game.addChild(bossBulletHit);
tween(bossBulletHit, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
bossBulletHit.destroy();
}
});
// Kalkan power-up aktifse ilk hasarı engelle
if (activePowerUp === "shield" && playerShip._shielded) {
playerShip._shielded = false;
if (playerShip._shieldCircle) {
tween(playerShip._shieldCircle, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
playerShip._shieldCircle.destroy();
playerShip._shieldCircle = null;
}
});
}
var shieldHit = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: playerShip.width * 1.7,
height: playerShip.height * 1.7
});
shieldHit.alpha = 0.5;
shieldHit.color = 0x7cbb37;
game.addChild(shieldHit);
tween(shieldHit, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
shieldHit.destroy();
}
});
// Hasarı engelle, can azalmasın
} else {
playerHealth -= 3; // bossmermi hasarı 3
}
updateCanBar();
updatePlayershipCanBar();
if (playerHealth <= 0) {
updateCanBar();
updatePlayershipCanBar();
LK.showGameOver();
return;
}
bBullet.destroy();
game.bossBullets.splice(bb, 1);
continue;
}
}
// Boss'un hareket yarıçapı: ekranın sağ yarısında, merkeze kadar gidebilsin
// Merkez: (2048/2, 2732/2)
// Boss'un hareket merkezi: ekranın sağında başlar, merkeze kadar hareket edebilir
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var rightEdgeX = 2048 - 200;
var bossMoveRadiusX = (rightEdgeX - centerX) / 2; // sağdan merkeze kadar yarıçap
var bossMoveRadiusY = (centerY - 0) * 0.8; // üstten alta merkeze kadar (biraz daha az)
var bossCenterX = centerX + bossMoveRadiusX;
var bossCenterY = centerY;
// --- BOSS MERMİLERİNDEN KAÇMA ALGORİTMASI KALDIRILDI ---
// Boss, ekrandaki boss mermilerinden kaçmaz, sadece dairesel hareket yapar
var t = LK.ticks / 60; // yavaş hareket için
var bossTargetX = bossCenterX + Math.cos(t) * bossMoveRadiusX;
var bossTargetY = bossCenterY + Math.sin(t * 0.8) * bossMoveRadiusY;
// Boss'un hedef pozisyonuna yumuşak geçiş (smooth movement)
var lerp = function lerp(a, b, t) {
return a + (b - a) * t;
};
game.bossImg.x = lerp(game.bossImg.x, bossTargetX, 0.18);
game.bossImg.y = lerp(game.bossImg.y, bossTargetY, 0.18);
// --- BOSS CAN, HASAR ALMA, HASAR VERME ---
// Boss canı başlat
if (typeof game.bossHealth === "undefined") {
game.bossHealth = 10; // Boss'un toplam canı artık 10
// Boss can barı
game.bossHealthBarBg = new Container();
var bossBarBgRect = game.bossHealthBarBg.attachAsset('can', {
anchorX: 0,
anchorY: 0.5,
x: 0,
y: 20,
width: 400,
height: 40
});
bossBarBgRect.alpha = 0.25;
game.bossHealthBarFg = new Container();
var bossBarFgRect = game.bossHealthBarFg.attachAsset('can', {
anchorX: 0,
anchorY: 0.5,
x: 0,
y: 20,
width: 400,
height: 40
});
bossBarFgRect.alpha = 1;
game.bossHealthBarContainer = new Container();
game.bossHealthBarContainer.addChild(game.bossHealthBarBg);
game.bossHealthBarContainer.addChild(game.bossHealthBarFg);
// Boss can barı ekranın sağ üst köşesinde, timer'ın hemen altında göster
game.bossHealthBarContainer.x = -400; // Offset for right alignment in gui.topRight
game.bossHealthBarContainer.y = 100; // Just below timer
LK.gui.topRight.addChild(game.bossHealthBarContainer);
}
// Boss can barını güncelle
var bossTargetWidth = 400 * Math.max(0, game.bossHealth) / 10;
tween(game.bossHealthBarFg.children[0], {
width: bossTargetWidth
}, {
duration: 200
});
// Boss can barı rengi: yeşil (full) -> kırmızı (az)
var bossHealthRatio = Math.max(0, Math.min(1, game.bossHealth / 10));
var br = Math.round(0xFF * (1 - bossHealthRatio));
var bg = Math.round(0xFF * bossHealthRatio);
var bb = 0;
var bossColor = br << 16 | bg << 8 | bb;
tween(game.bossHealthBarFg.children[0], {
color: bossColor
}, {
duration: 200
});
// Boss'a mermi çarpması kontrolü
for (var bi = bullets.length - 1; bi >= 0; bi--) {
var bossBullet = bullets[bi];
// Boss'un çarpışma yarıçapı: görselin yarısı
var bossRadius = (game.bossImg.width || 400) / 2;
var dx = bossBullet.x - game.bossImg.x;
var dy = bossBullet.y - game.bossImg.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < bossRadius + 16) {
// Patlama efekti
var bossHit = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: bossBullet.x,
y: bossBullet.y,
width: 80,
height: 80
});
game.addChild(bossHit);
tween(bossHit, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
bossHit.destroy();
}
});
// Boss canı azalt
game.bossHealth -= 2;
if (game.bossHealth < 0) game.bossHealth = 0;
// Mermiyi yok et
bossBullet.destroy();
bullets.splice(bi, 1);
// Boss öldü mü?
if (game.bossHealth <= 0) {
// Boss patlama efekti
var bossExplosion = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: game.bossImg.x,
y: game.bossImg.y,
width: game.bossImg.width || 400,
height: game.bossImg.height || 400
});
game.addChild(bossExplosion);
tween(bossExplosion, {
alpha: 0,
scaleX: 3,
scaleY: 3
}, {
duration: 800,
onFinish: function onFinish() {
bossExplosion.destroy();
}
});
// Boss'u yok et
game.bossImg.destroy();
game.bossImg = null;
// Boss can barını yok et
if (game.bossHealthBarContainer) {
game.bossHealthBarContainer.destroy();
game.bossHealthBarContainer = null;
}
// Skor bonusu
score += 20;
scoreTxt.setText(score);
updateDifficulty();
// --- PORTAL EKLE ---
// Boss öldüğünde portalı ekle ve büyüme animasyonunu başlat
if (!game.portal) {
// Portalı ekranın sağında ortalanmış şekilde oluştur, ekran dışına taşmayacak şekilde
var portalWidth = 120;
var portalHeight = 120;
var portalScale = 3.0; // Büyüme sonrası maksimum scale
var portalX = 2048 - portalWidth * portalScale / 2 - 40; // Sağdan 40px boşluk bırak
var portalY = 2732 / 2;
var portal = LK.getAsset('portal', {
anchorX: 0.5,
anchorY: 0.5,
x: portalX,
y: portalY,
width: portalWidth,
height: portalHeight
});
portal.scaleX = 1.2;
portal.scaleY = 1.2;
portal.alpha = 1;
portal.isShrinking = false;
portal.lastWasIntersecting = false;
game.portal = portal;
game.addChild(portal);
// Portal büyüme animasyonu: 1.2'den 3.0'a kadar büyüsün
portal._growTweenStarted = true;
tween(portal, {
scaleX: 3.0,
scaleY: 3.0
}, {
duration: 1200,
easing: tween.easeOut,
onFinish: function onFinish() {
portal._growTweenStarted = false;
}
});
}
// Oyun bitmesin, win popup gösterme
return;
}
}
}
// Boss oyuncuya çarparsa hasar versin
if (playerShip && game.bossImg) {
var dxp = playerShip.x - game.bossImg.x;
var dyp = playerShip.y - game.bossImg.y;
var distp = Math.sqrt(dxp * dxp + dyp * dyp);
var bossRadius = (game.bossImg.width || 400) / 2;
var playerRadius = playerShip.radius || (playerShip.width ? playerShip.width / 2 : 70);
if (distp < bossRadius + playerRadius - 20) {
// Sadece ilk çarpışmada hasar uygula (her frame değil)
if (!game.bossLastPlayerHit) {
// Patlama efekti
var bossPlayerHit = LK.getAsset('patlamaeffekt', {
anchorX: 0.5,
anchorY: 0.5,
x: playerShip.x,
y: playerShip.y,
width: playerShip.width || 140,
height: playerShip.height || 100
});
game.addChild(bossPlayerHit);
tween(bossPlayerHit, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
onFinish: function onFinish() {
bossPlayerHit.destroy();
}
});
playerHealth -= 5;
updateCanBar();
updatePlayershipCanBar();
if (playerHealth <= 0) {
updateCanBar();
updatePlayershipCanBar();
LK.showGameOver();
return;
}
game.bossLastPlayerHit = true;
}
} else {
game.bossLastPlayerHit = false;
}
}
}
// (Geri alındı: scrollX += scrollSpeed ile sağa doğru ilerleme efekti yok)
// --- Ava: playerShip ve portal da scrollX ile sağa kaymalı (otomatik hareket yoksa) ---
// (Geri alındı: playerShip ve portal scrollSpeed ile sağa kaydırılmıyor)
// Portal dinamik efekt: sadece büyüme ve renk döngüsü (nabız efekti kaldırıldı)
if (game.portal) {
// Portal'ın konumu ve büyümesi: portal ekranın tam ortasında sabit kalır, büyüme animasyonu yok
if (game.portal) {
// Renk döngüsü (HSV'den RGB'ye basit dönüşüm)
var t = LK.ticks % 360 / 360;
var h = t,
s = 0.7,
v = 1.0;
var i = Math.floor(h * 6);
var f = h * 6 - i;
var p = v * (1 - s);
var q = v * (1 - f * s);
var r, g, b;
switch (i % 6) {
case 0:
r = v, g = q, b = p;
break;
case 1:
r = q, g = v, b = p;
break;
case 2:
r = p, g = v, b = q;
break;
case 3:
r = p, g = q, b = v;
break;
case 4:
r = q, g = p, b = v;
break;
case 5:
r = v, g = p, b = q;
break;
}
var color = Math.round(r * 255) << 16 | Math.round(g * 255) << 8 | Math.round(b * 255);
game.portal.color = color;
}
if (typeof game.portal.isShrinking === "undefined") game.portal.isShrinking = false;
if (typeof game.portal.lastWasIntersecting === "undefined") game.portal.lastWasIntersecting = false;
// --- Portal büyümesi bittikten sonra playership otomatik geçişi için ek kodlar ---
if (game.portal && !game.portal.isShrinking && !game.portal._autoMoveStarted && !game.portal.lastWasIntersecting) {
// Portal büyüme animasyonu bittiyse (scaleX >= 3.0 - 0.01)
if (!game.portal._growTweenStarted && Math.abs(game.portal.scaleX - 3.0) < 0.01 && playerShip && !playerShip._autoMovingToPortal) {
// Otomatik hareket başlatılmadan önce 2 saniye bekle
game.portal._autoMoveStarted = true;
playerShip._autoMovingToPortal = true;
// Hedef portalın merkezi
var portalTargetX = game.portal.x;
var portalTargetY = game.portal.y;
LK.setTimeout(function () {
// 2 saniye sonra otomatik hareket başlasın
tween(playerShip, {
x: portalTargetX,
y: portalTargetY
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Hareket bittiğinde flag kaldır
playerShip._autoMovingToPortal = false;
}
});
}, 2000);
}
}
// Oyuncu gemisi portal ile temas etti mi?
var portalIntersect = false;
if (playerShip && !game.portal.isShrinking) {
// Portal ve gemi çarpışma kontrolü (daire-çarpışma)
var dx = playerShip.x - game.portal.x;
var dy = playerShip.y - game.portal.y;
var portalRadius = (game.portal.width ? game.portal.width / 2 : 60) * game.portal.scaleX;
var playerRadius = playerShip.radius || (playerShip.width ? playerShip.width / 2 : 70);
var dist = Math.sqrt(dx * dx + dy * dy);
portalIntersect = dist < portalRadius + playerRadius - 10;
if (!game.portal.lastWasIntersecting && portalIntersect) {
// Gemi portalın içine girdi: gemi ve mermiler kaybolsun, portal küçülüp ışık patlamasıyla kaybolsun
// Gemi kaybolsun (görsel olarak)
if (playerShip && playerShip.parent) {
tween(playerShip, {
alpha: 0,
scaleX: 0.2,
scaleY: 0.2
}, {
duration: 400,
onFinish: function onFinish() {
if (playerShip && playerShip.parent) {
playerShip.destroy();
}
}
});
}
// Tüm mermileri kaybolma animasyonuyla yok et
for (var i = bullets.length - 1; i >= 0; i--) {
var b = bullets[i];
if (b && b.parent) {
b.visible = false; // Portal geçildikten sonra mermiler görünmesin
b.alpha = 0;
b.destroy();
}
}
bullets = [];
// Portal küçülmeye başlasın
game.portal.isShrinking = true;
tween(game.portal, {
scaleX: 0.1,
scaleY: 0.1,
alpha: 0.0
}, {
duration: 900,
easing: tween.easeIn,
onFinish: function onFinish() {
// Işık patlaması efekti
if (game.portal && game.portal.parent) {
var portalExplosion = LK.getAsset('portalblast', {
anchorX: 0.5,
anchorY: 0.5,
x: game.portal.x,
y: game.portal.y,
width: (game.portal.width || 120) * (game.portal.scaleX || 1.0) * 2.2,
height: (game.portal.height || 120) * (game.portal.scaleY || 1.0) * 2.2
});
portalExplosion.alpha = 0.85;
game.addChild(portalExplosion);
tween(portalExplosion, {
alpha: 0,
scaleX: 2.5,
scaleY: 2.5
}, {
duration: 500,
onFinish: function onFinish() {
if (portalExplosion && portalExplosion.parent) portalExplosion.destroy();
// Portal tamamen kaybolduktan sonra win ekranı göster
// LK.showYouWin(); // Win ekranı gösterme KALDIRILDI
}
});
game.portal.destroy();
game.portal = null;
}
}
});
}
game.portal.lastWasIntersecting = portalIntersect;
}
}
// Kara delik spawn: ekranda kara delik yoksa ve spawn süresi dolduysa, sadece oyunun ilerleyen bölümlerinde (ör: skor 20'den sonra) rastgele spawn et
if (typeof game.blackHoles === "undefined") game.blackHoles = [];
if (typeof game.lastBlackHoleSpawnTick === "undefined") game.lastBlackHoleSpawnTick = -10000;
var blackHoleSpawnCooldown = 1200 + Math.floor(Math.random() * 900); // 20-35 saniye arası
// Kara delik sadece skor 20 ve üstü olduğunda spawn edilsin (oyunun ilerleyen bölümleri)
if (score >= 20) {
// Kara delik yoksa ve spawn süresi dolduysa %60 olasılıkla spawn et
if (game.blackHoles.length < 1 && LK.ticks - game.lastBlackHoleSpawnTick > blackHoleSpawnCooldown) {
if (Math.random() < 0.6) {
var bh = new BlackHole();
game.blackHoles.push(bh);
game.addChild(bh);
game.lastBlackHoleSpawnTick = LK.ticks;
} else {
// spawn denemesi başarısızsa tekrar denemek için tick'i güncelleme
game.lastBlackHoleSpawnTick = LK.ticks;
}
}
}
// Kara delikleri güncelle ve ömrü bitenleri sil
for (var bhIdx = game.blackHoles.length - 1; bhIdx >= 0; bhIdx--) {
var bh = game.blackHoles[bhIdx];
if (bh && bh.update) bh.update();
if (bh && bh.parent === null) {
game.blackHoles.splice(bhIdx, 1);
}
}
// Gift spawn: gift yoksa ve spawn süresi dolduysa nadiren spawn et
if (!giftBg && LK.ticks - lastGiftSpawnTick > giftSpawnCooldown) {
// %80 olasılıkla gift spawn et
if (Math.random() < 0.8) {
spawnGift();
} else {
// spawn denemesi başarısızsa tekrar denemek için tick'i güncelleme
lastGiftSpawnTick = LK.ticks;
}
}
// Gift güncellemesi (power-up çarpışma kontrolü)
if (giftBg && giftBg.update) {
giftBg.update();
}
// Aktif power-up süresini kontrol et
if (activePowerUp && LK.ticks >= powerUpEndTick) {
deactivatePowerUp();
}
// Power-up efektleri: hız, kalkan, skor çarpanı
if (activePowerUp === "speedup" && playerShip && dragging) {
// Sürükleme hızını artırmak için handleMove fonksiyonunda hız limiti artırılabilir
// (Burada ek bir kod gerekmez, handleMove zaten sınırları kontrol ediyor)
}
if (activePowerUp === "shield" && playerShip && playerShip._shieldCircle) {
// Kalkan efekti: hafif nabız animasyonu
var t = LK.ticks % 60 / 60;
var scale = 1.3 + 0.1 * Math.sin(t * Math.PI * 2);
playerShip._shieldCircle.scaleX = scale;
playerShip._shieldCircle.scaleY = scale;
}
// Power-up skor çarpanı: skor eklenirken game._scoreMultiplier kullanılır
if (!game._scoreMultiplier) game._scoreMultiplier = 1;
// --- Orijinal kod ---
}; ===================================================================
--- original.js
+++ change.js
@@ -342,82 +342,477 @@
/****
* Game Code
****/
-// Galaksi arka planı kaldırıldı
-// Yıldızlar: Parallax ve hafif dönen yıldızlar
-var starBgCount = 90;
+// --- DYNAMIC SPACE BACKGROUND FOR MAIN MENU ---
+// Starfield, nebula, galaxies, asteroids, ship silhouettes, satellites, particles
+var starBgCount = 120;
var stars = [];
var starBgContainer = new Container();
for (var i = 0; i < starBgCount; i++) {
- var starSize = 2 + Math.random() * 4;
+ var starSize = 1.5 + Math.random() * 3.5;
var star = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 2732,
width: starSize,
height: starSize
});
- // Farklı parlaklıklar
- star.alpha = 0.3 + Math.random() * 0.7;
- // Farklı hızlar (parallax)
- star._vx = 0.7 + Math.random() * 1.2;
- // Hafif döndürme efekti
- star._rotSpeed = (Math.random() - 0.5) * 0.01;
+ star.alpha = 0.18 + Math.random() * 0.82;
+ star._vx = 0.3 + Math.random() * 1.1;
+ star._rotSpeed = (Math.random() - 0.5) * 0.008;
+ star._twinkle = Math.random() * Math.PI * 2;
stars.push(star);
starBgContainer.addChild(star);
}
-game.addChild(starBgContainer); // Yıldız arka planı ekle (addChildAt yerine addChild ile, out of bounds hatasını önler)
-// --- BAŞLANGIÇ MENÜSÜ ---
+// Add distant nebulae (soft colored, slow parallax)
+var nebulae = [];
+for (var n = 0; n < 2; n++) {
+ var nebula = LK.getAsset('can', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 400 + Math.random() * 1200,
+ y: 400 + Math.random() * 1800,
+ width: 900 + Math.random() * 400,
+ height: 400 + Math.random() * 300
+ });
+ nebula.alpha = 0.13 + Math.random() * 0.09;
+ nebula.color = n === 0 ? 0x6e4fff : 0x2fd6c7;
+ nebula._vx = 0.08 + Math.random() * 0.07;
+ nebula._vy = 0.01 + Math.random() * 0.03;
+ nebula._pulse = Math.random() * Math.PI * 2;
+ nebulae.push(nebula);
+ starBgContainer.addChild(nebula);
+}
+// Add distant galaxies (faint, slow, colored ellipses)
+var galaxies = [];
+for (var g = 0; g < 2; g++) {
+ var galaxy = LK.getAsset('can', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 300 + Math.random() * 1400,
+ y: 300 + Math.random() * 1800,
+ width: 600 + Math.random() * 300,
+ height: 220 + Math.random() * 120
+ });
+ galaxy.alpha = 0.09 + Math.random() * 0.07;
+ galaxy.color = g === 0 ? 0xf7b32b : 0x9b59b6;
+ galaxy._vx = 0.04 + Math.random() * 0.04;
+ galaxy._vy = 0.01 + Math.random() * 0.02;
+ galaxy._rotSpeed = (Math.random() - 0.5) * 0.002;
+ galaxies.push(galaxy);
+ starBgContainer.addChild(galaxy);
+}
+// Add asteroid flybys (move right to left, fade in/out)
+var menuAsteroids = [];
+function spawnMenuAsteroid() {
+ var y = 100 + Math.random() * (2732 - 200);
+ var size = 60 + Math.random() * 60;
+ var asteroid = LK.getAsset('meteorstone', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 + size,
+ y: y,
+ width: size,
+ height: size
+ });
+ asteroid.alpha = 0.0;
+ asteroid._vx = 2.5 + Math.random() * 2.5;
+ asteroid._fadeIn = true;
+ asteroid._fadeOut = false;
+ menuAsteroids.push(asteroid);
+ starBgContainer.addChild(asteroid);
+ tween(asteroid, {
+ alpha: 0.7
+ }, {
+ duration: 400,
+ onFinish: function onFinish() {
+ asteroid._fadeIn = false;
+ }
+ });
+}
+var asteroidSpawnTick = 0;
+// Add ship silhouettes (fly by, faint, slow)
+var menuShips = [];
+function spawnMenuShip() {
+ var y = 200 + Math.random() * (2732 - 400);
+ var size = 80 + Math.random() * 40;
+ var ship = LK.getAsset('playership2', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -size,
+ y: y,
+ width: size,
+ height: size * 0.7
+ });
+ ship.alpha = 0.13 + Math.random() * 0.09;
+ ship._vx = 2.2 + Math.random() * 1.2;
+ ship._fadeOut = false;
+ menuShips.push(ship);
+ starBgContainer.addChild(ship);
+}
+var shipSpawnTick = 0;
+// Add satellites (blink, move slowly)
+var menuSatellites = [];
+function spawnMenuSatellite() {
+ var y = 150 + Math.random() * (2732 - 300);
+ var size = 38 + Math.random() * 18;
+ var sat = LK.getAsset('spaceObject', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 + size,
+ y: y,
+ width: size,
+ height: size
+ });
+ sat.alpha = 0.22 + Math.random() * 0.13;
+ sat._vx = 0.7 + Math.random() * 0.7;
+ sat._blink = Math.random() * Math.PI * 2;
+ menuSatellites.push(sat);
+ starBgContainer.addChild(sat);
+}
+var satelliteSpawnTick = 0;
+// Add particle trails (random, faint, slow)
+var menuParticles = [];
+function spawnMenuParticle() {
+ var x = Math.random() * 2048;
+ var y = Math.random() * 2732;
+ var size = 8 + Math.random() * 12;
+ var p = LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: x,
+ y: y,
+ width: size,
+ height: size
+ });
+ p.alpha = 0.08 + Math.random() * 0.08;
+ p._vy = 0.5 + Math.random() * 0.7;
+ p._life = 60 + Math.floor(Math.random() * 60);
+ menuParticles.push(p);
+ starBgContainer.addChild(p);
+}
+var particleSpawnTick = 0;
+game.addChild(starBgContainer); // Add all menu background elements
+// --- HOLOGRAPHIC-STYLE FLOATING MENU & LOGO ---
+// Centered floating menu container
var startMenuContainer = new Container();
-// Oyun başı intro sahnesi kaldırıldı, menü doğrudan gösteriliyor
if (!startMenuContainer.parent) {
startMenuContainer.alpha = 1;
startMenuContainer.scaleX = 1;
startMenuContainer.scaleY = 1;
game.addChild(startMenuContainer);
}
-// Menü renklerini dinamik olarak yönetmek için global değişkenler
+// Menu colors and layout
var menuBgColor = 0x181c2b;
var menuButtonColors = [0x3a9cff, 0x4e5d94, 0x7cbb37, 0xf7b32b];
var menuWidth = 1000;
var menuHeight = 1100;
-// Menü arka planına transparan kutu
-// Modern transparan menü kutusu
+// Holographic menu background (glow, border, glass effect)
+var borderBg = LK.getAsset('can', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: menuWidth / 2,
+ y: menuHeight / 2,
+ width: menuWidth + 54,
+ height: menuHeight + 54
+});
+borderBg.alpha = 0.22;
+borderBg.color = 0x0a0e1a;
+startMenuContainer.addChild(borderBg);
var startMenuBg = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: menuWidth / 2,
y: menuHeight / 2,
width: menuWidth,
height: menuHeight
});
-startMenuBg.alpha = 0.88;
+startMenuBg.alpha = 0.93;
startMenuBg.color = menuBgColor;
startMenuContainer.addChild(startMenuBg);
-// Menü arka planına hafif bir border efekti ekle (arka planı büyütüp, daha koyu bir renk ile)
-var borderBg = LK.getAsset('can', {
+// Holographic glass overlay
+var holoOverlay = LK.getAsset('can', {
anchorX: 0.5,
anchorY: 0.5,
x: menuWidth / 2,
y: menuHeight / 2,
- width: menuWidth + 44,
- height: menuHeight + 44
+ width: menuWidth,
+ height: menuHeight
});
-borderBg.alpha = 0.18;
-borderBg.color = 0x000000;
-startMenuContainer.addChildAt(borderBg, 0);
-// Başlık ve alt başlık
-var titleText = new Text2("UZAY MACERASI", {
- size: 120,
+holoOverlay.alpha = 0.13;
+holoOverlay.color = 0x3a9cff;
+startMenuContainer.addChild(holoOverlay);
+// --- LOGO: floating, pulsing, above menu ---
+var logoText = new Text2("UZAY MACERASI", {
+ size: 160,
fill: 0xFFE066
});
-titleText.anchor.set(0.5, 0.5);
-titleText.x = menuWidth / 2;
-titleText.y = 140;
-startMenuContainer.addChild(titleText);
-// Subtitle text removed as requested
+logoText.anchor.set(0.5, 0.5);
+logoText.x = menuWidth / 2;
+logoText.y = 60;
+logoText.alpha = 0.97;
+startMenuContainer.addChild(logoText);
+// Logo energy pulse effect (handled in update below)
+logoText._pulseBase = 1.0;
+// --- HOLOGRAPHIC BUTTONS ---
+// Button layout: arc or vertical
+var menuButtons = [{
+ label: "Start Game",
+ key: "start",
+ color: 0x3a9cff
+}, {
+ label: "Load",
+ key: "load",
+ color: 0x4e5d94
+}, {
+ label: "Settings",
+ key: "options",
+ color: 0x7cbb37
+}, {
+ label: "Exit",
+ key: "exit",
+ color: 0xf7b32b
+}];
+var buttonHeight = 140;
+var buttonWidth = 600;
+var buttonSpacing = 48;
+var firstBtnY = 320;
+var btnBgList = [];
+var btnTextList = [];
+for (var i = 0; i < menuButtons.length; i++) {
+ // Arc layout: slight curve, or vertical
+ var arcAngle = (i - (menuButtons.length - 1) / 2) * 0.18;
+ var btnY = firstBtnY + i * (buttonHeight + buttonSpacing) + Math.sin(arcAngle) * 40;
+ var btnX = menuWidth / 2 + Math.sin(arcAngle) * 120;
+ // Button shadow
+ var btnBgShadow = LK.getAsset('can', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: btnX + 8,
+ y: btnY + 10,
+ width: buttonWidth + 24,
+ height: buttonHeight + 18
+ });
+ btnBgShadow.alpha = 0.16;
+ btnBgShadow.color = 0x000000;
+ startMenuContainer.addChild(btnBgShadow);
+ // Button background (holographic, glowing)
+ var btnBg = LK.getAsset('can', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: btnX,
+ y: btnY,
+ width: buttonWidth,
+ height: buttonHeight
+ });
+ btnBg.alpha = 0.93;
+ btnBg.color = menuButtonColors[i % menuButtonColors.length];
+ btnBg.menuKey = menuButtons[i].key;
+ btnBg.buttonIndex = i;
+ btnBg.interactive = true;
+ btnBg.defaultAlpha = btnBg.alpha;
+ btnBg._glow = 0.0;
+ // Button hover/tap effect
+ btnBg.down = function (btn) {
+ return function (x, y, obj) {
+ btn.alpha = 0.65;
+ tween(btn, {
+ alpha: btn.defaultAlpha
+ }, {
+ duration: 120
+ });
+ // TODO: play soft electronic sound here if sound enabled
+ // Button action
+ if (btn.menuKey === "start") {
+ tween(startMenuContainer, {
+ alpha: 0,
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 350,
+ onFinish: function onFinish() {
+ if (startMenuContainer && startMenuContainer.parent) startMenuContainer.destroy();
+ timeLeft = gameDuration;
+ updateTimerDisplay();
+ gameStarted = true;
+ }
+ });
+ } else if (btn.menuKey === "exit") {
+ // Exit: fade out and reload (simulate exit)
+ tween(startMenuContainer, {
+ alpha: 0,
+ scaleX: 0.7,
+ scaleY: 0.7
+ }, {
+ duration: 350,
+ onFinish: function onFinish() {
+ if (startMenuContainer && startMenuContainer.parent) startMenuContainer.destroy();
+ // Simulate exit: reload page
+ if (typeof window !== "undefined" && window.location) window.location.reload();
+ }
+ });
+ } else {
+ // Open modal for load/settings
+ if (startMenuContainer && startMenuContainer.parent) {
+ startMenuContainer.visible = false;
+ }
+ var modalW = 800;
+ var modalH = 700;
+ var modalContainer = new Container();
+ var modalBg = LK.getAsset('can', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: modalW / 2,
+ y: modalH / 2,
+ width: modalW,
+ height: modalH
+ });
+ modalBg.alpha = 0.96;
+ modalBg.color = 0x181c2b;
+ modalContainer.addChild(modalBg);
+ var modalTitle = btn.menuKey === "load" ? "Load Game" : "Settings";
+ var modalContent = btn.menuKey === "load" ? "No saved games found." : "Adjust your settings here.";
+ var modalTitleText = new Text2(modalTitle, {
+ size: 100,
+ fill: 0xFFE066,
+ maxWidth: modalW - 80
+ });
+ modalTitleText.anchor.set(0.5, 0.5);
+ modalTitleText.x = modalW / 2;
+ modalTitleText.y = 120;
+ modalContainer.addChild(modalTitleText);
+ var modalContentText = new Text2(modalContent, {
+ size: 60,
+ fill: "#fff",
+ maxWidth: modalW - 80
+ });
+ modalContentText.anchor.set(0.5, 0);
+ modalContentText.x = modalW / 2;
+ modalContentText.y = 220;
+ modalContainer.addChild(modalContentText);
+ // Close button
+ var closeBtnW = 320;
+ var closeBtnH = 100;
+ var closeBtnY = modalH - closeBtnH / 2 - 24;
+ var closeBtnBg = LK.getAsset('can', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: modalW / 2,
+ y: closeBtnY,
+ width: closeBtnW,
+ height: closeBtnH
+ });
+ closeBtnBg.alpha = 0.85;
+ closeBtnBg.color = 0x3a9cff;
+ closeBtnBg.interactive = true;
+ closeBtnBg.down = function () {
+ return function (x, y, obj) {
+ if (modalContainer && modalContainer.parent) modalContainer.destroy();
+ if (startMenuContainer && !startMenuContainer.parent) {
+ startMenuContainer.visible = true;
+ game.addChild(startMenuContainer);
+ }
+ };
+ }();
+ modalContainer.addChild(closeBtnBg);
+ var closeBtnText = new Text2("Close", {
+ size: 70,
+ fill: "#fff"
+ });
+ closeBtnText.anchor.set(0.5, 0.5);
+ closeBtnText.x = modalW / 2;
+ closeBtnText.y = closeBtnY;
+ closeBtnText.interactive = true;
+ closeBtnText.down = function (bgRef) {
+ return function (x, y, obj) {
+ if (bgRef && bgRef.down) bgRef.down(x, y, obj);
+ };
+ }(closeBtnBg);
+ modalContainer.addChild(closeBtnText);
+ modalContainer.x = 2048 / 2 - modalW / 2;
+ modalContainer.y = 2732 / 2 - modalH / 2;
+ game.addChild(modalContainer);
+ }
+ };
+ }(btnBg);
+ btnBgList.push(btnBg);
+ startMenuContainer.addChild(btnBg);
+ // Button glow overlay
+ var btnGlow = LK.getAsset('can', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: btnX,
+ y: btnY,
+ width: buttonWidth * 1.08,
+ height: buttonHeight * 1.18
+ });
+ btnGlow.alpha = 0.0;
+ btnGlow.color = 0xffffff;
+ btnBg._glowOverlay = btnGlow;
+ startMenuContainer.addChild(btnGlow);
+ // Button highlight
+ var btnHighlight = LK.getAsset('can', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: btnX,
+ y: btnY - buttonHeight / 3,
+ width: buttonWidth * 0.92,
+ height: buttonHeight * 0.38
+ });
+ btnHighlight.alpha = 0.18;
+ btnHighlight.color = 0xffffff;
+ startMenuContainer.addChild(btnHighlight);
+ // Button text
+ var btnText = new Text2(menuButtons[i].label, {
+ size: 100,
+ fill: "#fff",
+ maxWidth: buttonWidth - 60
+ });
+ btnText.anchor.set(0.5, 0.5);
+ btnText.x = btnX;
+ btnText.y = btnY;
+ btnText.menuKey = menuButtons[i].key;
+ btnText.buttonIndex = i;
+ btnText.interactive = true;
+ btnText.defaultAlpha = 1;
+ btnText.down = function (btnBgRef, btnTextRef) {
+ return function (x, y, obj) {
+ btnTextRef.alpha = 0.65;
+ tween(btnTextRef, {
+ alpha: btnTextRef.defaultAlpha
+ }, {
+ duration: 120
+ });
+ if (btnBgRef && btnBgRef.down) btnBgRef.down(x, y, obj);
+ };
+ }(btnBg, btnText);
+ btnTextList.push(btnText);
+ startMenuContainer.addChild(btnText);
+}
+// Info text
+var infoText = new Text2("Drag the ship, shoot space objects!", {
+ size: 70,
+ fill: "#fff",
+ maxWidth: menuWidth - 80
+});
+infoText.anchor.set(0.5, 0.5);
+infoText.x = menuWidth / 2;
+infoText.y = startMenuBg.y + startMenuBg.height / 2 + 48;
+startMenuContainer.addChild(infoText);
+// Copyright
+var copyrightText = new Text2("© 2024 FRVR.Ava.Combo[POGAAS]", {
+ size: 38,
+ fill: 0xB0E0FF
+});
+copyrightText.anchor.set(0.5, 0.5);
+copyrightText.x = menuWidth / 2;
+copyrightText.y = menuHeight - 32;
+startMenuContainer.addChild(copyrightText);
+// Center menu on screen
+startMenuContainer.x = 2048 / 2 - menuWidth / 2;
+startMenuContainer.y = 2732 / 2 - menuHeight / 2;
// Dinamik butonlar
var menuButtons = [{
label: "Yeni Oyun",
key: "start",
@@ -1685,22 +2080,175 @@
}
// Oyun döngüsü
game.update = function () {
// (Geri alındı: ekran sağa doğru ilerlemesin, scrollX ve scrollSpeed kaldırıldı)
- // Galaksi arka planı kaldırıldı
- // Yıldızlar: parallax ve hafif döndürme
+ // --- MAIN MENU BACKGROUND & UI ANIMATIONS ---
+ // Animate stars (parallax, twinkle)
if (typeof starBgContainer !== "undefined" && stars && stars.length) {
for (var si = 0; si < stars.length; si++) {
var s = stars[si];
s.x -= s._vx;
s.rotation += s._rotSpeed;
- // Ekrandan soldan çıkarsa sağa wrap et
+ s._twinkle += 0.04 + Math.random() * 0.01;
+ s.alpha = 0.18 + 0.7 * Math.abs(Math.sin(s._twinkle));
if (s.x < -10) {
s.x = 2048 + 10;
s.y = Math.random() * 2732;
}
}
}
+ // Animate nebulae (slow drift, pulse)
+ if (typeof nebulae !== "undefined" && nebulae.length) {
+ for (var ni = 0; ni < nebulae.length; ni++) {
+ var n = nebulae[ni];
+ n.x -= n._vx;
+ n.y += n._vy;
+ n._pulse += 0.01;
+ n.alpha = 0.13 + 0.09 * (0.7 + 0.3 * Math.sin(n._pulse));
+ if (n.x < -n.width / 2) {
+ n.x = 2048 + n.width / 2;
+ n.y = 400 + Math.random() * 1800;
+ }
+ }
+ }
+ // Animate galaxies (slow drift, rotate)
+ if (typeof galaxies !== "undefined" && galaxies.length) {
+ for (var gi = 0; gi < galaxies.length; gi++) {
+ var g = galaxies[gi];
+ g.x -= g._vx;
+ g.y += g._vy;
+ g.rotation += g._rotSpeed;
+ if (g.x < -g.width / 2) {
+ g.x = 2048 + g.width / 2;
+ g.y = 300 + Math.random() * 1800;
+ }
+ }
+ }
+ // Animate asteroid flybys (fade in/out, move)
+ if (typeof menuAsteroids !== "undefined") {
+ if (typeof asteroidSpawnTick === "undefined") asteroidSpawnTick = 0;
+ asteroidSpawnTick++;
+ if (asteroidSpawnTick > 120 + Math.random() * 120) {
+ spawnMenuAsteroid();
+ asteroidSpawnTick = 0;
+ }
+ for (var ai = menuAsteroids.length - 1; ai >= 0; ai--) {
+ var a = menuAsteroids[ai];
+ a.x -= a._vx;
+ if (!a._fadeIn && !a._fadeOut && a.x < 2048 / 2) {
+ a._fadeOut = true;
+ tween(a, {
+ alpha: 0
+ }, {
+ duration: 400,
+ onFinish: function onFinish() {
+ if (a && a.parent) a.destroy();
+ }
+ });
+ }
+ if (a.x < -a.width / 2 || a.alpha <= 0.01) {
+ if (a.parent) a.destroy();
+ menuAsteroids.splice(ai, 1);
+ }
+ }
+ }
+ // Animate ship silhouettes (fly by left to right)
+ if (typeof menuShips !== "undefined") {
+ if (typeof shipSpawnTick === "undefined") shipSpawnTick = 0;
+ shipSpawnTick++;
+ if (shipSpawnTick > 180 + Math.random() * 180) {
+ spawnMenuShip();
+ shipSpawnTick = 0;
+ }
+ for (var si = menuShips.length - 1; si >= 0; si--) {
+ var sh = menuShips[si];
+ sh.x += sh._vx;
+ if (!sh._fadeOut && sh.x > 2048 + sh.width / 2) {
+ sh._fadeOut = true;
+ tween(sh, {
+ alpha: 0
+ }, {
+ duration: 400,
+ onFinish: function onFinish() {
+ if (sh && sh.parent) sh.destroy();
+ }
+ });
+ }
+ if (sh.x > 2048 + sh.width / 2 || sh.alpha <= 0.01) {
+ if (sh.parent) sh.destroy();
+ menuShips.splice(si, 1);
+ }
+ }
+ }
+ // Animate satellites (blink, move)
+ if (typeof menuSatellites !== "undefined") {
+ if (typeof satelliteSpawnTick === "undefined") satelliteSpawnTick = 0;
+ satelliteSpawnTick++;
+ if (satelliteSpawnTick > 240 + Math.random() * 180) {
+ spawnMenuSatellite();
+ satelliteSpawnTick = 0;
+ }
+ for (var sa = menuSatellites.length - 1; sa >= 0; sa--) {
+ var sat = menuSatellites[sa];
+ sat.x -= sat._vx;
+ sat._blink += 0.09;
+ sat.alpha = 0.22 + 0.13 * Math.abs(Math.sin(sat._blink));
+ if (sat.x < -sat.width / 2 || sat.alpha <= 0.01) {
+ if (sat.parent) sat.destroy();
+ menuSatellites.splice(sa, 1);
+ }
+ }
+ }
+ // Animate particles (fall, fade)
+ if (typeof menuParticles !== "undefined") {
+ if (typeof particleSpawnTick === "undefined") particleSpawnTick = 0;
+ particleSpawnTick++;
+ if (particleSpawnTick > 12) {
+ spawnMenuParticle();
+ particleSpawnTick = 0;
+ }
+ for (var pi = menuParticles.length - 1; pi >= 0; pi--) {
+ var p = menuParticles[pi];
+ p.y += p._vy;
+ p._life--;
+ if (p.y > 2732 + 20 || p._life <= 0) {
+ if (p.parent) p.destroy();
+ menuParticles.splice(pi, 1);
+ }
+ }
+ }
+ // Animate logo pulse
+ if (typeof logoText !== "undefined") {
+ var t = LK.ticks % 90 / 90;
+ var pulse = 1.0 + 0.06 * Math.sin(t * Math.PI * 2);
+ logoText.scaleX = logoText.scaleY = logoText._pulseBase * pulse;
+ logoText.alpha = 0.93 + 0.07 * Math.abs(Math.sin(t * Math.PI * 2));
+ }
+ // Animate menu button glow/hover
+ if (typeof btnBgList !== "undefined" && btnBgList.length) {
+ for (var bi = 0; bi < btnBgList.length; bi++) {
+ var btn = btnBgList[bi];
+ // If hovered (touch/click), pulse glow
+ if (btn._glow > 0.01) {
+ btn._glow -= 0.04;
+ if (btn._glow < 0) btn._glow = 0;
+ }
+ if (btn._glowOverlay) {
+ btn._glowOverlay.alpha = btn._glow * 0.7;
+ }
+ }
+ }
+ // Animate menu button hover on touch (simulate hover for mobile)
+ if (typeof btnTextList !== "undefined" && btnTextList.length) {
+ for (var ti = 0; ti < btnTextList.length; ti++) {
+ var tbtn = btnTextList[ti];
+ if (tbtn._hovering) {
+ if (btnBgList[tbtn.buttonIndex]) {
+ btnBgList[tbtn.buttonIndex]._glow = 1.0;
+ }
+ }
+ }
+ }
if (!gameStarted) return;
// Playership sağlık barı 0 olduğunda oyun bitsin
if (playerHealth <= 0) {
updateCanBar();
düşman uzay gemisi. In-Game asset. 2d. High contrast. No shadows
patlama efekti. In-Game asset. 2d. High contrast. No shadows
mermi yönünü sağa çevir ve yat
satürn. In-Game asset. 2d. High contrast. No shadows
meteor taşı. In-Game asset. 2d. High contrast. No shadows
bölüm sonu canavar için devasa uzay gemisi. In-Game asset. 2d. High contrast. No shadows
rengini değiştir
ışın mermisi. In-Game asset. 2d. High contrast. No shadows
yanan ateş topları. In-Game asset. 2d. High contrast. No shadows
oyunda açılacak bir uzay portalı için görüntüyü netleştir
A magical sci-fi starburst explosion for a 2D game effect, with a bright blue and white energy core bursting outward in radiant spikes, surrounded by glowing particles, swirling light trails, and a soft nebula-like aura. The effect should feel like a powerful portal discharge or dimensional rift opening, with dynamic energy and cinematic glow. Transparent background, digital art style, top-down angle, ideal for sprite use in games.. In-Game asset. 2d. High contrast. No shadows
A stunning 2D top-down galaxy for a space-themed game background, featuring a massive spiral galaxy with swirling arms in vibrant shades of blue, purple, and pink, a bright glowing core, scattered star clusters, distant nebulae, and a few small planets orbiting around. The galaxy should feel colorful, mysterious, and vast, with soft glowing effects and high contrast for a sci-fi aesthetic. Style: digital art, seamless background, suitable for looping game parallax layers.. In-Game asset. 2d. High contrast. No shadows
kalkanın içinde gemi olmasın
A 2D sci-fi gift box or power-up crate floating in space, with a glowing metallic surface, futuristic design, bright neon blue and silver accents, and a soft pulsing light effect. The box should look valuable and mysterious, slightly levitating with subtle sparkles or energy rings around it. Designed for a top-down space shooter game. Transparent background, digital art, ideal for sprite use.. In-Game asset. 2d. High contrast. No shadows
A 2D sci-fi power-up gift box that grants a shield, designed with a glowing blue energy core inside a metallic futuristic container. The box features holographic shield symbols, neon cyan highlights, and soft pulsing light. It is slightly levitating, surrounded by sparkles and a faint energy ring. The design should clearly suggest it gives protective power. Transparent background, digital art style, ideal for sprite use in a top-down space shooter game.. In-Game asset. 2d. High contrast. No shadows
bu görseli hız için değiştir
Design a basic 2D top-down spaceship with a compact, angular body and minimal detailing. The ship should have a small central cockpit, two modest rear thrusters, and one weapon mount. Colors are simple — grays and blues — suggesting a utilitarian design. It should look like a beginner’s ship: reliable but not advanced. In-Game asset. 2d. High contrast. No shadows
Upgrade the Level 1 ship into a more capable 2D top-down design. Add wing extensions with subtle glowing lines, a larger engine section with animated thrusters, and two visible weapon hardpoints. Add more color variation (blues, steel, light glow effects) to indicate progress and increased power.. In-Game asset. 2d. High contrast. No shadows
Transform the ship into a high-tech 2D top-down spacecraft. Add shield emitters with rotating energy halos, four weapon slots, side thrusters, and an enhanced cockpit with a golden or crystal-like glow. The silhouette is wider and more refined. Visuals should include detailed paneling, moving parts, and advanced energy flows.. In-Game asset. 2d. High contrast. No shadows
elmas. In-Game asset. 2d. High contrast. No shadows
uzay 2d etkileyici lazer ışını. In-Game asset. 2d. High contrast. No shadows