User prompt
Swordsmen should go to the enemies and strike them so that they do not remain motionless.
User prompt
Let the swordsmen go towards the enemy like cavalry and strike
User prompt
The direction of the cavalry should always remain the same, so that they do not reverse.
User prompt
Let the cavalry run towards the enemies and not stand still. Let them strike the enemies without leaving their side.
User prompt
Süvariler düşmanlara doğru koşsun hareketsiz kalmasınlar Düşmanların yanına gidince düşmanlara vursunlar
User prompt
Let the cavalry move
User prompt
Let the cavalry go towards the enemies and attack
User prompt
Levels should be a little harder and characters should move faster.
User prompt
Gold prices of archers, spearmen, swordsmen and cavalrymen should be halved.
User prompt
Kaç goldumuzun olduğunu gösteren yazı sola gelsin.Ayrıca Start battle yazısıda aşağıya gelsin
User prompt
Gold yazısı biraz sola gelsin ayrıca Okçular mızrakçılar süvariler ve kılıç ustaları nın altına kaç gold oldukları yazsın
User prompt
Tüm karakterlerin altında kaç altın oldukları yazsın ayrıca Wave yazısı biraz sağa alınsın Start Battle yazısında biraz aşağıya alınsın
User prompt
Spearmen should be able to throw spears and also add a Janissary with a sword in his hand.
Code edit (1 edits merged)
Please save this source code
User prompt
Janissary March
Initial prompt
Now I want to make a game about the Janissaries in the Ottoman period. These Janissaries join the war together.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Arrow = Container.expand(function () {
var self = Container.call(this);
self.speed = 8;
self.target = null;
self.damage = 30;
var arrowGraphics = self.attachAsset('arrow', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (self.target && self.target.health > 0) {
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 30) {
self.target.takeDamage(self.damage);
self.destroy();
for (var i = arrows.length - 1; i >= 0; i--) {
if (arrows[i] === self) {
arrows.splice(i, 1);
break;
}
}
} else {
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
arrowGraphics.rotation = angle;
}
} else {
self.destroy();
for (var i = arrows.length - 1; i >= 0; i--) {
if (arrows[i] === self) {
arrows.splice(i, 1);
break;
}
}
}
};
return self;
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
self.health = 80;
self.maxHealth = 80;
self.speed = 1;
self.attackPower = 25;
self.attackCooldown = 0;
self.maxAttackCooldown = 90;
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.findNearestJanissary = function () {
var nearest = null;
var nearestDistance = Infinity;
for (var i = 0; i < janissaries.length; i++) {
var jan = janissaries[i];
var dx = jan.x - self.x;
var dy = jan.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < nearestDistance) {
nearest = jan;
nearestDistance = distance;
}
}
return nearest;
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
self.health = 0;
self.destroy();
for (var i = enemies.length - 1; i >= 0; i--) {
if (enemies[i] === self) {
enemies.splice(i, 1);
gold += 10;
goldText.setText('Gold: ' + gold);
break;
}
}
}
};
self.update = function () {
if (self.attackCooldown > 0) {
self.attackCooldown--;
}
var target = self.findNearestJanissary();
if (target) {
var dx = target.x - self.x;
var dy = target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 60) {
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
} else {
if (self.attackCooldown <= 0) {
target.takeDamage(self.attackPower);
self.attackCooldown = self.maxAttackCooldown;
LK.effects.flashObject(target, 0xff0000, 200);
}
}
}
};
return self;
});
var Janissary = Container.expand(function (type) {
var self = Container.call(this);
self.type = type;
self.health = 100;
self.maxHealth = 100;
self.attackPower = type === 'archer' ? 30 : type === 'spearman' ? 40 : type === 'swordsman' ? 45 : 50;
self.range = type === 'archer' ? 400 : type === 'spearman' ? 250 : type === 'swordsman' ? 80 : 80;
self.attackCooldown = 0;
self.maxAttackCooldown = type === 'archer' ? 60 : type === 'spearman' ? 70 : type === 'swordsman' ? 40 : 30;
self.isDragging = false;
self.target = null;
var unitGraphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
var goldDisplayText = new Text2('', {
size: 30,
fill: 0xFFD700
});
goldDisplayText.anchor.set(0.5, 0);
goldDisplayText.x = -20;
goldDisplayText.y = 80;
self.addChild(goldDisplayText);
self.updateGoldDisplay = function () {
var goldCost = type === 'archer' ? 30 : type === 'spearman' ? 40 : type === 'swordsman' ? 50 : 60;
goldDisplayText.setText(goldCost + ' gold');
};
self.updateGoldDisplay();
self.findNearestEnemy = function () {
var nearest = null;
var nearestDistance = Infinity;
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
var dx = enemy.x - self.x;
var dy = enemy.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= self.range && distance < nearestDistance) {
nearest = enemy;
nearestDistance = distance;
}
}
return nearest;
};
self.attack = function (target) {
if (self.attackCooldown <= 0) {
if (self.type === 'archer') {
var arrow = new Arrow();
arrow.x = self.x;
arrow.y = self.y;
arrow.target = target;
arrow.damage = self.attackPower;
arrows.push(arrow);
game.addChild(arrow);
LK.getSound('bowRelease').play();
} else if (self.type === 'spearman') {
var spear = new Spear();
spear.x = self.x;
spear.y = self.y;
spear.target = target;
spear.damage = self.attackPower;
spears.push(spear);
game.addChild(spear);
LK.getSound('spearThrow').play();
} else {
target.takeDamage(self.attackPower);
LK.getSound('swordClash').play();
LK.effects.flashObject(target, 0xff0000, 200);
}
self.attackCooldown = self.maxAttackCooldown;
}
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
self.health = 0;
self.destroy();
for (var i = janissaries.length - 1; i >= 0; i--) {
if (janissaries[i] === self) {
janissaries.splice(i, 1);
break;
}
}
}
};
self.update = function () {
if (self.attackCooldown > 0) {
self.attackCooldown--;
}
if (!self.isDragging) {
self.target = self.findNearestEnemy();
if (self.target) {
self.attack(self.target);
}
}
};
self.down = function (x, y, obj) {
if (deploymentPhase) {
self.isDragging = true;
draggedUnit = self;
}
};
return self;
});
var Spear = Container.expand(function () {
var self = Container.call(this);
self.speed = 6;
self.target = null;
self.damage = 40;
var spearGraphics = self.attachAsset('spear', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (self.target && self.target.health > 0) {
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 30) {
self.target.takeDamage(self.damage);
self.destroy();
for (var i = spears.length - 1; i >= 0; i--) {
if (spears[i] === self) {
spears.splice(i, 1);
break;
}
}
} else {
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
spearGraphics.rotation = angle;
}
} else {
self.destroy();
for (var i = spears.length - 1; i >= 0; i--) {
if (spears[i] === self) {
spears.splice(i, 1);
break;
}
}
}
};
return self;
});
var UnitButton = Container.expand(function (unitType, cost) {
var self = Container.call(this);
self.unitType = unitType;
self.cost = cost;
var buttonGraphics = self.attachAsset(unitType, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
self.down = function (x, y, obj) {
if (deploymentPhase && gold >= self.cost) {
var newUnit = new Janissary(self.unitType);
newUnit.x = x;
newUnit.y = y;
newUnit.isDragging = true;
draggedUnit = newUnit;
janissaries.push(newUnit);
game.addChild(newUnit);
gold -= self.cost;
goldText.setText('Gold: ' + gold);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2F4F2F
});
/****
* Game Code
****/
var battlefield = game.addChild(LK.getAsset('battlefield', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 300
}));
var deployPanel = game.addChild(LK.getAsset('deployPanel', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
var janissaries = [];
var enemies = [];
var arrows = [];
var spears = [];
var currentWave = 1;
var maxWaves = 5;
var waveTimer = 0;
var deploymentPhase = true;
var draggedUnit = null;
var gold = 100;
var waveText = new Text2('Wave: 1', {
size: 80,
fill: 0xFFFFFF
});
waveText.anchor.set(0.5, 0);
LK.gui.top.addChild(waveText);
waveText.x = 200;
waveText.y = 50;
var goldText = new Text2('Gold: 100', {
size: 60,
fill: 0xFFFF00
});
goldText.anchor.set(0, 0);
LK.gui.topRight.addChild(goldText);
goldText.x = -200;
goldText.y = 20;
var phaseText = new Text2('Deployment Phase - Position Your Units!', {
size: 70,
fill: 0x00FF00
});
phaseText.anchor.set(0.5, 0);
LK.gui.center.addChild(phaseText);
phaseText.y = -200;
var archerButton = new UnitButton('archer', 30);
archerButton.x = 300;
archerButton.y = 150;
game.addChild(archerButton);
var archerGoldText = new Text2('30 gold', {
size: 30,
fill: 0xFFD700
});
archerGoldText.anchor.set(0.5, 0);
archerGoldText.x = 300;
archerGoldText.y = 220;
game.addChild(archerGoldText);
var spearmanButton = new UnitButton('spearman', 40);
spearmanButton.x = 500;
spearmanButton.y = 150;
game.addChild(spearmanButton);
var spearmanGoldText = new Text2('40 gold', {
size: 30,
fill: 0xFFD700
});
spearmanGoldText.anchor.set(0.5, 0);
spearmanGoldText.x = 500;
spearmanGoldText.y = 220;
game.addChild(spearmanGoldText);
var cavalryButton = new UnitButton('cavalry', 60);
cavalryButton.x = 700;
cavalryButton.y = 150;
game.addChild(cavalryButton);
var cavalryGoldText = new Text2('60 gold', {
size: 30,
fill: 0xFFD700
});
cavalryGoldText.anchor.set(0.5, 0);
cavalryGoldText.x = 700;
cavalryGoldText.y = 220;
game.addChild(cavalryGoldText);
var swordsmanButton = new UnitButton('swordsman', 50);
swordsmanButton.x = 900;
swordsmanButton.y = 150;
game.addChild(swordsmanButton);
var swordsmanGoldText = new Text2('50 gold', {
size: 30,
fill: 0xFFD700
});
swordsmanGoldText.anchor.set(0.5, 0);
swordsmanGoldText.x = 900;
swordsmanGoldText.y = 220;
game.addChild(swordsmanGoldText);
var startBattleText = new Text2('Start Battle', {
size: 60,
fill: 0xFF0000
});
startBattleText.anchor.set(0.5, 0.5);
startBattleText.x = 1500;
startBattleText.y = 200;
game.addChild(startBattleText);
startBattleText.down = function (x, y, obj) {
if (deploymentPhase && janissaries.length > 0) {
deploymentPhase = false;
phaseText.setText('Wave ' + currentWave + ' - Defend!');
phaseText.tint = 0xff0000;
startBattleText.visible = false;
archerButton.visible = false;
spearmanButton.visible = false;
cavalryButton.visible = false;
swordsmanButton.visible = false;
archerGoldText.visible = false;
spearmanGoldText.visible = false;
cavalryGoldText.visible = false;
swordsmanGoldText.visible = false;
spawnWave();
}
};
function spawnWave() {
var enemyCount = currentWave * 3 + 2;
for (var i = 0; i < enemyCount; i++) {
var enemy = new Enemy();
var side = Math.floor(Math.random() * 4);
if (side === 0) {
enemy.x = Math.random() * 2048;
enemy.y = 300;
} else if (side === 1) {
enemy.x = 2048;
enemy.y = 300 + Math.random() * 1800;
} else if (side === 2) {
enemy.x = Math.random() * 2048;
enemy.y = 2100;
} else {
enemy.x = 0;
enemy.y = 300 + Math.random() * 1800;
}
enemies.push(enemy);
game.addChild(enemy);
}
}
function checkWaveComplete() {
if (enemies.length === 0 && !deploymentPhase) {
currentWave++;
if (currentWave > maxWaves) {
LK.showYouWin();
} else {
deploymentPhase = true;
phaseText.setText('Wave ' + currentWave + ' Preparation');
phaseText.tint = 0x00ff00;
waveText.setText('Wave: ' + currentWave);
startBattleText.visible = true;
archerButton.visible = true;
spearmanButton.visible = true;
cavalryButton.visible = true;
swordsmanButton.visible = true;
archerGoldText.visible = true;
spearmanGoldText.visible = true;
cavalryGoldText.visible = true;
swordsmanGoldText.visible = true;
gold += 50;
goldText.setText('Gold: ' + gold);
}
}
}
function checkGameOver() {
if (janissaries.length === 0 && !deploymentPhase) {
LK.showGameOver();
}
}
game.move = function (x, y, obj) {
if (draggedUnit && deploymentPhase) {
if (y > 300) {
draggedUnit.x = x;
draggedUnit.y = y;
}
}
};
game.up = function (x, y, obj) {
if (draggedUnit) {
draggedUnit.isDragging = false;
draggedUnit = null;
}
};
game.update = function () {
for (var i = janissaries.length - 1; i >= 0; i--) {
if (janissaries[i].health <= 0) {
janissaries[i].destroy();
janissaries.splice(i, 1);
}
}
for (var i = enemies.length - 1; i >= 0; i--) {
if (enemies[i].health <= 0) {
enemies[i].destroy();
enemies.splice(i, 1);
}
}
for (var i = arrows.length - 1; i >= 0; i--) {
if (!arrows[i].target || arrows[i].target.health <= 0) {
arrows[i].destroy();
arrows.splice(i, 1);
}
}
for (var i = spears.length - 1; i >= 0; i--) {
if (!spears[i].target || spears[i].target.health <= 0) {
spears[i].destroy();
spears.splice(i, 1);
}
}
checkWaveComplete();
checkGameOver();
}; ===================================================================
--- original.js
+++ change.js
@@ -132,8 +132,9 @@
size: 30,
fill: 0xFFD700
});
goldDisplayText.anchor.set(0.5, 0);
+ goldDisplayText.x = -20;
goldDisplayText.y = 80;
self.addChild(goldDisplayText);
self.updateGoldDisplay = function () {
var goldCost = type === 'archer' ? 30 : type === 'spearman' ? 40 : type === 'swordsman' ? 50 : 60;
@@ -340,20 +341,52 @@
var archerButton = new UnitButton('archer', 30);
archerButton.x = 300;
archerButton.y = 150;
game.addChild(archerButton);
+var archerGoldText = new Text2('30 gold', {
+ size: 30,
+ fill: 0xFFD700
+});
+archerGoldText.anchor.set(0.5, 0);
+archerGoldText.x = 300;
+archerGoldText.y = 220;
+game.addChild(archerGoldText);
var spearmanButton = new UnitButton('spearman', 40);
spearmanButton.x = 500;
spearmanButton.y = 150;
game.addChild(spearmanButton);
+var spearmanGoldText = new Text2('40 gold', {
+ size: 30,
+ fill: 0xFFD700
+});
+spearmanGoldText.anchor.set(0.5, 0);
+spearmanGoldText.x = 500;
+spearmanGoldText.y = 220;
+game.addChild(spearmanGoldText);
var cavalryButton = new UnitButton('cavalry', 60);
cavalryButton.x = 700;
cavalryButton.y = 150;
game.addChild(cavalryButton);
+var cavalryGoldText = new Text2('60 gold', {
+ size: 30,
+ fill: 0xFFD700
+});
+cavalryGoldText.anchor.set(0.5, 0);
+cavalryGoldText.x = 700;
+cavalryGoldText.y = 220;
+game.addChild(cavalryGoldText);
var swordsmanButton = new UnitButton('swordsman', 50);
swordsmanButton.x = 900;
swordsmanButton.y = 150;
game.addChild(swordsmanButton);
+var swordsmanGoldText = new Text2('50 gold', {
+ size: 30,
+ fill: 0xFFD700
+});
+swordsmanGoldText.anchor.set(0.5, 0);
+swordsmanGoldText.x = 900;
+swordsmanGoldText.y = 220;
+game.addChild(swordsmanGoldText);
var startBattleText = new Text2('Start Battle', {
size: 60,
fill: 0xFF0000
});
@@ -370,8 +403,12 @@
archerButton.visible = false;
spearmanButton.visible = false;
cavalryButton.visible = false;
swordsmanButton.visible = false;
+ archerGoldText.visible = false;
+ spearmanGoldText.visible = false;
+ cavalryGoldText.visible = false;
+ swordsmanGoldText.visible = false;
spawnWave();
}
};
function spawnWave() {
@@ -410,8 +447,12 @@
archerButton.visible = true;
spearmanButton.visible = true;
cavalryButton.visible = true;
swordsmanButton.visible = true;
+ archerGoldText.visible = true;
+ spearmanGoldText.visible = true;
+ cavalryGoldText.visible = true;
+ swordsmanGoldText.visible = true;
gold += 50;
goldText.setText('Gold: ' + gold);
}
}
animasyon Çizgi dizi tarzında bir Osmanlı okçusu. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında bir At üstünde bir Osmanlı süvarisi. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında bir Osmanlı mızrakçısı. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında Beyaz bir ok. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında bir toprak ama ne ağaç var nede çimen sadece dümdüz kahverengi toprak açık kahverengi olsun toprak. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında bir bizans askeri. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında elinde kılıç olan bir osmanlı yeniçerisi. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında kalkanlı osmanlı askeri.Kalkanları büyük olsun In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında osmanlı topçusu ekle bu askerin yanında savaş topuda olsun. In-Game asset. 2d. High contrast. No shadows
animasyon çizgi dizi tarzında siyah top. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında bizans okçusu. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında bizans topçusu. In-Game asset. 2d. High contrast. No shadows
Mızrak. In-Game asset. 2d. High contrast. No shadows
animasyon çizgi dizi tarzında bir siper. In-Game asset. 2d. High contrast. No shadows
mor bir arrow. In-Game asset. 2d. High contrast. No shadows
at üstünde okçu. In-Game asset. 2d. High contrast. No shadows
Animasyon çizgi dizi tarzında yeniçeri. In-Game asset. 2d. High contrast. No shadows
animasyo çizgi dizi gibi bir osmanlı yeniçerisi ama güçlü. In-Game asset. 2d. High contrast. No shadows