User prompt
Düşman sağlık barı görünsün. Ayrıca düşmana sıkılan mermi görselleri, düşmana çarpınca yok olsun.
User prompt
Asteroid Avcısı mermi hızını %10 arttır
User prompt
Asteroid Avcısı, Asteroidi resim boyutunun dışından saldırı yok etsin. Asteroid resminin içine girmesin.
User prompt
Takip mesafesi olsun daima. Uzaktan saldırılar olsun birbirlerinin içine girmesin
User prompt
Bütün birimler birimler %10 uzaklıkta ateş etsinler.
User prompt
Asteroid Avcısı, Asteroidi yok etsin veya etmesin, koloniye gelmeden sürekli olarak harita da dolaşsın ve ilgili astreidleri yok etmeye çalışsın.
User prompt
Bizim askerler, düşman birliği gelirken savunma saldırısı yapsın
User prompt
Askerlerin can barı için özel resim dosyası oluştur.
User prompt
Can barı için özel resim dosyası oluştur
User prompt
Düşman askerleri uzaktan saldırmasınlar. Bizim koloni yakınına gelince benim askerler ile savaşıp öyle base saldırsınlar
User prompt
Bu düşman Base'ine bir özel resim dosyası oluştur.
User prompt
düşman hızı bizim askerler gibi çok yavaş olsun. Saldırmadan önce kendi base etrafında çok yavaş şekilde dolaşsın.
User prompt
Bu resim 1 dakikada 1 bize saldırası için düşman gemisi göndersin.
User prompt
Haritanın üst tarafına asteroid gibi dışardan gelen ama bu sabit bir yerde duran resim oluştur.
User prompt
Oyundaki bütün düşman konulu kodları sil
User prompt
Maksimum sayı hiçbirinde olmasın ve otomatik satın alım hiçbirinde olmasın.
User prompt
Kaynak Avcısı ve Asteroit Avcısı ücreti 300 kaynak, Savaşçı ücreti 500 kaynak olarak güncelle. Ayrıca her satın alımda %10 artır.
User prompt
Toplanacak olan kaynakların içeriği 2 ile 10 arasında rastgele olsun.
User prompt
Kaynak Avcısının Kendisine özel resim dosyası oluştur
User prompt
Kaynak Avcısı Ücretini 300 Kaynak yapalım. Ayrıca başlangıçta 1 tane Kaynak Avcısı var iken başlayalım
User prompt
Please fix the bug: 'ReferenceError: hunterActiveRatio is not defined' in or related to this line: 'var hunterActiveY = 2732 * hunterActiveRatio;' Line Number: 1129
User prompt
Please fix the bug: 'resourceHunterBuyBtn is not defined' in or related to this line: 'resourceHunterBuyBtn.down = function (x, y, obj) {' Line Number: 744
User prompt
Sıfırdan Yeni bir gemi türü oluştur. İsmi ''Kaynak Avcısı'' olsun. Sadece haritada olan kaynakları toplamakla ilgilensin. Kod yaz bununla ilgili.
User prompt
Lütfen işlemlere devam et.
User prompt
Gemi satın alma panelinin kendisine özel resim dosyası oluştur
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
// Asteroit Avcısı (Collector)
var AsteroidHunter = Container.expand(function () {
var self = Container.call(this);
var col = self.attachAsset('collector', {
anchorX: 0.5,
anchorY: 0.5
});
self.target = null;
// Avcı hızı, kaynak hızından %25 fazla olacak şekilde ayarlanır
self.speed = 1.25 * (0.002 + 0.001) * 0.1 * 2732; // Kaynakların max hızından %25 fazla (normalize için 2732 ile çarpıldı)
self.state = 'idle'; // idle, moving, returning
self.update = function () {
if (self.state === 'moving' && self.target) {
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
// --- Avcı mermi sıksın: 60 tickte bir (1 saniyede bir) ---
if (typeof self.lastShot === "undefined") self.lastShot = 0;
if (typeof self.shootDelay === "undefined") self.shootDelay = 60;
if (LK.ticks - self.lastShot > self.shootDelay && dist > 20) {
var b = new Container();
var bulletAsset = b.attachAsset('collector_bullet', {
anchorX: 0.5,
anchorY: 0.5
});
b.x = self.x;
b.y = self.y;
// Asteroide doğru yönlendir
var tdist = Math.sqrt(dx * dx + dy * dy);
b.dirX = tdist > 0 ? dx / tdist : 0;
b.dirY = tdist > 0 ? dy / tdist : -1;
b.speed = 18 * 0.1;
b.update = function () {
b.x += b.dirX * b.speed;
b.y += b.dirY * b.speed;
// Asteroide çarptıysa yok et
if (self.target && b.intersects(self.target)) {
if (typeof self.target.hp === "number" && self.target.hp > 0) {
self.target.hp -= 1;
}
b.destroy();
if (typeof bullets !== "undefined") {
var idx = bullets.indexOf(b);
if (idx !== -1) bullets.splice(idx, 1);
}
}
// Ekran dışıysa yok et
if (b.x < -100 || b.x > 2148 || b.y < -100 || b.y > 2832) {
b.destroy();
if (typeof bullets !== "undefined") {
var idx = bullets.indexOf(b);
if (idx !== -1) bullets.splice(idx, 1);
}
}
};
if (typeof bullets !== "undefined") bullets.push(b);
if (typeof game !== "undefined") game.addChild(b);
self.lastShot = LK.ticks;
}
if (dist < 10) {
// Asteroide ulaştıysa, sadece idle'a geçsin
self.state = 'returning';
} else {
self.x += self.speed * dx / dist;
self.y += self.speed * dy / dist;
}
} else if (self.state === 'returning') {
var dx = colony.x - self.x;
var dy = colony.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 10) {
self.state = 'idle';
self.target = null;
} else {
self.x += self.speed * dx / dist;
self.y += self.speed * dy / dist;
}
}
};
return self;
});
// Asteroid ve kaynak çıkışı için yeni AsteroidNode class'ı
var AsteroidNode = Container.expand(function () {
var self = Container.call(this);
// Kaynak türleri ve asteroid asset id'leri
var asteroidTypes = [{
name: "Altın",
asset: "asteroid_gold",
resourceAsset: "resource_gold"
}, {
name: "Kobalt",
asset: "asteroid_cobalt",
resourceAsset: "resource_cobalt"
}, {
name: "Nikel",
asset: "asteroid_nickel",
resourceAsset: "resource_nickel"
}, {
name: "Helyum-3",
asset: "asteroid_helium3",
resourceAsset: "resource_helium3"
}, {
name: "Platin",
asset: "asteroid_platinum",
resourceAsset: "resource_platinum"
}, {
name: "Demir",
asset: "asteroid_iron",
resourceAsset: "resource_iron"
}, {
name: "Manganez",
asset: "asteroid_manganese",
resourceAsset: "resource_manganese"
}];
// Rastgele bir kaynak türü seç
var typeIndex = Math.floor(Math.random() * asteroidTypes.length);
self.resourceType = asteroidTypes[typeIndex].name;
self.asteroidAsset = asteroidTypes[typeIndex].asset;
self.resourceAsset = asteroidTypes[typeIndex].resourceAsset;
// Asteroid görseli
var ast = self.attachAsset(self.asteroidAsset, {
anchorX: 0.5,
anchorY: 0.5
});
self.hp = 3 + Math.floor(Math.random() * 3); // 3-5 arası can
self.collected = false;
self.resourceSpawned = false;
// Hareket: Rastgele kenardan giriş
var edge = Math.floor(Math.random() * 4);
var startX, startY, endX, endY;
var margin = 120;
if (edge === 0) {
startX = -margin;
startY = 400 + Math.random() * (2732 - 800);
endX = 2048 + margin;
endY = startY + (Math.random() - 0.5) * 400;
} else if (edge === 1) {
startX = 2048 + margin;
startY = 400 + Math.random() * (2732 - 800);
endX = -margin;
endY = startY + (Math.random() - 0.5) * 400;
} else if (edge === 2) {
startX = Math.random() * 2048;
startY = -margin;
endX = startX + (Math.random() - 0.5) * 400;
endY = 2732 + margin;
} else {
startX = Math.random() * 2048;
startY = 2732 + margin;
endX = startX + (Math.random() - 0.5) * 400;
endY = -margin;
}
self.x = startX;
self.y = startY;
self._moveStartX = startX;
self._moveStartY = startY;
self._moveEndX = endX;
self._moveEndY = endY;
self._moveProgress = 0;
self._moveSpeed = (0.002 + Math.random() * 0.001) * 0.1;
self.visible = true;
self.resourceNode = null; // Kaynak nesnesi referansı
self.update = function () {
if (self.collected) return;
// Hareket ilerlemesini güncelle
self._moveProgress += self._moveSpeed;
if (self._moveProgress > 1) {
self.collected = true;
self.visible = false;
return;
}
// Lineer hareket
self.x = self._moveStartX + (self._moveEndX - self._moveStartX) * self._moveProgress;
self.y = self._moveStartY + (self._moveEndY - self._moveStartY) * self._moveProgress;
// --- Asteroid boyutunu koloniye yaklaştıkça büyüt ---
// Koloniye olan mesafeyi hesapla
if (typeof colony !== "undefined" && colony && typeof colony.x === "number" && typeof colony.y === "number") {
var dxCol = self.x - colony.x;
var dyCol = self.y - colony.y;
var distCol = Math.sqrt(dxCol * dxCol + dyCol * dyCol);
// Maksimum mesafe: ekran köşesinden koloniye (en uzak ~2732)
var maxDist = 2732;
// Minimum scale: 0.25, Maksimum scale: 1.2
var minScale = 0.25;
var maxScale = 1.2;
// Koloniye yaklaştıkça scale artar, uzaktayken küçüktür
var t = 1 - Math.min(distCol / maxDist, 1);
var scale = minScale + (maxScale - minScale) * t;
// Asteroit görselini ölçekle
if (ast) {
ast.scaleX = scale;
ast.scaleY = scale;
}
}
// Asteroid yok edildi ve kaynak çıkmadıysa kaynak çıkar
if (self.hp <= 0 && !self.resourceSpawned) {
self.resourceSpawned = true;
// Kaynak node'u oluştur
var resNode = new ResourceNode(self.resourceType, self.resourceAsset);
resNode.x = self.x;
resNode.y = self.y;
if (typeof resourceNodes !== "undefined") resourceNodes.push(resNode);
if (typeof game !== "undefined") game.addChild(resNode);
self.collected = true;
self.visible = false;
}
};
return self;
});
// Mermi
var Bullet = Container.expand(function () {
var self = Container.call(this);
var b = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 40 * 0.1;
self.dirX = 0;
self.dirY = -1;
self.from = 'player'; // veya 'enemy'
self.targetEnemy = null; // Eğer hedef varsa
self.attackPower = 1; // Her merminin saldırı gücü 1 olsun
self.update = function () {
// Eğer bu oyuncu mermisi ve hedefi varsa, hedefe yönel
if (self.from === 'player' && self.targetEnemy && typeof self.targetEnemy.x === "number" && typeof self.targetEnemy.y === "number") {
var dx = self.targetEnemy.x - self.x;
var dy = self.targetEnemy.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist > 0) {
self.dirX = dx / dist;
self.dirY = dy / dist;
}
}
self.x += self.dirX * self.speed;
self.y += self.dirY * self.speed;
};
return self;
});
// Koloni ana üssü
var Colony = Container.expand(function () {
var self = Container.call(this);
var c = self.attachAsset('colony', {
anchorX: 0.5,
anchorY: 0.5
});
// Koloni canı
self.maxHp = 50;
self.hp = 50;
return self;
});
// 60 saniye * 60 FPS
// Düşman gemisi class'ı (önce base etrafında yavaşça döner, sonra saldırır)
var EnemyShip = Container.expand(function () {
var self = Container.call(this);
var s = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = topAsteroid.x;
self.y = topAsteroid.y + 80;
// Askerler gibi yavaş hız: ResourceHunter ile aynı hız
self.speed = 1.1 * (0.002 + 0.001) * 0.1 * 2732; // 0.0003*0.1*2732 ≈ 0.08*2732 ≈ 218
self.lastShot = 0;
self.shootDelay = 60; // 1 saniyede bir ateş etsin
self.hp = 3;
self.state = 'orbiting'; // 'orbiting' -> 'attacking'
self.orbitTime = 0;
self.orbitDuration = 180; // 3 saniye boyunca base etrafında dönecek
self.orbitRadius = 180 + Math.random() * 60; // 180-240px arası
self.orbitAngle = Math.random() * Math.PI * 2;
self.update = function () {
if (self.state === 'orbiting') {
// Base etrafında yavaşça daire çiz
self.orbitTime++;
self.orbitAngle += 0.012; // Yavaşça döner
self.x = topAsteroid.x + Math.cos(self.orbitAngle) * self.orbitRadius;
self.y = topAsteroid.y + Math.sin(self.orbitAngle) * self.orbitRadius;
if (self.orbitTime > self.orbitDuration) {
self.state = 'approaching';
// Saldırıya başlarken hedefi koloniye kilitle
self.attackTargetX = colony.x;
self.attackTargetY = colony.y;
}
} else if (self.state === 'approaching') {
// Koloniye yaklaşana kadar ilerle, ama saldırma
var dx = self.attackTargetX - self.x;
var dy = self.attackTargetY - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
// Koloniye belli bir mesafeye (ör: 350px) kadar yaklaşınca önce bizim askerlerle savaş
var engageRadius = 350;
if (dist > engageRadius) {
if (dist > 0) {
self.x += self.speed * dx / dist;
self.y += self.speed * dy / dist;
}
} else {
// Koloniye yaklaştı, önce bizim askerlerle savaş
self.state = 'engaging';
}
} else if (self.state === 'engaging') {
// Sadece bizim gemilere saldır, koloniye saldırmaz
// En yakın oyuncu savaşçısını bul
var nearestShip = null;
var minDist = 999999;
if (ship && ship.visible && typeof ship.x === "number" && typeof ship.y === "number" && ship.hp > 0) {
var dxs = ship.x - self.x;
var dys = ship.y - self.y;
var dists = Math.sqrt(dxs * dxs + dys * dys);
if (dists < minDist) {
minDist = dists;
nearestShip = ship;
}
}
// Eğer yakınsa ona yaklaş ve ateş et
if (nearestShip && minDist < 400) {
// Yaklaş
if (minDist > 40) {
self.x += self.speed * (nearestShip.x - self.x) / minDist;
self.y += self.speed * (nearestShip.y - self.y) / minDist;
}
// Ateş etme (her 1 saniyede bir)
if (LK.ticks - self.lastShot > self.shootDelay) {
var b = new Bullet();
b.x = self.x;
b.y = self.y + 40;
b.dirX = nearestShip.x - self.x;
b.dirY = nearestShip.y - self.y;
var bdist = Math.sqrt(b.dirX * b.dirX + b.dirY * b.dirY);
if (bdist > 0) {
b.dirX /= bdist;
b.dirY /= bdist;
} else {
b.dirX = 0;
b.dirY = 1;
}
b.from = 'enemy';
b.attackPower = 2;
bullets.push(b);
game.addChild(b);
self.lastShot = LK.ticks;
}
// Eğer oyuncu gemisi yok olduysa, tekrar koloniye saldırmaya başla
if (nearestShip.hp <= 0 || !nearestShip.visible) {
self.state = 'attacking';
}
} else {
// Oyuncu gemisi yoksa veya çok uzaktaysa, tekrar koloniye saldır
self.state = 'attacking';
}
} else if (self.state === 'attacking') {
// Koloniye doğru düz hareket
var dx = self.attackTargetX - self.x;
var dy = self.attackTargetY - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist > 0) {
self.x += self.speed * dx / dist;
self.y += self.speed * dy / dist;
}
// Ateş etme (her 1 saniyede bir)
if (LK.ticks - self.lastShot > self.shootDelay) {
var b = new Bullet();
b.x = self.x;
b.y = self.y + 40;
b.dirX = colony.x - self.x;
b.dirY = colony.y - self.y;
var bdist = Math.sqrt(b.dirX * b.dirX + b.dirY * b.dirY);
if (bdist > 0) {
b.dirX /= bdist;
b.dirY /= bdist;
} else {
b.dirX = 0;
b.dirY = 1;
}
b.from = 'enemy';
b.attackPower = 2;
bullets.push(b);
game.addChild(b);
self.lastShot = LK.ticks;
}
// Koloniye çok yaklaştıysa yok ol
if (dist < 40) {
self.hp = 0;
}
}
};
return self;
});
// Koloni can barı ve can göstergesi
// Kaynak Avcısı (ResourceHunter) - sadece haritadaki kaynakları toplar
var ResourceHunter = Container.expand(function () {
var self = Container.call(this);
var hunter = self.attachAsset('resource_hunter', {
// Artık kendine özel görsel
anchorX: 0.5,
anchorY: 0.5
});
self.target = null;
self.speed = 1.1 * (0.002 + 0.001) * 0.1 * 2732; // Kaynaklara uygun hız
self.state = 'idle'; // idle, moving, returning
self.carryType = null;
self.carryAmount = 0;
self.update = function () {
// Eğer kaynak taşıyorsa koloniye dön
if (self.state === 'returning' && self.carryType && self.carryAmount > 0) {
var dx = colony.x - self.x;
var dy = colony.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 20) {
// Kaynağı koloniye bırak
if (typeof resourceStocks[self.carryType] === "number") {
resourceStocks[self.carryType] += self.carryAmount;
}
self.carryType = null;
self.carryAmount = 0;
self.state = 'idle';
self.target = null;
} else {
self.x += self.speed * dx / dist;
self.y += self.speed * dy / dist;
}
return;
}
// Eğer hedef kaynak varsa ona git
if (self.state === 'moving' && self.target && !self.target.collected && self.target.visible) {
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 20) {
// Kaynağı topla
self.carryType = self.target.resourceType;
self.carryAmount = self.target.amount;
self.target.collected = true;
self.target.visible = false;
self.state = 'returning';
} else {
self.x += self.speed * dx / dist;
self.y += self.speed * dy / dist;
}
return;
}
// Idle ise yeni hedef ara
if (self.state === 'idle') {
// En yakın toplanmamış kaynağı bul
var minDist = 99999;
var targetRes = null;
for (var i = 0; i < resourceNodes.length; i++) {
var r = resourceNodes[i];
if (!r.collected && r.visible) {
var dx = r.x - self.x;
var dy = r.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
targetRes = r;
}
}
}
if (targetRes) {
self.target = targetRes;
self.state = 'moving';
}
}
};
return self;
});
// Kaynak noktası (sadece asteroid yok edilince çıkar)
var ResourceNode = Container.expand(function (resourceType, resourceAsset) {
var self = Container.call(this);
// resourceType ve resourceAsset parametre olarak alınır
self.resourceType = resourceType || "Altın";
self.resourceAsset = resourceAsset || "resource_gold";
var res = self.attachAsset(self.resourceAsset, {
anchorX: 0.5,
anchorY: 0.5
});
self.amount = 2 + Math.floor(Math.random() * 9); // 2-10 arası kaynak
self.collected = false;
self.visible = true;
// Sabit durur, hareket etmez
self.update = function () {};
return self;
});
// Oyuncu gemisi
var Ship = Container.expand(function () {
var self = Container.call(this);
var s = self.attachAsset('ship', {
anchorX: 0.5,
anchorY: 0.5
});
// Hız %100 yavaşlatıldı
self.speed = 11 * 0.1;
self.targetX = self.x;
self.targetY = self.y;
self.lastShot = 0;
self.shootDelay = 30; // 0.5s
self.update = function () {
// Hareket
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist > self.speed) {
self.x += self.speed * dx / dist;
self.y += self.speed * dy / dist;
} else {
self.x = self.targetX;
self.y = self.targetY;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0a0a1a
});
/****
* Game Code
****/
// Collector'ın sıktığı mermi için özel asset
// Global değişkenler
// Koloni, kaynak, gemi ve düşman için temel şekiller
// 7 farklı asteroid görseli (her kaynak için bir tane)
// Sağ alt gemi paneli için özel arka plan görseli (daha belirgin, köşeleri yuvarlatılmış, koyu mavi)
// Kaynak Avcısı için özel görsel
function _typeof3(o) {
"@babel/helpers - typeof";
return _typeof3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof3(o);
}
function _typeof2(o) {
"@babel/helpers - typeof";
return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof2(o);
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
var colony;
var ship;
var collectors = [];
var resourceHunters = [];
var autoResourceHunters = 1;
var resourceNodes = [];
var bullets = [];
var resources = 0;
var autoCollectors = 1;
var spawnEnemyTimer = 0;
var dragNode = null;
var lastTouch = {
x: 0,
y: 0
};
// Koloni kur
colony = new Colony();
colony.x = 2048 / 2;
colony.y = 2732 - 400;
game.addChild(colony);
// Haritanın üst tarafında sabit bir asteroid resmi oluştur
var topAsteroidBase = LK.getAsset('enemy_base', {
anchorX: 0.5,
anchorY: 0.5
});
topAsteroidBase.x = 2048 / 2;
topAsteroidBase.y = 120; // Ekranın üst kısmında, ortalanmış
game.addChild(topAsteroidBase);
// Eski asteroid görseli istenirse, aşağıdaki satırı kullanabilirsiniz:
// var topAsteroid = LK.getAsset('asteroid_iron', { anchorX: 0.5, anchorY: 0.5 });
// topAsteroid.x = 2048 / 2;
// topAsteroid.y = 120;
// game.addChild(topAsteroid);
// Oyun kodunda topAsteroid olarak kullanılan referansları topAsteroidBase olarak güncelleyin:
var topAsteroid = topAsteroidBase;
// Düşman gemisi için array ve timer
var enemyShips = [];
var enemySpawnTimer = 0;
var ENEMY_SPAWN_INTERVAL = 60 * 60;
// Koloni can barı ve can göstergesi
var colonyHpBarBg = LK.getAsset('collector', {
width: 220,
height: 28,
color: 0x222222,
anchorX: 0.5,
anchorY: 0.5
});
colonyHpBarBg.y = colony.y - 160;
colonyHpBarBg.x = colony.x;
game.addChild(colonyHpBarBg);
var colonyHpBar = LK.getAsset('collector', {
width: 216,
height: 20,
color: 0x4adf4a,
anchorX: 0.5,
anchorY: 0.5
});
colonyHpBar.y = colony.y - 160;
colonyHpBar.x = colony.x;
game.addChild(colonyHpBar);
// Sol alt köşeye hizalı GUI grubu oluştur
var guiLeftBottomGroup = new Container();
LK.gui.bottomLeft.addChild(guiLeftBottomGroup);
// Koloni can yazısı (sol alt)
var colonyHpTxt = new Text2('50 / 50', {
size: 36,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
colonyHpTxt.anchor.set(0, 1); // Sol alt köşe
colonyHpTxt.x = 0;
colonyHpTxt.y = 0;
guiLeftBottomGroup.addChild(colonyHpTxt);
// Kaynak göstergesi (sol alt)
var resourceTxt = new Text2('Toplam Kaynak: 0', {
size: 36,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
resourceTxt.anchor.set(0, 1);
resourceTxt.x = 0;
resourceTxt.y = colonyHpTxt.y - colonyHpTxt.height - 8;
guiLeftBottomGroup.addChild(resourceTxt);
// collectorTxt: Sadece yükseklik için dummy olarak tanımlanır (sol panelde gösterilmiyor)
var collectorTxt = new Text2('Asteroit Avcısı: 1', {
size: 36,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
collectorTxt.anchor.set(0, 1);
collectorTxt.x = 0;
collectorTxt.y = resourceTxt.y - resourceTxt.height - 8;
// Gemi sayısı göstergesi -- KALDIRILDI
var guiRightBottomGroup = new Container();
LK.gui.bottomRight.addChild(guiRightBottomGroup);
// Koloni Sağlığı başlığı (sağ alt)
var colonyHpLabelRight = new Text2('Koloni Sağlığı', {
size: 28,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
colonyHpLabelRight.anchor.set(1, 1);
colonyHpLabelRight.x = 0;
colonyHpLabelRight.y = 0;
guiRightBottomGroup.addChild(colonyHpLabelRight);
// Koloni can yazısı (sağ alt)
var colonyHpTxtRight = new Text2('50 / 50', {
size: 36,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
colonyHpTxtRight.anchor.set(1, 1); // Sağ alt köşe
colonyHpTxtRight.x = 0;
colonyHpTxtRight.y = -colonyHpLabelRight.height - 8;
guiRightBottomGroup.addChild(colonyHpTxtRight);
// Otomasyon göstergesi (sağ alt)
var collectorTxtRight = new Text2('Asteroit Avcısı: 1', {
size: 36,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
collectorTxtRight.anchor.set(1, 1);
collectorTxtRight.x = 0;
collectorTxtRight.y = -colonyHpLabelRight.height - colonyHpTxtRight.height - 16;
guiRightBottomGroup.addChild(collectorTxtRight);
// Gemi sayısı göstergesi (sağ alt)
var shipCountTxtRight = new Text2('Savaşçı: 1', {
size: 36,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
shipCountTxtRight.anchor.set(1, 1);
shipCountTxtRight.x = 0;
shipCountTxtRight.y = -colonyHpLabelRight.height - colonyHpTxtRight.height - collectorTxtRight.height - 24;
guiRightBottomGroup.addChild(shipCountTxtRight);
// Gemi canı göstergesi (sağ alt) -- KALDIRILDI
// --- Sağ alt panel: Gemi satın alma paneli (yeni) ---
var shipBuyPanelGroup = new Container();
shipBuyPanelGroup.x = 0;
shipBuyPanelGroup.y = -colonyHpLabelRight.height - colonyHpTxtRight.height - collectorTxtRight.height - shipCountTxtRight.height - 48 - 260; // 260px üstte, panel yüksekliği kadar yukarıda
guiRightBottomGroup.addChild(shipBuyPanelGroup);
// Panel arka planı (özel görsel, hafif şeffaf)
var shipBuyPanelBg = LK.getAsset('ship_buy_panel_bg', {
anchorX: 1,
anchorY: 1
});
shipBuyPanelBg.alpha = 0.92;
shipBuyPanelBg.x = 0;
shipBuyPanelBg.y = 0;
shipBuyPanelGroup.addChild(shipBuyPanelBg);
// Panel başlığı
var shipBuyPanelTitle = new Text2('Savaşçı Satın Al', {
size: 32,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
shipBuyPanelTitle.anchor.set(1, 1);
shipBuyPanelTitle.x = -24;
shipBuyPanelTitle.y = -24;
shipBuyPanelGroup.addChild(shipBuyPanelTitle);
// Satın alma butonu
var shipBuyBtn = new Text2('Yeni Savaşçı (500 Kaynak)', {
size: 28,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
shipBuyBtn.anchor.set(1, 1);
shipBuyBtn.x = -32;
shipBuyBtn.y = -80;
shipBuyBtn.interactive = true;
shipBuyBtn.buttonMode = true;
shipBuyBtn.hitArea = {
x: -shipBuyBtn.width - 20,
y: -10,
width: shipBuyBtn.width + 40,
height: shipBuyBtn.height + 20
};
shipBuyPanelGroup.addChild(shipBuyBtn);
// Asteroit Avcısı satın alma butonu
var collectorBuyBtn = new Text2('Asteroit Avcısı (300 Kaynak)', {
size: 28,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
collectorBuyBtn.anchor.set(1, 1);
collectorBuyBtn.x = -32;
collectorBuyBtn.y = -140;
collectorBuyBtn.interactive = true;
collectorBuyBtn.buttonMode = true;
collectorBuyBtn.hitArea = {
x: -collectorBuyBtn.width - 20,
y: -10,
width: collectorBuyBtn.width + 40,
height: collectorBuyBtn.height + 20
};
shipBuyPanelGroup.addChild(collectorBuyBtn);
// --- Satın alma fiyatları ve artış oranı ---
var shipBuyPrice = 500;
var collectorBuyPrice = 300;
var resourceHunterBuyPrice = 300;
var shipBuyPriceIncrease = 1.10;
var collectorBuyPriceIncrease = 1.10;
var resourceHunterBuyPriceIncrease = 1.10;
// Gemi satın alma işlemi
shipBuyBtn.down = function (x, y, obj) {
if (resources >= shipBuyPrice && (!ship.visible || ship.hp <= 0)) {
resources -= shipBuyPrice;
ship.hp = ship.maxHp || 6;
ship.visible = true;
ship.x = 2048 / 2;
ship.y = 2732 - 700;
LK.effects.flashObject(ship, 0x4adf4a, 800);
shipBuyPrice = Math.ceil(shipBuyPrice * shipBuyPriceIncrease);
shipBuyBtn.setText('Yeni Savaşçı (' + shipBuyPrice + ' Kaynak)');
}
};
// Asteroit Avcısı satın alma işlemi
collectorBuyBtn.down = function (x, y, obj) {
if (resources >= collectorBuyPrice) {
resources -= collectorBuyPrice;
autoCollectors++;
createCollectors(autoCollectors);
LK.effects.flashObject(collectors[collectors.length - 1], 0x4adf4a, 800);
collectorBuyPrice = Math.ceil(collectorBuyPrice * collectorBuyPriceIncrease);
collectorBuyBtn.setText('Asteroit Avcısı (' + collectorBuyPrice + ' Kaynak)');
}
};
// Kaynak Avcısı satın alma butonu
var resourceHunterBuyBtn = new Text2('Kaynak Avcısı (' + resourceHunterBuyPrice + ' Kaynak)', {
size: 28,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
resourceHunterBuyBtn.anchor.set(1, 1);
resourceHunterBuyBtn.x = -32;
resourceHunterBuyBtn.y = -200;
resourceHunterBuyBtn.interactive = true;
resourceHunterBuyBtn.buttonMode = true;
resourceHunterBuyBtn.hitArea = {
x: -resourceHunterBuyBtn.width - 20,
y: -10,
width: resourceHunterBuyBtn.width + 40,
height: resourceHunterBuyBtn.height + 20
};
shipBuyPanelGroup.addChild(resourceHunterBuyBtn);
// Kaynak Avcısı satın alma işlemi
resourceHunterBuyBtn.down = function (x, y, obj) {
if (resources >= resourceHunterBuyPrice) {
resources -= resourceHunterBuyPrice;
autoResourceHunters++;
createResourceHunters(autoResourceHunters);
LK.effects.flashObject(resourceHunters[resourceHunters.length - 1], 0x4adf4a, 800);
resourceHunterBuyPrice = Math.ceil(resourceHunterBuyPrice * resourceHunterBuyPriceIncrease);
resourceHunterBuyBtn.setText('Kaynak Avcısı (' + resourceHunterBuyPrice + ' Kaynak)');
}
};
// --- Sağ alt panel: Gemi öğeleri satın alma paneli ---
var shipPanelGroup = new Container();
shipPanelGroup.x = 0;
shipPanelGroup.y = -colonyHpLabelRight.height - colonyHpTxtRight.height - collectorTxtRight.height - shipCountTxtRight.height - 48;
guiRightBottomGroup.addChild(shipPanelGroup);
// Panel arka planı (özel görsel, hafif şeffaf)
var shipPanelBg = LK.getAsset('ship_panel_bg', {
anchorX: 1,
anchorY: 1
});
shipPanelBg.alpha = 0.92;
shipPanelBg.x = 0;
shipPanelBg.y = 0;
shipPanelGroup.addChild(shipPanelBg);
// Panel başlığı
var shipPanelTitle = new Text2('Savaşçı Yükseltmeleri', {
size: 32,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
shipPanelTitle.anchor.set(1, 1);
shipPanelTitle.x = -24;
shipPanelTitle.y = -24;
shipPanelGroup.addChild(shipPanelTitle);
// Satın alınabilir öğeler: örnek olarak "Savaşçı Canı +1" ve "Savaşçı Yenile"
var shipUpgradeBtn = new Text2('Can +1 (30 Kaynak)', {
size: 28,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
shipUpgradeBtn.anchor.set(1, 1);
shipUpgradeBtn.x = -32;
shipUpgradeBtn.y = -80;
shipUpgradeBtn.interactive = true;
shipUpgradeBtn.buttonMode = true;
shipUpgradeBtn.hitArea = {
x: -shipUpgradeBtn.width - 20,
y: -10,
width: shipUpgradeBtn.width + 40,
height: shipUpgradeBtn.height + 20
};
shipPanelGroup.addChild(shipUpgradeBtn);
shipUpgradeBtn.down = function (x, y, obj) {
// 30 kaynak ile savaşçı canı artır
if (resources >= 30 && typeof ship.hp === "number" && typeof ship.maxHp === "number" && ship.visible) {
resources -= 30;
ship.maxHp += 1;
ship.hp = ship.maxHp;
LK.effects.flashObject(ship, 0x4adf4a, 600);
}
};
var shipRespawnBtn = new Text2('Savaşçı Yenile (60 Kaynak)', {
size: 28,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
shipRespawnBtn.anchor.set(1, 1);
shipRespawnBtn.x = -32;
shipRespawnBtn.y = -140;
shipRespawnBtn.interactive = true;
shipRespawnBtn.buttonMode = true;
shipRespawnBtn.hitArea = {
x: -shipRespawnBtn.width - 20,
y: -10,
width: shipRespawnBtn.width + 40,
height: shipRespawnBtn.height + 20
};
shipPanelGroup.addChild(shipRespawnBtn);
shipRespawnBtn.down = function (x, y, obj) {
// 60 kaynak ile gemi tekrar aktif edilir
if (resources >= 60 && (!ship.visible || ship.hp <= 0)) {
resources -= 60;
ship.hp = ship.maxHp || 6;
ship.visible = true;
ship.x = 2048 / 2;
ship.y = 2732 - 700;
LK.effects.flashObject(ship, 0x4adf4a, 800);
}
};
// Paneli sağ alt köşede, diğer yazıların üstünde tutmak için z-index ayarı
if (typeof shipPanelGroup.setChildIndex === "function") {
shipPanelGroup.setChildIndex(shipPanelBg, 0);
}
// Sağ üst köşeye "Oyunu Sıfırla" butonu ekle
var resetBtn = new Text2('Oyunu Sıfırla', {
size: 44,
fill: "#fff",
font: "bold",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
resetBtn.anchor.set(1, 0); // sağ üst köşe
resetBtn.x = 0;
resetBtn.y = 0;
resetBtn.interactive = true;
resetBtn.buttonMode = true;
resetBtn.hitArea = {
x: -20,
y: -10,
width: resetBtn.width + 40,
height: resetBtn.height + 20
};
resetBtn.down = function (x, y, obj) {
// Oyun ilerlemesini sıfırla
if (typeof storage !== "undefined" && storage.clear) {
storage.clear();
}
LK.showGameOver(); // Oyun sıfırlama için game over popup tetikle
};
LK.gui.topRight.addChild(resetBtn);
// Kaynak türleri ve isimleri
var resourceTypeList = [{
name: "Altın",
asset: "resource_gold"
}, {
name: "Kobalt",
asset: "resource_cobalt"
}, {
name: "Nikel",
asset: "resource_nickel"
}, {
name: "Helyum-3",
asset: "resource_helium3"
}, {
name: "Platin",
asset: "resource_platinum"
}, {
name: "Demir",
asset: "resource_iron"
}, {
name: "Manganez",
asset: "resource_manganese"
}];
// Her kaynak için stok tut
var resourceStocks = {};
for (var i = 0; i < resourceTypeList.length; i++) {
resourceStocks[resourceTypeList[i].name] = 0;
}
// Oyun başında storage'dan yükleme yapılmaz, her zaman sıfırdan başlar
// Her kaynak için ayrı Text2 oluştur, alt alta hizala
var resourceStockTxts = [];
var lastY = collectorTxt.y - collectorTxt.height - 16;
for (var i = 0; i < resourceTypeList.length; i++) {
// Kaynak rengi: asset id'sinden shape tanımını bul
var assetId = resourceTypeList[i].asset;
var assetColor = 0xffffff;
// Asset tanımlarını yukarıda sabit olarak bildiğimiz için, elle eşleştiriyoruz
if (assetId === "resource_gold") assetColor = 0x5b6733;else if (assetId === "resource_cobalt") assetColor = 0x52459a;else if (assetId === "resource_nickel") assetColor = 0x825648;else if (assetId === "resource_helium3") assetColor = 0xf59af1;else if (assetId === "resource_platinum") assetColor = 0x63dbd1;else if (assetId === "resource_iron") assetColor = 0xe5bf1c;else if (assetId === "resource_manganese") assetColor = 0xbc3379;
var txt = new Text2(resourceTypeList[i].name + ": 0", {
size: 36,
fill: assetColor,
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
txt.anchor.set(0, 1);
txt.x = 0;
txt.y = lastY;
guiLeftBottomGroup.addChild(txt);
resourceStockTxts.push(txt);
lastY = txt.y - txt.height; // Satır arası boşluğu kaldırıldı
}
// Gemi sayısı göstergesi (sol alt) -- KALDIRILDI, sadece yükseklik için dummy olarak tanımlanır
var shipCountTxt = new Text2('Savaşçı: 1', {
size: 36,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
shipCountTxt.anchor.set(0, 1);
shipCountTxt.x = 0;
shipCountTxt.y = -colonyHpTxt.height - resourceTxt.height - collectorTxt.height - 24;
// Eğer başka yazı veya butonlar eklenirse, aynı şekilde guiLeftBottomGroup'a eklenmeli ve
// y koordinatları bir önceki elemanın yüksekliği ve aradaki boşluk ile ayarlanmalı.
// Tüm yazılar ve butonlar bu grupta, sol alt köşeye hizalı ve font boyutu 36 olacak şekilde ayarlanmıştır.
// Gemi kur
ship = new Ship();
ship.x = 2048 / 2;
ship.y = 2732 - 700;
ship.hp = 6;
ship.maxHp = 6;
game.addChild(ship);
// Gemi can barı: geminin üstünde gösterilecek
var shipHpBarBg = LK.getAsset('collector', {
width: 90,
height: 16,
color: 0x222222,
anchorX: 0.5,
anchorY: 0.5
});
var shipHpBar = LK.getAsset('collector', {
width: 86,
height: 8,
color: 0xE64A3A,
anchorX: 0.5,
anchorY: 0.5
});
shipHpBarBg.y = ship.y - 50;
shipHpBarBg.x = ship.x;
shipHpBar.y = ship.y - 50;
shipHpBar.x = ship.x;
game.addChild(shipHpBarBg);
game.addChild(shipHpBar);
// Asteroit Avcısı'nın aktif olacağı oran (ör: 0.5 = alt %50'lik kısımda avlanır, ileride artırılabilir)
var hunterActiveRatio = 0.5; // Alt %50'lik kısımda aktif
// Asteroit Avcılarını oluştur
function createCollectors(n) {
for (var i = collectors.length; i < n; i++) {
var c = new AsteroidHunter();
c.x = colony.x + 100 * (i - n / 2);
c.y = colony.y + 100;
collectors.push(c);
game.addChild(c);
}
}
createCollectors(autoCollectors);
// Kaynak Avcılarını oluştur
function createResourceHunters(n) {
for (var i = resourceHunters.length; i < n; i++) {
var h = new ResourceHunter();
h.x = colony.x + 100 * (i - n / 2);
h.y = colony.y + 200;
resourceHunters.push(h);
game.addChild(h);
}
}
createResourceHunters(autoResourceHunters);
// Asteroidleri oluştur (kaynaklar asteroid yok edilince çıkacak)
// Artık asteroidler haritaya yavaşça girip rastgele ilerleyecek, sayıları 2-6 arası olacak
var asteroidNodes = [];
function spawnAsteroids() {
// Haritada 2-6 asteroid olacak şekilde ayarla
var minAsteroids = 2;
var maxAsteroids = 6;
// Mevcut asteroid sayısını kontrol et
var currentAsteroids = 0;
for (var i = 0; i < asteroidNodes.length; i++) {
if (!asteroidNodes[i].collected) currentAsteroids++;
}
var toSpawn = Math.max(minAsteroids - currentAsteroids, 0);
toSpawn = Math.min(maxAsteroids - currentAsteroids, toSpawn + Math.floor(Math.random() * (maxAsteroids - minAsteroids + 1)));
for (var i = 0; i < toSpawn; i++) {
var a = new AsteroidNode();
asteroidNodes.push(a);
game.addChild(a);
}
}
// Başlangıçta asteroidleri oluştur
spawnAsteroids();
// Gemiye dokunma ve sürükleme
game.down = function (x, y, obj) {
// Gemiye dokunulduysa sürükle
var local = game.toLocal({
x: x,
y: y
});
var dx = local.x - ship.x;
var dy = local.y - ship.y;
if (dx * dx + dy * dy < 120 * 120) {
dragNode = ship;
lastTouch.x = local.x;
lastTouch.y = local.y;
} else {
// Hedefe git
ship.targetX = local.x;
ship.targetY = local.y;
}
};
game.move = function (x, y, obj) {
if (dragNode === ship) {
var local = game.toLocal({
x: x,
y: y
});
ship.targetX = local.x;
ship.targetY = local.y;
lastTouch.x = local.x;
lastTouch.y = local.y;
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Kaynak toplama otomasyonu
function assignCollectors() {
for (var i = 0; i < collectors.length; i++) {
var c = collectors[i];
// Eğer collector bir asteroidi takip ediyorsa ve asteroid haritadan çıkmadıysa veya yok olmadıysa veya kaynak almadıysa, takip etmeye devam etsin
if (c.state === 'moving' && c.target && typeof c.target.hp === "number" &&
// AsteroidNode ise
!c.target.collected && c.target.visible && (!c.target.resourceSpawned || _typeof3(c.target.resourceNode) === "object" && c.target.resourceNode && !c.target.resourceNode.collected)) {
// Asteroid yok edilmedi ve kaynak alınmadı, takip etmeye devam et
continue;
}
// Sadece idle durumundakiler için yeni hedef ata
if (c.state === 'idle') {
// --- Tüm haritadaki asteroidlere saldır, öncelik koloniye en yakın olan ---
// Asteroit Avcısı haritanın üst yarısına müdahale etmesin (oran ile)
var hunterActiveY = 2732 * hunterActiveRatio;
var minDistAst = 99999;
var targetAst = null;
for (var j = 0; j < asteroidNodes.length; j++) {
var a = asteroidNodes[j];
if (!a.collected && a.visible && typeof a.x === "number" && typeof a.y === "number") {
// Asteroit Avcısı sadece hunterActiveY'den aşağıdaki asteroidlere saldırır
if (a.y < hunterActiveY) continue;
// Koloniye olan mesafeyi hesapla
var dxCol = a.x - colony.x;
var dyCol = a.y - colony.y;
var distCol = Math.sqrt(dxCol * dxCol + dyCol * dyCol);
// Her durumda, en yakın asteroidi bul
var dx = a.x - c.x;
var dy = a.y - c.y;
var dist = dx * dx + dy * dy;
// Öncelik: koloniye en yakın asteroid
if (distCol < minDistAst) {
minDistAst = distCol;
targetAst = a;
}
}
}
if (targetAst) {
c.target = targetAst;
c.state = 'moving';
continue;
}
// Asteroit Avcıları kaynak toplamaz, sadece asteroit yok ederler
}
}
}
// Gemi ateş etme
function shipShoot() {
if (LK.ticks - ship.lastShot > ship.shootDelay) {
var b = new Bullet();
b.x = ship.x;
b.y = ship.y - 60;
// En yakın düşmanı bul
var nearestEnemy = null;
var minDist = 999999;
for (var i = 0; i < enemies.length; i++) {
var dx = enemies[i].x - ship.x;
var dy = enemies[i].y - ship.y;
var dist = dx * dx + dy * dy;
if (dist < minDist) {
minDist = dist;
nearestEnemy = enemies[i];
}
}
if (nearestEnemy) {
// Merminin hedefini kaydet
b.targetEnemy = nearestEnemy;
var tx = nearestEnemy.x - ship.x;
var ty = nearestEnemy.y - ship.y;
var tdist = Math.sqrt(tx * tx + ty * ty);
if (tdist > 0) {
b.dirX = tx / tdist;
b.dirY = ty / tdist;
} else {
b.dirX = 0;
b.dirY = -1;
}
} else {
b.dirX = 0;
b.dirY = -1;
}
b.from = 'player';
bullets.push(b);
game.addChild(b);
ship.lastShot = LK.ticks;
}
}
// Oyun güncelleme döngüsü
game.update = function () {
// Kaynak göstergesini güncelle
var totalResourceStock = 0;
for (var i = 0; i < resourceTypeList.length; i++) {
totalResourceStock += resourceStocks[resourceTypeList[i].name];
}
resourceTxt.setText('Toplam Kaynak: ' + totalResourceStock);
collectorTxt.setText('Asteroit Avcısı: ' + autoCollectors);
// Her kaynak türünden stokta olan miktarı göster
for (var i = 0; i < resourceTypeList.length; i++) {
var typeName = resourceTypeList[i].name;
// resourceStocks[typeName] zaten Collector tarafından güncelleniyor, burada tekrar sıfırlama veya toplama yapma!
// Sadece GUI güncellemesi için değerler kullanılacak.
}
// Her kaynak için GUI yazısını güncelle
for (var i = 0; i < resourceTypeList.length; i++) {
var typeName = resourceTypeList[i].name;
resourceStockTxts[i].setText(typeName + ": " + resourceStocks[typeName]);
}
// Gemi sayısı güncelle (şu an 1, ileride dinamik yapılabilir)
shipCountTxt.setText('Savaşçı: 1');
shipCountTxtRight.setText('Savaşçı: 1');
// Gemi canı güncelle -- KALDIRILDI
// --- Sağ alt panel butonlarının aktif/pasif durumunu güncelle ---
// Gemi satın alma paneli butonu
if (typeof shipBuyBtn !== "undefined") {
if (resources >= shipBuyPrice && (!ship.visible || ship.hp <= 0)) {
shipBuyBtn.alpha = 1;
} else {
shipBuyBtn.alpha = 0.5;
}
}
// Asteroit Avcısı satın alma butonu
if (typeof collectorBuyBtn !== "undefined") {
if (resources >= collectorBuyPrice) {
collectorBuyBtn.alpha = 1;
} else {
collectorBuyBtn.alpha = 0.5;
}
}
// Kaynak Avcısı satın alma butonu aktiflik
if (typeof resourceHunterBuyBtn !== "undefined") {
if (resources >= resourceHunterBuyPrice) {
resourceHunterBuyBtn.alpha = 1;
} else {
resourceHunterBuyBtn.alpha = 0.5;
}
}
if (typeof shipUpgradeBtn !== "undefined") {
if (resources >= 30 && typeof ship.hp === "number" && typeof ship.maxHp === "number" && ship.visible) {
shipUpgradeBtn.alpha = 1;
} else {
shipUpgradeBtn.alpha = 0.5;
}
}
if (typeof shipRespawnBtn !== "undefined") {
if (resources >= 60 && (!ship.visible || ship.hp <= 0)) {
shipRespawnBtn.alpha = 1;
} else {
shipRespawnBtn.alpha = 0.5;
}
}
// Koloni can barı ve can yazısı güncelle
if (colony.hp < 0) colony.hp = 0;
if (colony.hp > colony.maxHp) colony.hp = colony.maxHp;
colonyHpBar.width = 216 * (colony.hp / colony.maxHp);
colonyHpBar.x = colony.x;
colonyHpBar.y = colony.y - 160;
colonyHpBarBg.x = colony.x;
colonyHpBarBg.y = colony.y - 160;
colonyHpTxt.setText(Math.round(colony.hp) + ' / ' + colony.maxHp);
colonyHpTxt.x = colony.x;
colonyHpTxt.y = colony.y - 160;
colonyHpTxtRight.setText(Math.round(colony.hp) + ' / ' + colony.maxHp);
// Sağ alt collector güncelle
collectorTxtRight.setText('Asteroit Avcısı: ' + autoCollectors);
// Sağ alt Kaynak Avcısı güncelle
if (typeof resourceHunterBuyBtn !== "undefined") {
if (!game.resourceHunterTxtRight) {
var txt = new Text2('Kaynak Avcısı: ' + autoResourceHunters, {
size: 36,
fill: "#fff",
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowDistance: 2,
dropShadowAngle: Math.PI / 4,
dropShadowBlur: 4,
dropShadowAlpha: 0.7
});
txt.anchor.set(1, 1);
txt.x = 0;
txt.y = -colonyHpLabelRight.height - colonyHpTxtRight.height - collectorTxtRight.height - shipCountTxtRight.height - 24;
guiRightBottomGroup.addChild(txt);
game.resourceHunterTxtRight = txt;
}
game.resourceHunterTxtRight.setText('Kaynak Avcısı: ' + autoResourceHunters);
}
// Asteroidleri güncelle ve haritada minimum 2, maksimum 6 asteroid olmasını sağla
for (var i = asteroidNodes.length - 1; i >= 0; i--) {
var a = asteroidNodes[i];
if (typeof a.update === "function") a.update();
// Haritadan çıkan veya yok edilen asteroidleri temizle
if (a.collected || !a.visible) {
a.destroy();
asteroidNodes.splice(i, 1);
}
}
// Asteroid sayısı azaldıysa yeni asteroid ekle
spawnAsteroids();
// Kaynakları güncelle (hareket ettir)
for (var i = 0; i < resourceNodes.length; i++) {
if (typeof resourceNodes[i].update === "function") resourceNodes[i].update();
}
// Toplayıcıları görevlendir
assignCollectors();
// Collector güncelle
for (var i = 0; i < collectors.length; i++) {
collectors[i].update();
}
// Kaynak Avcısı güncelle
for (var i = 0; i < resourceHunters.length; i++) {
resourceHunters[i].update();
}
// Gemi güncelle
ship.update();
// Gemi can barı pozisyon ve genişlik güncelle
if (typeof shipHpBar !== "undefined" && typeof shipHpBarBg !== "undefined") {
shipHpBarBg.x = ship.x;
shipHpBarBg.y = ship.y - 50;
shipHpBar.x = ship.x;
shipHpBar.y = ship.y - 50;
var ratio = typeof ship.hp === "number" && typeof ship.maxHp === "number" && ship.maxHp > 0 ? ship.hp / ship.maxHp : 1;
if (ratio < 0) ratio = 0;
if (ratio > 1) ratio = 1;
shipHpBar.width = 86 * ratio;
shipHpBar.visible = ship.visible;
shipHpBarBg.visible = ship.visible;
}
// Gemi rastgele hareket etsin, düşman yok
if (!ship.randomMoveTimer) ship.randomMoveTimer = 0;
ship.randomMoveTimer++;
if (ship.randomMoveTimer > 60) {
// Her 1 saniyede bir yeni hedef belirle
var angle = Math.random() * Math.PI * 2;
var dist = 300 + Math.random() * 350;
ship.targetX = colony.x + Math.cos(angle) * dist;
ship.targetY = colony.y + Math.sin(angle) * dist;
ship.isAttacking = false;
ship.randomMoveTimer = 0;
}
// --- Düşman gemisi üretimi ve güncellemesi ---
enemySpawnTimer++;
if (enemySpawnTimer >= ENEMY_SPAWN_INTERVAL) {
var newEnemy = new EnemyShip();
enemyShips.push(newEnemy);
game.addChild(newEnemy);
enemySpawnTimer = 0;
}
// Düşman gemilerini güncelle
for (var i = enemyShips.length - 1; i >= 0; i--) {
var e = enemyShips[i];
if (typeof e.update === "function") e.update();
// Eğer yok olduysa sil
if (e.hp <= 0 || e.x < -200 || e.x > 2248 || e.y < -200 || e.y > 2932) {
e.destroy();
enemyShips.splice(i, 1);
}
}
// Mermileri güncelle
for (var i = bullets.length - 1; i >= 0; i--) {
var b = bullets[i];
b.update();
// Ekran dışıysa sil
if (b.x < -100 || b.x > 2148 || b.y < -100 || b.y > 2832) {
b.destroy();
bullets.splice(i, 1);
continue;
}
// Çarpışmalar
// Sadece koloni ve gemi ile çarpışma kontrolü (düşman yok)
if (b.from === 'enemy') {
// Koloniye çarpma
if (b.intersects(colony)) {
if (typeof colony.hp !== "number") colony.hp = colony.maxHp || 50;
colony.hp -= typeof b.attackPower === "number" ? b.attackPower : 1;
LK.effects.flashObject(colony, 0xff0000, 400);
b.destroy();
bullets.splice(i, 1);
if (colony.hp <= 0) {
LK.effects.flashScreen(0xff0000, 800);
LK.showGameOver();
return;
}
continue;
}
// Gemiye çarpma
if (b.intersects(ship)) {
LK.effects.flashObject(ship, 0xff0000, 500);
b.destroy();
bullets.splice(i, 1);
if (typeof ship.hp !== "number") ship.hp = ship.maxHp || 6;
ship.hp -= typeof b.attackPower === "number" ? b.attackPower : 1;
if (ship.hp <= 0) {
ship.hp = 0;
LK.effects.flashObject(ship, 0xff0000, 800);
ship.visible = false;
ship.x = -9999;
ship.y = -9999;
}
}
}
}
// Otomasyon yükseltme: 50 kaynak ile yeni toplayıcı
// (Otomatik satın alma kaldırıldı)
// Kazanma koşulu: 200 kaynak
if (resources >= 200) {
LK.showYouWin();
return;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -284,13 +284,79 @@
self.orbitAngle += 0.012; // Yavaşça döner
self.x = topAsteroid.x + Math.cos(self.orbitAngle) * self.orbitRadius;
self.y = topAsteroid.y + Math.sin(self.orbitAngle) * self.orbitRadius;
if (self.orbitTime > self.orbitDuration) {
- self.state = 'attacking';
+ self.state = 'approaching';
// Saldırıya başlarken hedefi koloniye kilitle
self.attackTargetX = colony.x;
self.attackTargetY = colony.y;
}
+ } else if (self.state === 'approaching') {
+ // Koloniye yaklaşana kadar ilerle, ama saldırma
+ var dx = self.attackTargetX - self.x;
+ var dy = self.attackTargetY - self.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ // Koloniye belli bir mesafeye (ör: 350px) kadar yaklaşınca önce bizim askerlerle savaş
+ var engageRadius = 350;
+ if (dist > engageRadius) {
+ if (dist > 0) {
+ self.x += self.speed * dx / dist;
+ self.y += self.speed * dy / dist;
+ }
+ } else {
+ // Koloniye yaklaştı, önce bizim askerlerle savaş
+ self.state = 'engaging';
+ }
+ } else if (self.state === 'engaging') {
+ // Sadece bizim gemilere saldır, koloniye saldırmaz
+ // En yakın oyuncu savaşçısını bul
+ var nearestShip = null;
+ var minDist = 999999;
+ if (ship && ship.visible && typeof ship.x === "number" && typeof ship.y === "number" && ship.hp > 0) {
+ var dxs = ship.x - self.x;
+ var dys = ship.y - self.y;
+ var dists = Math.sqrt(dxs * dxs + dys * dys);
+ if (dists < minDist) {
+ minDist = dists;
+ nearestShip = ship;
+ }
+ }
+ // Eğer yakınsa ona yaklaş ve ateş et
+ if (nearestShip && minDist < 400) {
+ // Yaklaş
+ if (minDist > 40) {
+ self.x += self.speed * (nearestShip.x - self.x) / minDist;
+ self.y += self.speed * (nearestShip.y - self.y) / minDist;
+ }
+ // Ateş etme (her 1 saniyede bir)
+ if (LK.ticks - self.lastShot > self.shootDelay) {
+ var b = new Bullet();
+ b.x = self.x;
+ b.y = self.y + 40;
+ b.dirX = nearestShip.x - self.x;
+ b.dirY = nearestShip.y - self.y;
+ var bdist = Math.sqrt(b.dirX * b.dirX + b.dirY * b.dirY);
+ if (bdist > 0) {
+ b.dirX /= bdist;
+ b.dirY /= bdist;
+ } else {
+ b.dirX = 0;
+ b.dirY = 1;
+ }
+ b.from = 'enemy';
+ b.attackPower = 2;
+ bullets.push(b);
+ game.addChild(b);
+ self.lastShot = LK.ticks;
+ }
+ // Eğer oyuncu gemisi yok olduysa, tekrar koloniye saldırmaya başla
+ if (nearestShip.hp <= 0 || !nearestShip.visible) {
+ self.state = 'attacking';
+ }
+ } else {
+ // Oyuncu gemisi yoksa veya çok uzaktaysa, tekrar koloniye saldır
+ self.state = 'attacking';
+ }
} else if (self.state === 'attacking') {
// Koloniye doğru düz hareket
var dx = self.attackTargetX - self.x;
var dy = self.attackTargetY - self.y;
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Galactic Colony Command" and with the description "Kendi uzay kolonini kur, kaynakları topla, otomasyon sistemleri geliştir ve diğer kolonilerle stratejik savaşlara girerek galaksinin hakimi ol!". No text on banner!
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Uzay İstasyonu" and with the description "Kendi uzay kolonini kur, kaynakları topla, otomasyon sistemleri geliştir ve diğer kolonilerle stratejik savaşlara girerek galaksinin hakimi ol!". No text on banner!, Uzay istasyonu
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Gezegen" and with the description "Kendi uzay kolonini kur, kaynakları topla, otomasyon sistemleri geliştir ve diğer kolonilerle stratejik savaşlara girerek galaksinin hakimi ol!". No text on banner!, Uzay istasyonu, Gezegen
Astreroit cobalt. In-Game asset. 2d. High contrast. No shadows
asteroid gold. In-Game asset. 2d. High contrast. No shadows
asteroid helium. In-Game asset. 2d. High contrast. No shadows
Asteroid Iron - Yazısız. In-Game asset. 2d. High contrast. No shadows
asteroid manganese - yazısız. In-Game asset. 2d. High contrast. No shadows
Asteroid Nikel - Yazısız. In-Game asset. 2d. High contrast. No shadows
Cobalt cevheri. In-Game asset. 2d. High contrast. No shadows
Platinum Cevheri - Yazısız. In-Game asset. 2d. High contrast. No shadows
Ateş - Patlama. In-Game asset. 2d. High contrast. No shadows
Ateş. In-Game asset. 2d. High contrast. No shadows
Maden toplayıcı uzay mekiği, Gerçekçi. In-Game asset. High contrast. No shadows
Uzay savaş gemisi - Gerçekçi - Yazısız. In-Game asset. High contrast. No shadows
Altın Cevheri - Yazısız. In-Game asset. 2d. High contrast. No shadows
Helium cevheri - yazısız. In-Game asset. 2d. High contrast. No shadows
Iron cevheri - yazısız. In-Game asset. 2d. High contrast. No shadows
Manganese cevheri - yazısız. In-Game asset. 2d. High contrast. No shadows
HP BAR - yazısız. In-Game asset. 2d. High contrast. No shadows
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Galactic Colony Command" and with the description "Kendi uzay kolonini kur, kaynakları topla, otomasyon sistemleri geliştir ve diğer kolonilerle stratejik savaşlara girerek galaksinin hakimi ol!". No text on banner!
uzay savaş gemisi. In-Game asset. 2d. High contrast. No shadows
uzay savaş gemisi - gerçekçi - yazısız. In-Game asset. High contrast. No shadows
uzay savaş gemisi - gerçekçi - yazısız. In-Game asset. High contrast. No shadows
Uzay Savunma Kulesi - Yazısız - Gerçekçi. In-Game asset. High contrast. No shadows
Uzay Savunma Kulesi - Yazısız - Gerçekçi. In-Game asset. High contrast. No shadows
Uzay Savunma Kulesi - Yazısız - Gerçekçi. In-Game asset. High contrast. No shadows
Uzay Savunma Kulesi - Yazısız - Gerçekçi. In-Game asset. High contrast. No shadows
Uzay savaş istasyonu - Gerçekçi. In-Game asset. High contrast. No shadows
Uzay savaş istasyonu - Gerçekçi. In-Game asset. High contrast. No shadows
Uzay savaş istasyonu - Gerçekçi. In-Game asset. High contrast. No shadows
Hoparlör. In-Game asset. 2d. High contrast. No shadows