User prompt
Kuleler bu alanın üstünde olsun
User prompt
Dairenin İçi boş olsun
User prompt
Kuleler gözüksün
User prompt
İçi boş olsun
User prompt
İçi boş olsun ve her zaman gözüksün
User prompt
Kare değil daire olsun ve tqm kulenin ortasında ve 2 kat daha büyük olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kulenin hasar verdiği alanları daire içine al
User prompt
Kuleler yakındaki düşmanlara 0.2 saniyede bir 2 hasar versin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Tüm karekterler birbirine hasar vere bilsin
User prompt
Karakterler birbirine hasar verebilsin
User prompt
İşçilerin hızını 2 kat hızlandır
User prompt
Coins yazısını golds olarak değiştir
User prompt
Düşman takımdaki ve bizim takımdaki Savaşçılar,okçular,büyücüler ve dragon lar birbirine hasar verebilsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Okçular 20 hasar büyücüler 30 hasar dragon 40 hasar versin
User prompt
Kulelerin sağlığı 300 olsun
User prompt
İşçi dışında ki karakterler birbiriyle savaşa ilginç ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Her işçi farklı bir yere gitsin
User prompt
Bir takımdaki işçilerin hepsi farklı bir coin i toplamaya çalışsın
User prompt
Wizzard shoot magic ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Okçular uzaktan da ok alabilsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Her takıma başlangıçta 15 coin verilsin
User prompt
Archer shoots arrow ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Okçular "arrow" ateşkesin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Okçu ok atsın büyücü büyü atsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kuleler kendine yaklaşan düşman karakterlerine 3 saniyede bir 10 hasar versin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Arrow = Container.expand(function (team, startX, startY, targetX, targetY, damage) {
var self = Container.call(this);
var graphics = self.attachAsset('Arrow', {
anchorX: 0.5,
anchorY: 0.5
});
self.team = team;
self.damage = damage;
self.speed = 8;
self.target = null;
// Calculate direction
var dx = targetX - startX;
var dy = targetY - startY;
var distance = Math.sqrt(dx * dx + dy * dy);
self.directionX = dx / distance;
self.directionY = dy / distance;
// Set rotation to point toward target
self.rotation = Math.atan2(dy, dx);
// Position arrow at start
self.x = startX;
self.y = startY;
self.update = function () {
// Move arrow
self.x += self.directionX * self.speed;
self.y += self.directionY * self.speed;
// Check if arrow is off screen
if (self.x < -100 || self.x > 2148 || self.y < -100 || self.y > 2832) {
self.destroy();
// Remove from arrows array
for (var i = arrows.length - 1; i >= 0; i--) {
if (arrows[i] === self) {
arrows.splice(i, 1);
break;
}
}
}
// Check collision with enemy units
var enemyUnits = self.team === 'player' ? aiUnits : playerUnits;
for (var i = 0; i < enemyUnits.length; i++) {
var enemy = enemyUnits[i];
if (self.intersects(enemy)) {
enemy.health -= self.damage;
if (enemy.health <= 0) {
enemyUnits.splice(i, 1);
enemy.destroy();
}
self.destroy();
// Remove from arrows array
for (var j = arrows.length - 1; j >= 0; j--) {
if (arrows[j] === self) {
arrows.splice(j, 1);
break;
}
}
return;
}
}
// Check collision with enemy towers
var enemyTowers = self.team === 'player' ? aiTowers : playerTowers;
for (var i = 0; i < enemyTowers.length; i++) {
var tower = enemyTowers[i];
if (self.intersects(tower)) {
tower.health -= self.damage;
if (tower.health <= 0) {
enemyTowers.splice(i, 1);
tower.destroy();
LK.getSound('towerDestroyed').play();
}
self.destroy();
// Remove from arrows array
for (var j = arrows.length - 1; j >= 0; j--) {
if (arrows[j] === self) {
arrows.splice(j, 1);
break;
}
}
return;
}
}
};
return self;
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.value = 1;
self.collected = false;
return self;
});
var CombatUnit = Container.expand(function (team, unitType) {
var self = Container.call(this);
var assetName = team === 'player' ? unitType : 'ai' + unitType.charAt(0).toUpperCase() + unitType.slice(1);
var graphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.team = team;
self.unitType = unitType;
self.speed = unitType === 'dragon' ? 3 : unitType === 'wizard' ? 1.5 : unitType === 'archer' ? 2.5 : 2;
self.damage = unitType === 'dragon' ? 40 : unitType === 'wizard' ? 30 : unitType === 'archer' ? 20 : 10;
self.health = unitType === 'dragon' ? 50 : unitType === 'wizard' ? 40 : unitType === 'archer' ? 30 : unitType === 'warrior' ? 20 : 10;
self.maxHealth = self.health;
self.attackRange = unitType === 'wizard' ? 100 : unitType === 'archer' ? 200 : 50;
self.attackCooldown = 0;
self.target = null;
// Create health bar background (black)
self.healthBarBg = LK.getAsset('blackBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 0.75
});
self.healthBarBg.x = 0;
self.healthBarBg.y = -120;
self.healthBarBg.tint = 0x000000;
self.addChild(self.healthBarBg);
// Create health bar (green for player, red for AI)
self.healthBar = LK.getAsset('blackBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 0.75
});
self.healthBar.x = 0;
self.healthBar.y = -120;
self.healthBar.tint = team === 'player' ? 0x00ff00 : 0xff0000;
self.addChild(self.healthBar);
self.healthText = new Text2(self.health.toString(), {
size: 50,
fill: '#ffffff'
});
self.healthText.anchor.set(0.5, 0.5);
self.addChild(self.healthText);
self.healthText.x = 0;
self.healthText.y = -120;
self.update = function () {
if (self.attackCooldown > 0) {
self.attackCooldown--;
}
if (!self.target) {
self.findNearestEnemyTower();
} else {
self.moveToTarget();
}
self.healthText.setText(self.health.toString());
// Update health bar scale based on health percentage
var healthPercentage = self.health / self.maxHealth;
tween(self.healthBar, {
scaleX: 1.5 * healthPercentage
}, {
duration: 200
});
};
self.findNearestEnemyTower = function () {
// First try to find nearby enemy units to attack
var enemyUnits = self.team === 'player' ? aiUnits : playerUnits;
var nearestEnemy = null;
var nearestDistance = Infinity;
var unitSearchRange = 300; // Range to look for enemy units
for (var i = 0; i < enemyUnits.length; i++) {
var enemy = enemyUnits[i];
// Skip workers - we don't want to attack them
if (enemy.unitType === 'worker') {
continue;
}
// Only combat units (warriors, archers, wizards, dragons) can attack other combat units
if (self.unitType !== 'worker' && enemy.unitType !== 'worker') {
var distance = Math.sqrt(Math.pow(enemy.x - self.x, 2) + Math.pow(enemy.y - self.y, 2));
if (distance < nearestDistance && distance <= unitSearchRange) {
nearestDistance = distance;
nearestEnemy = enemy;
}
}
}
// If we found an enemy unit, target it
if (nearestEnemy) {
self.target = nearestEnemy;
return;
}
// Otherwise, target towers as fallback
var enemyTowers = self.team === 'player' ? aiTowers : playerTowers;
var nearestTower = null;
nearestDistance = Infinity;
for (var i = 0; i < enemyTowers.length; i++) {
var tower = enemyTowers[i];
var distance = Math.sqrt(Math.pow(tower.x - self.x, 2) + Math.pow(tower.y - self.y, 2));
if (distance < nearestDistance) {
nearestDistance = distance;
nearestTower = tower;
}
}
self.target = nearestTower;
};
self.moveToTarget = function () {
if (!self.target) {
return;
}
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < self.attackRange) {
self.attackTarget();
} else {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
};
self.attackTarget = function () {
if (self.attackCooldown <= 0 && self.target) {
if (self.unitType === 'archer') {
// Archer shoots arrow
var arrow = new Arrow(self.team, self.x, self.y, self.target.x, self.target.y, self.damage);
arrows.push(arrow);
game.addChild(arrow);
} else if (self.unitType === 'wizard') {
// Wizard shoots magic
var magic = new Magic(self.team, self.x, self.y, self.target.x, self.target.y, self.damage);
magics.push(magic);
game.addChild(magic);
} else {
// Melee attack
self.target.health -= self.damage;
if (self.target.health <= 0) {
// Check if target is a unit or tower
if (self.target.unitType) {
// Target is a unit
self.destroyUnit();
} else {
// Target is a tower
self.destroyTower();
}
}
}
self.attackCooldown = 60;
LK.getSound('attack').play();
}
};
self.destroyUnit = function () {
var units = self.team === 'player' ? aiUnits : playerUnits;
var index = units.indexOf(self.target);
if (index > -1) {
units.splice(index, 1);
self.target.destroy();
self.target = null;
}
};
self.destroyTower = function () {
var towers = self.team === 'player' ? aiTowers : playerTowers;
var index = towers.indexOf(self.target);
if (index > -1) {
towers.splice(index, 1);
self.target.destroy();
LK.getSound('towerDestroyed').play();
self.target = null;
}
};
return self;
});
var Magic = Container.expand(function (team, startX, startY, targetX, targetY, damage) {
var self = Container.call(this);
var graphics = self.attachAsset('Magic', {
anchorX: 0.5,
anchorY: 0.5
});
self.team = team;
self.damage = damage;
self.speed = 6;
self.target = null;
// Calculate direction
var dx = targetX - startX;
var dy = targetY - startY;
var distance = Math.sqrt(dx * dx + dy * dy);
self.directionX = dx / distance;
self.directionY = dy / distance;
// Position magic at start
self.x = startX;
self.y = startY;
// Add magical glow effect
tween(graphics, {
tint: 0x9966ff
}, {
duration: 500,
easing: tween.easeInOut
});
tween(graphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.easeOut
});
self.update = function () {
// Move magic
self.x += self.directionX * self.speed;
self.y += self.directionY * self.speed;
// Add sparkle rotation
graphics.rotation += 0.1;
// Check if magic is off screen
if (self.x < -100 || self.x > 2148 || self.y < -100 || self.y > 2832) {
self.destroy();
// Remove from magics array
for (var i = magics.length - 1; i >= 0; i--) {
if (magics[i] === self) {
magics.splice(i, 1);
break;
}
}
}
// Check collision with enemy units
var enemyUnits = self.team === 'player' ? aiUnits : playerUnits;
for (var i = 0; i < enemyUnits.length; i++) {
var enemy = enemyUnits[i];
if (self.intersects(enemy)) {
enemy.health -= self.damage;
if (enemy.health <= 0) {
enemyUnits.splice(i, 1);
enemy.destroy();
}
self.destroy();
// Remove from magics array
for (var j = magics.length - 1; j >= 0; j--) {
if (magics[j] === self) {
magics.splice(j, 1);
break;
}
}
return;
}
}
// Check collision with enemy towers
var enemyTowers = self.team === 'player' ? aiTowers : playerTowers;
for (var i = 0; i < enemyTowers.length; i++) {
var tower = enemyTowers[i];
if (self.intersects(tower)) {
tower.health -= self.damage;
if (tower.health <= 0) {
enemyTowers.splice(i, 1);
tower.destroy();
LK.getSound('towerDestroyed').play();
}
self.destroy();
// Remove from magics array
for (var j = magics.length - 1; j >= 0; j--) {
if (magics[j] === self) {
magics.splice(j, 1);
break;
}
}
return;
}
}
};
return self;
});
var Tower = Container.expand(function (team) {
var self = Container.call(this);
var assetName = team === 'player' ? 'playerTower' : 'aiTower';
var graphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 1.0
});
self.team = team;
self.health = 300;
self.maxHealth = 300;
// Create health bar background (black)
self.healthBarBg = LK.getAsset('blackBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.08,
scaleY: 0.625
});
self.healthBarBg.x = 0;
self.healthBarBg.y = -262.5;
self.healthBarBg.tint = 0x0000ff;
self.addChild(self.healthBarBg);
// Create health bar (blue)
self.healthBar = LK.getAsset('blackBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.08,
scaleY: 0.625
});
self.healthBar.x = 0;
self.healthBar.y = -262.5;
self.healthBar.tint = 0x0000ff;
self.addChild(self.healthBar);
self.healthText = new Text2(self.health.toString(), {
size: 42,
fill: '#ffffff'
});
self.healthText.anchor.set(0.5, 0.5);
self.addChild(self.healthText);
self.healthText.x = 0;
self.healthText.y = -262.5;
self.attackCooldown = 0;
self.attackRange = 150;
// Create permanent damage area outline (hollow circle)
self.damageAreaOutline = LK.getAsset('damageAreaOutline', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: self.attackRange / 50 * 2,
scaleY: self.attackRange / 50 * 2
});
self.damageAreaOutline.x = 0;
self.damageAreaOutline.y = -131.25;
self.damageAreaOutline.tint = self.team === 'player' ? 0x00ff00 : 0xff0000;
self.damageAreaOutline.alpha = 0.1; // Very transparent fill
self.addChild(self.damageAreaOutline);
// Create hollow outline effect by adding a smaller inner circle with background color
self.damageAreaInner = LK.getAsset('damageAreaOutline', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: self.attackRange / 50 * 2 - 0.2,
scaleY: self.attackRange / 50 * 2 - 0.2
});
self.damageAreaInner.x = 0;
self.damageAreaInner.y = -131.25;
self.damageAreaInner.tint = 0x228B22; // Match game background color
self.damageAreaInner.alpha = 1.0; // Fully opaque to create hole effect
self.addChild(self.damageAreaInner);
self.update = function () {
if (self.attackCooldown > 0) {
self.attackCooldown--;
}
self.attackNearbyEnemies();
self.healthText.setText(self.health.toString());
// Update health bar scale based on health percentage
var healthPercentage = self.health / self.maxHealth;
tween(self.healthBar, {
scaleX: 2.08 * healthPercentage
}, {
duration: 200
});
};
self.attackNearbyEnemies = function () {
if (self.attackCooldown <= 0) {
var enemyUnits = self.team === 'player' ? aiUnits : playerUnits;
for (var i = 0; i < enemyUnits.length; i++) {
var enemy = enemyUnits[i];
var dx = enemy.x - self.x;
var dy = enemy.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= self.attackRange) {
enemy.health -= 2; // Deal 2 damage as specified
self.attackCooldown = 12; // 0.2 seconds at 60 FPS
LK.getSound('attack').play();
// Create damage area visualization circle
self.showDamageArea();
if (enemy.health <= 0) {
self.destroyUnit(enemy, enemyUnits, i);
}
break; // Attack only one enemy per cycle
}
}
}
};
self.showDamageArea = function () {
// Create a filled circle for attack effect
var damageCircle = LK.getAsset('damageArea', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: self.attackRange / 50 * 1.5,
scaleY: self.attackRange / 50 * 1.5
});
damageCircle.x = 0;
damageCircle.y = -131.25;
damageCircle.tint = self.team === 'player' ? 0x00ff00 : 0xff0000;
damageCircle.alpha = 0.5;
self.addChild(damageCircle);
// Animate the circle to fade out and remove it
tween(damageCircle, {
alpha: 0,
scaleX: self.attackRange / 50 * 2.2,
scaleY: self.attackRange / 50 * 2.2
}, {
duration: 300,
easing: tween.easeOut,
onComplete: function onComplete() {
damageCircle.destroy();
}
});
};
self.destroyUnit = function (unit, unitsArray, index) {
unitsArray.splice(index, 1);
unit.destroy();
};
return self;
});
var Worker = Container.expand(function (team) {
var self = Container.call(this);
var assetName = team === 'player' ? 'worker' : 'aiWorker';
var graphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.team = team;
self.speed = 4;
self.target = null;
self.collectRange = 40;
self.health = 10;
self.maxHealth = 10;
// Create health bar background (black)
self.healthBarBg = LK.getAsset('blackBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 0.75
});
self.healthBarBg.x = 0;
self.healthBarBg.y = -120;
self.healthBarBg.tint = 0x000000;
self.addChild(self.healthBarBg);
// Create health bar (green for player, red for AI)
self.healthBar = LK.getAsset('blackBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 0.75
});
self.healthBar.x = 0;
self.healthBar.y = -120;
self.healthBar.tint = team === 'player' ? 0x00ff00 : 0xff0000;
self.addChild(self.healthBar);
self.healthText = new Text2(self.health.toString(), {
size: 50,
fill: '#ffffff'
});
self.healthText.anchor.set(0.5, 0.5);
self.addChild(self.healthText);
self.healthText.x = 0;
self.healthText.y = -120;
self.update = function () {
if (!self.target) {
self.findNearestCoin();
} else {
self.moveToTarget();
}
self.healthText.setText(self.health.toString());
// Update health bar scale based on health percentage
var healthPercentage = self.health / self.maxHealth;
tween(self.healthBar, {
scaleX: 1.5 * healthPercentage
}, {
duration: 200
});
};
self.findNearestCoin = function () {
var nearestCoin = null;
var nearestDistance = Infinity;
var targetCoins = self.team === 'player' ? playerCoins_array : aiCoins_array;
var teamWorkers = self.team === 'player' ? playerUnits : aiUnits;
for (var i = 0; i < targetCoins.length; i++) {
var coin = targetCoins[i];
if (!coin.collected) {
// Check if another worker is already targeting this coin
var isTargeted = false;
for (var j = 0; j < teamWorkers.length; j++) {
var worker = teamWorkers[j];
if (worker.unitType === 'worker' && worker !== self && worker.target === coin) {
isTargeted = true;
break;
}
}
if (!isTargeted) {
var distance = Math.sqrt(Math.pow(coin.x - self.x, 2) + Math.pow(coin.y - self.y, 2));
if (distance < nearestDistance) {
nearestDistance = distance;
nearestCoin = coin;
}
}
}
}
self.target = nearestCoin;
};
self.moveToTarget = function () {
if (!self.target || self.target.collected) {
self.target = null;
return;
}
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < self.collectRange) {
self.collectCoin();
} else {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
};
self.collectCoin = function () {
if (self.target && !self.target.collected) {
self.target.collected = true;
if (self.team === 'player') {
playerCoins += self.target.value;
} else {
aiCoins += self.target.value;
}
LK.getSound('coinCollect').play();
self.target = null;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228B22
});
/****
* Game Code
****/
var playerCoins = 15;
var aiCoins = 15;
var playerTowers = [];
var aiTowers = [];
var coins = [];
var playerCoins_array = [];
var aiCoins_array = [];
var playerUnits = [];
var aiUnits = [];
var arrows = [];
var magics = [];
var coinSpawnTimer = 0;
var aiActionTimer = 0;
// UI Elements
var coinDisplay = new Text2('Golds: 0', {
size: 80,
fill: '#ffff00'
});
coinDisplay.anchor.set(0.5, 0.5);
coinDisplay.x = 0;
coinDisplay.y = -273.75;
LK.gui.bottom.addChild(coinDisplay);
var workerButton = new Text2('5', {
size: 32,
fill: '#ffffff'
});
workerButton.anchor.set(0.5, 0.5);
workerButton.x = -400;
workerButton.y = -45;
var warriorButton = new Text2('10', {
size: 32,
fill: '#ffffff'
});
warriorButton.anchor.set(0.5, 0.5);
warriorButton.x = -200;
warriorButton.y = -45;
var wizardButton = new Text2('20', {
size: 32,
fill: '#ffffff'
});
wizardButton.anchor.set(0.5, 0.5);
wizardButton.x = 200;
wizardButton.y = -45;
var archerButton = new Text2('15', {
size: 32,
fill: '#ffffff'
});
archerButton.anchor.set(0.5, 0.5);
archerButton.x = 0;
archerButton.y = -45;
var dragonButton = new Text2('25', {
size: 32,
fill: '#ffffff'
});
dragonButton.anchor.set(0.5, 0.5);
dragonButton.x = 400;
dragonButton.y = -45;
// Add unified black background behind all recruitment buttons and unit images
var unifiedBackground = LK.getAsset('blackBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 22.0,
scaleY: 2.8
});
unifiedBackground.x = 0;
unifiedBackground.y = -78;
unifiedBackground.tint = 0x000000;
unifiedBackground.alpha = 0.5;
LK.gui.bottom.addChild(unifiedBackground);
// Add unit images above recruitment buttons
var workerImage = LK.getAsset('worker', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
workerImage.x = -400;
workerImage.y = -110;
LK.gui.bottom.addChild(workerImage);
var warriorImage = LK.getAsset('warrior', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
warriorImage.x = -200;
warriorImage.y = -110;
LK.gui.bottom.addChild(warriorImage);
var wizardImage = LK.getAsset('wizard', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
wizardImage.x = 200;
wizardImage.y = -110;
LK.gui.bottom.addChild(wizardImage);
var archerImage = LK.getAsset('archer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
archerImage.x = 0;
archerImage.y = -110;
LK.gui.bottom.addChild(archerImage);
var dragonImage = LK.getAsset('dragon', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
dragonImage.x = 400;
dragonImage.y = -110;
LK.gui.bottom.addChild(dragonImage);
// Add texts after backgrounds so they appear on top
LK.gui.bottom.addChild(workerButton);
LK.gui.bottom.addChild(warriorButton);
LK.gui.bottom.addChild(wizardButton);
LK.gui.bottom.addChild(archerButton);
LK.gui.bottom.addChild(dragonButton);
// Initialize towers
function initializeTowers() {
// Player tower
var playerTower = new Tower('player');
playerTower.x = 1024;
playerTower.y = 2200;
playerTowers.push(playerTower);
game.addChild(playerTower);
// AI tower
var aiTower = new Tower('ai');
aiTower.x = 1024;
aiTower.y = 300;
aiTowers.push(aiTower);
game.addChild(aiTower);
}
;
function spawnCoin() {
// Spawn player coin
var playerCoin = new Coin();
playerCoin.x = Math.random() * 1800 + 124;
playerCoin.y = Math.random() * 1000 + 1200; // Lower half for player
playerCoins_array.push(playerCoin);
coins.push(playerCoin);
game.addChild(playerCoin);
// Spawn AI coin
var aiCoin = new Coin();
aiCoin.x = Math.random() * 1800 + 124;
aiCoin.y = Math.random() * 1000 + 400; // Upper half for AI
aiCoins_array.push(aiCoin);
coins.push(aiCoin);
game.addChild(aiCoin);
}
function spawnUnit(team, unitType) {
var unit;
var cost = unitType === 'worker' ? 5 : unitType === 'warrior' ? 10 : unitType === 'wizard' ? 20 : unitType === 'archer' ? 15 : 25;
if (team === 'player' && playerCoins >= cost) {
playerCoins -= cost;
if (unitType === 'worker') {
unit = new Worker('player');
} else {
unit = new CombatUnit('player', unitType);
}
unit.x = playerTowers[0].x + Math.random() * 200 - 100;
unit.y = playerTowers[0].y - 100;
playerUnits.push(unit);
game.addChild(unit);
LK.getSound('unitSpawn').play();
} else if (team === 'ai' && aiCoins >= cost) {
aiCoins -= cost;
if (unitType === 'worker') {
unit = new Worker('ai');
} else {
unit = new CombatUnit('ai', unitType);
}
unit.x = aiTowers[0].x + Math.random() * 200 - 100;
unit.y = aiTowers[0].y + 100;
aiUnits.push(unit);
game.addChild(unit);
}
}
function aiLogic() {
if (aiActionTimer <= 0) {
if (aiCoins >= 25 && Math.random() < 0.1) {
spawnUnit('ai', 'dragon');
} else if (aiCoins >= 15 && Math.random() < 0.15) {
spawnUnit('ai', 'archer');
} else if (aiCoins >= 20 && Math.random() < 0.2) {
spawnUnit('ai', 'wizard');
} else if (aiCoins >= 10 && Math.random() < 0.3) {
spawnUnit('ai', 'warrior');
} else if (aiCoins >= 5 && Math.random() < 0.4) {
spawnUnit('ai', 'worker');
}
aiActionTimer = 120;
}
aiActionTimer--;
}
function checkGameEnd() {
if (playerTowers.length === 0) {
LK.showGameOver();
} else if (aiTowers.length === 0) {
LK.showYouWin();
}
}
function cleanupCollectedCoins() {
// Clean up from main coins array
for (var i = coins.length - 1; i >= 0; i--) {
if (coins[i].collected) {
coins[i].destroy();
coins.splice(i, 1);
}
}
// Clean up from player coins array
for (var i = playerCoins_array.length - 1; i >= 0; i--) {
if (playerCoins_array[i].collected) {
playerCoins_array.splice(i, 1);
}
}
// Clean up from AI coins array
for (var i = aiCoins_array.length - 1; i >= 0; i--) {
if (aiCoins_array[i].collected) {
aiCoins_array.splice(i, 1);
}
}
}
// Button event handlers
workerButton.down = function () {
spawnUnit('player', 'worker');
};
warriorButton.down = function () {
spawnUnit('player', 'warrior');
};
wizardButton.down = function () {
spawnUnit('player', 'wizard');
};
archerButton.down = function () {
spawnUnit('player', 'archer');
};
dragonButton.down = function () {
spawnUnit('player', 'dragon');
};
// Initialize game
initializeTowers();
// Spawn initial workers for both teams
var playerWorker = new Worker('player');
playerWorker.x = playerTowers[0].x + 50;
playerWorker.y = playerTowers[0].y - 100;
playerUnits.push(playerWorker);
game.addChild(playerWorker);
var aiWorker = new Worker('ai');
aiWorker.x = aiTowers[0].x + 50;
aiWorker.y = aiTowers[0].y + 100;
aiUnits.push(aiWorker);
game.addChild(aiWorker);
// Main game loop
game.update = function () {
// Update coin display
coinDisplay.setText('Golds: ' + playerCoins);
// Spawn coins
coinSpawnTimer++;
if (coinSpawnTimer >= 180) {
spawnCoin();
coinSpawnTimer = 0;
}
// AI logic
aiLogic();
// Clean up collected coins
cleanupCollectedCoins();
// Check game end conditions
checkGameEnd();
}; ===================================================================
--- original.js
+++ change.js
@@ -368,11 +368,9 @@
var self = Container.call(this);
var assetName = team === 'player' ? 'playerTower' : 'aiTower';
var graphics = self.attachAsset(assetName, {
anchorX: 0.5,
- anchorY: 1.0,
- scaleX: 1.0,
- scaleY: 1.0
+ anchorY: 1.0
});
self.team = team;
self.health = 300;
self.maxHealth = 300;
@@ -407,9 +405,9 @@
self.healthText.x = 0;
self.healthText.y = -262.5;
self.attackCooldown = 0;
self.attackRange = 150;
- // Create permanent damage area outline
+ // Create permanent damage area outline (hollow circle)
self.damageAreaOutline = LK.getAsset('damageAreaOutline', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: self.attackRange / 50 * 2,
@@ -417,21 +415,21 @@
});
self.damageAreaOutline.x = 0;
self.damageAreaOutline.y = -131.25;
self.damageAreaOutline.tint = self.team === 'player' ? 0x00ff00 : 0xff0000;
- self.damageAreaOutline.alpha = 0.5;
- // Create inner circle to make it hollow
+ self.damageAreaOutline.alpha = 0.1; // Very transparent fill
+ self.addChild(self.damageAreaOutline);
+ // Create hollow outline effect by adding a smaller inner circle with background color
self.damageAreaInner = LK.getAsset('damageAreaOutline', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: self.attackRange / 50 * 2 - 0.2,
scaleY: self.attackRange / 50 * 2 - 0.2
});
self.damageAreaInner.x = 0;
self.damageAreaInner.y = -131.25;
- self.damageAreaInner.tint = 0x228B22; // Same as background color
- self.damageAreaInner.alpha = 1.0;
- self.addChild(self.damageAreaOutline);
+ self.damageAreaInner.tint = 0x228B22; // Match game background color
+ self.damageAreaInner.alpha = 1.0; // Fully opaque to create hole effect
self.addChild(self.damageAreaInner);
self.update = function () {
if (self.attackCooldown > 0) {
self.attackCooldown--;
Worker. In-Game asset. 2d. High contrast. No shadows
Wizard. In-Game asset. 2d. High contrast. No shadows
Dragon. In-Game asset. 2d. High contrast. No shadows
Warrior. In-Game asset. 2d. High contrast. No shadows
etrafı kırmızı işçi. In-Game asset. 2d. High contrast. No shadows
Archer. In-Game asset. 2d. High contrast. No shadows
Magic. In-Game asset. 2d. High contrast. No shadows
Sadece 1 Altın parçacığı. In-Game asset. 2d. High contrast. No shadows
Köşelerdeki taş yerleri kaldır
Çözünürlüğü artır ve kırmızı şeyleri kaldır. In-Game asset. 2d. High contrast. No shadows
Ağzından ateş püskürtsün
Tam yukarıdan bakılan bir kule clash royaledeki gibi. In-Game asset. 2d. High contrast. No shadows
Mavi yerler kırmızı olsun
Sol tarafında kılıçlar olan start buton. In-Game asset. 2d. High contrast. No shadows
How to play button. In-Game asset. 2d. High contrast. No shadows
Tower defence menü background. In-Game asset. 2d. High contrast. No shadows
Towers On Attack yazısı. In-Game asset. 2d. High contrast. No shadows
Zombie. In-Game asset. 2d. High contrast. No shadows
Normal Mode button. In-Game asset. 2d. High contrast. No shadows
Zombie Mode buton. In-Game asset. 2d. High contrast. No shadows