User prompt
Enemy 3 aseti olustur
User prompt
Yeni dusman aseti sadece
User prompt
Heronun elindeki silahı kaldir
User prompt
Elinde silahı kaldır
User prompt
Power uplar %10 ihtimalle çıkma oranı artsın
User prompt
Her 150 puanda bir düşman sayısı %3 artsın
User prompt
Puan sistemi sınırsız olsun 500 de bitmesin
User prompt
Her mor düşman öldüğünde %30 ihtimalle kalkan kazan
User prompt
Kahramanın elinde silah tutsun
User prompt
Düşman lar %30 ihtimalle can versin
User prompt
Kahramana 5 zirh ekle
User prompt
Powerup 3 alirsan bütün düşman lar ölür
User prompt
Bana yeni powerup aseti olustur
User prompt
Bana yeni powerup olustur
User prompt
Her 50 puanda can yenilesin
User prompt
Enemey2 2 zırhı olsun her 20 puanda bir gelsin
User prompt
Yeni düşman aseti ekle
User prompt
Powerup2 %20 ihtimalle 3 lu sıksın
User prompt
Power up2 alirsan 5 zirh kazan
User prompt
Yeni power up asetti oluştur
User prompt
Yeni bir powerup asseti oluştur
User prompt
Power up olarak %20 olarak hızlı sıksın
User prompt
Powerup olarak %40 sansa bağlı olarak can otomatik dolsun
User prompt
Powerup olarak 2li mermi ekle
User prompt
Heronun can bari gözüksün
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemySprite = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = enemySprite.width;
self.height = enemySprite.height;
self.speed = 6 + Math.random() * 3;
self.shootTimer = 60 + Math.floor(Math.random() * 60);
self.hp = 1;
// Update
self.update = function () {
self.y += self.speed;
self.shootTimer--;
if (self.shootTimer <= 0) {
self.shoot();
self.shootTimer = 90 + Math.floor(Math.random() * 60);
}
};
// Shoot
self.shoot = function () {
var bullet = new EnemyBullet();
bullet.x = self.x;
bullet.y = self.y + self.height / 2 + bullet.height / 2;
enemyBullets.push(bullet);
game.addChild(bullet);
};
return self;
});
// Enemy bullet class
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletSprite = self.attachAsset('enemyBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = bulletSprite.width;
self.height = bulletSprite.height;
self.speed = 18;
self.update = function () {
self.y += self.speed;
};
return self;
});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroSprite = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = heroSprite.width;
self.height = heroSprite.height;
self.shootCooldown = 0;
self.poweredUp = false;
self.powerupTimer = 0;
// Shoot method
self.shoot = function () {
if (self.shootCooldown > 0) return;
var bullet = new HeroBullet();
bullet.x = self.x;
bullet.y = self.y - self.height / 2 - bullet.height / 2;
heroBullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
self.shootCooldown = self.poweredUp ? 10 : 20; // Faster shooting if powered up
};
// Powerup method
self.activatePowerup = function () {
self.poweredUp = true;
self.powerupTimer = 300; // 5 seconds at 60fps
tween(self, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
easing: tween.elasticOut
});
};
// Remove powerup
self.deactivatePowerup = function () {
self.poweredUp = false;
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.elasticIn
});
};
// Update
self.update = function () {
if (self.shootCooldown > 0) self.shootCooldown--;
if (self.poweredUp) {
self.powerupTimer--;
if (self.powerupTimer <= 0) {
self.deactivatePowerup();
}
}
};
return self;
});
// Hero bullet class
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletSprite = self.attachAsset('heroBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = bulletSprite.width;
self.height = bulletSprite.height;
self.speed = -28;
self.update = function () {
self.y += self.speed;
};
return self;
});
// Powerup class
var Powerup = Container.expand(function () {
var self = Container.call(this);
var powerupSprite = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = powerupSprite.width;
self.height = powerupSprite.height;
self.speed = 10;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222a36
});
/****
* Game Code
****/
// Music
// Sound effects
// Powerup: green ellipse
// Hero bullet: yellow box
// Enemy bullet: orange box
// Enemy asset: red ellipse
// Hero asset: blue box
// Play music
LK.playMusic('battlefieldMusic');
// Score
var score = 0;
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Hero lives
var heroLives = 5;
var livesTxt = new Text2("♥ x" + heroLives, {
size: 110,
fill: 0xFF4444,
font: "Impact, Arial Black, Tahoma"
});
livesTxt.anchor.set(1, 0);
livesTxt.x = LK.gui.width - 40;
livesTxt.y = 0;
LK.gui.top.addChild(livesTxt);
// Hero instance
var hero = new Hero();
game.addChild(hero);
hero.x = 2048 / 2;
hero.y = 2732 - 350;
// Arrays for game objects
var enemies = [];
var heroBullets = [];
var enemyBullets = [];
var powerups = [];
// Dragging
var dragNode = null;
// Difficulty
var spawnTimer = 0;
var spawnInterval = 60;
var difficultyTimer = 0;
// Powerup spawn
var powerupTimer = 600;
// Move handler
function handleMove(x, y, obj) {
if (dragNode) {
// Clamp hero inside game area, avoid top 100px and bottom 100px
var minX = hero.width / 2;
var maxX = 2048 - hero.width / 2;
var minY = 100 + hero.height / 2;
var maxY = 2732 - hero.height / 2 - 100;
hero.x = Math.max(minX, Math.min(maxX, x));
hero.y = Math.max(minY, Math.min(maxY, y));
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Only start drag if touch is on hero
var dx = x - hero.x;
var dy = y - hero.y;
if (dx * dx + dy * dy < hero.width / 2 * (hero.width / 2)) {
dragNode = hero;
handleMove(x, y, obj);
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Main update loop
game.update = function () {
// Hero update
hero.update();
// Hero auto-shoot
if (LK.ticks % (hero.poweredUp ? 6 : 12) === 0) {
hero.shoot();
}
// Spawn enemies
spawnTimer--;
if (spawnTimer <= 0) {
var enemy = new Enemy();
var margin = 120;
enemy.x = margin + Math.random() * (2048 - 2 * margin);
enemy.y = -enemy.height / 2;
enemies.push(enemy);
game.addChild(enemy);
spawnTimer = spawnInterval;
}
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer % 600 === 0 && spawnInterval > 20) {
spawnInterval -= 5;
}
// Powerup spawn
powerupTimer--;
if (powerupTimer <= 0) {
var powerup = new Powerup();
powerup.x = 200 + Math.random() * (2048 - 400);
powerup.y = -powerup.height / 2;
powerups.push(powerup);
game.addChild(powerup);
powerupTimer = 900 + Math.floor(Math.random() * 600);
}
// Update and cleanup hero bullets
for (var i = heroBullets.length - 1; i >= 0; i--) {
var b = heroBullets[i];
b.update();
if (b.y < -b.height / 2) {
b.destroy();
heroBullets.splice(i, 1);
continue;
}
// Collision with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
var e = enemies[j];
if (b.intersects(e)) {
e.hp--;
if (e.hp <= 0) {
LK.getSound('enemyDown').play();
score += 10;
scoreTxt.setText(score);
e.destroy();
enemies.splice(j, 1);
}
b.destroy();
heroBullets.splice(i, 1);
break;
}
}
}
// Update and cleanup enemy bullets
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var eb = enemyBullets[i];
eb.update();
if (eb.y > 2732 + eb.height / 2) {
eb.destroy();
enemyBullets.splice(i, 1);
continue;
}
// Collision with hero
if (eb.intersects(hero)) {
LK.effects.flashScreen(0xff0000, 800);
heroLives--;
livesTxt.setText("♥ x" + heroLives);
eb.destroy();
enemyBullets.splice(i, 1);
if (heroLives <= 0) {
LK.showGameOver();
return;
}
continue;
}
}
// Update and cleanup enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var e = enemies[i];
e.update();
if (e.y > 2732 + e.height / 2) {
e.destroy();
enemies.splice(i, 1);
continue;
}
// Collision with hero
if (e.intersects(hero)) {
LK.effects.flashScreen(0xff0000, 800);
heroLives--;
livesTxt.setText("♥ x" + heroLives);
e.destroy();
enemies.splice(i, 1);
if (heroLives <= 0) {
LK.showGameOver();
return;
}
continue;
}
}
// Update and cleanup powerups
for (var i = powerups.length - 1; i >= 0; i--) {
var p = powerups[i];
p.update();
if (p.y > 2732 + p.height / 2) {
p.destroy();
powerups.splice(i, 1);
continue;
}
// Collision with hero
if (p.intersects(hero)) {
LK.getSound('powerup').play();
hero.activatePowerup();
p.destroy();
powerups.splice(i, 1);
continue;
}
}
// Win condition: score 500
if (score >= 500) {
LK.showYouWin();
return;
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemySprite = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = enemySprite.width;
self.height = enemySprite.height;
self.speed = 6 + Math.random() * 3;
self.shootTimer = 60 + Math.floor(Math.random() * 60);
self.hp = 1;
// Update
self.update = function () {
self.y += self.speed;
self.shootTimer--;
if (self.shootTimer <= 0) {
self.shoot();
self.shootTimer = 90 + Math.floor(Math.random() * 60);
}
};
// Shoot
self.shoot = function () {
var bullet = new EnemyBullet();
bullet.x = self.x;
bullet.y = self.y + self.height / 2 + bullet.height / 2;
enemyBullets.push(bullet);
game.addChild(bullet);
};
return self;
});
// Enemy bullet class
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletSprite = self.attachAsset('enemyBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = bulletSprite.width;
self.height = bulletSprite.height;
self.speed = 18;
self.update = function () {
self.y += self.speed;
};
return self;
});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroSprite = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = heroSprite.width;
self.height = heroSprite.height;
self.shootCooldown = 0;
self.poweredUp = false;
self.powerupTimer = 0;
// Shoot method
self.shoot = function () {
if (self.shootCooldown > 0) return;
var bullet = new HeroBullet();
bullet.x = self.x;
bullet.y = self.y - self.height / 2 - bullet.height / 2;
heroBullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
self.shootCooldown = self.poweredUp ? 10 : 20; // Faster shooting if powered up
};
// Powerup method
self.activatePowerup = function () {
self.poweredUp = true;
self.powerupTimer = 300; // 5 seconds at 60fps
tween(self, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
easing: tween.elasticOut
});
};
// Remove powerup
self.deactivatePowerup = function () {
self.poweredUp = false;
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.elasticIn
});
};
// Update
self.update = function () {
if (self.shootCooldown > 0) self.shootCooldown--;
if (self.poweredUp) {
self.powerupTimer--;
if (self.powerupTimer <= 0) {
self.deactivatePowerup();
}
}
};
return self;
});
// Hero bullet class
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletSprite = self.attachAsset('heroBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = bulletSprite.width;
self.height = bulletSprite.height;
self.speed = -28;
self.update = function () {
self.y += self.speed;
};
return self;
});
// Powerup class
var Powerup = Container.expand(function () {
var self = Container.call(this);
var powerupSprite = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = powerupSprite.width;
self.height = powerupSprite.height;
self.speed = 10;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222a36
});
/****
* Game Code
****/
// Music
// Sound effects
// Powerup: green ellipse
// Hero bullet: yellow box
// Enemy bullet: orange box
// Enemy asset: red ellipse
// Hero asset: blue box
// Play music
LK.playMusic('battlefieldMusic');
// Score
var score = 0;
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Hero lives
var heroLives = 5;
var livesTxt = new Text2("♥ x" + heroLives, {
size: 110,
fill: 0xFF4444,
font: "Impact, Arial Black, Tahoma"
});
livesTxt.anchor.set(1, 0);
livesTxt.x = LK.gui.width - 40;
livesTxt.y = 0;
LK.gui.top.addChild(livesTxt);
// Hero instance
var hero = new Hero();
game.addChild(hero);
hero.x = 2048 / 2;
hero.y = 2732 - 350;
// Arrays for game objects
var enemies = [];
var heroBullets = [];
var enemyBullets = [];
var powerups = [];
// Dragging
var dragNode = null;
// Difficulty
var spawnTimer = 0;
var spawnInterval = 60;
var difficultyTimer = 0;
// Powerup spawn
var powerupTimer = 600;
// Move handler
function handleMove(x, y, obj) {
if (dragNode) {
// Clamp hero inside game area, avoid top 100px and bottom 100px
var minX = hero.width / 2;
var maxX = 2048 - hero.width / 2;
var minY = 100 + hero.height / 2;
var maxY = 2732 - hero.height / 2 - 100;
hero.x = Math.max(minX, Math.min(maxX, x));
hero.y = Math.max(minY, Math.min(maxY, y));
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Only start drag if touch is on hero
var dx = x - hero.x;
var dy = y - hero.y;
if (dx * dx + dy * dy < hero.width / 2 * (hero.width / 2)) {
dragNode = hero;
handleMove(x, y, obj);
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Main update loop
game.update = function () {
// Hero update
hero.update();
// Hero auto-shoot
if (LK.ticks % (hero.poweredUp ? 6 : 12) === 0) {
hero.shoot();
}
// Spawn enemies
spawnTimer--;
if (spawnTimer <= 0) {
var enemy = new Enemy();
var margin = 120;
enemy.x = margin + Math.random() * (2048 - 2 * margin);
enemy.y = -enemy.height / 2;
enemies.push(enemy);
game.addChild(enemy);
spawnTimer = spawnInterval;
}
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer % 600 === 0 && spawnInterval > 20) {
spawnInterval -= 5;
}
// Powerup spawn
powerupTimer--;
if (powerupTimer <= 0) {
var powerup = new Powerup();
powerup.x = 200 + Math.random() * (2048 - 400);
powerup.y = -powerup.height / 2;
powerups.push(powerup);
game.addChild(powerup);
powerupTimer = 900 + Math.floor(Math.random() * 600);
}
// Update and cleanup hero bullets
for (var i = heroBullets.length - 1; i >= 0; i--) {
var b = heroBullets[i];
b.update();
if (b.y < -b.height / 2) {
b.destroy();
heroBullets.splice(i, 1);
continue;
}
// Collision with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
var e = enemies[j];
if (b.intersects(e)) {
e.hp--;
if (e.hp <= 0) {
LK.getSound('enemyDown').play();
score += 10;
scoreTxt.setText(score);
e.destroy();
enemies.splice(j, 1);
}
b.destroy();
heroBullets.splice(i, 1);
break;
}
}
}
// Update and cleanup enemy bullets
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var eb = enemyBullets[i];
eb.update();
if (eb.y > 2732 + eb.height / 2) {
eb.destroy();
enemyBullets.splice(i, 1);
continue;
}
// Collision with hero
if (eb.intersects(hero)) {
LK.effects.flashScreen(0xff0000, 800);
heroLives--;
livesTxt.setText("♥ x" + heroLives);
eb.destroy();
enemyBullets.splice(i, 1);
if (heroLives <= 0) {
LK.showGameOver();
return;
}
continue;
}
}
// Update and cleanup enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var e = enemies[i];
e.update();
if (e.y > 2732 + e.height / 2) {
e.destroy();
enemies.splice(i, 1);
continue;
}
// Collision with hero
if (e.intersects(hero)) {
LK.effects.flashScreen(0xff0000, 800);
heroLives--;
livesTxt.setText("♥ x" + heroLives);
e.destroy();
enemies.splice(i, 1);
if (heroLives <= 0) {
LK.showGameOver();
return;
}
continue;
}
}
// Update and cleanup powerups
for (var i = powerups.length - 1; i >= 0; i--) {
var p = powerups[i];
p.update();
if (p.y > 2732 + p.height / 2) {
p.destroy();
powerups.splice(i, 1);
continue;
}
// Collision with hero
if (p.intersects(hero)) {
LK.getSound('powerup').play();
hero.activatePowerup();
p.destroy();
powerups.splice(i, 1);
continue;
}
}
// Win condition: score 500
if (score >= 500) {
LK.showYouWin();
return;
}
};
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Battlefield Blitz" and with the description "A dynamic 2D war game where you control a hero, dodge enemy attacks, and shoot down waves of foes to survive and score high.". No text on banner!
Enemy. In-Game asset. 2d. High contrast. No shadows
Gun. In-Game asset. 2d. High contrast. No shadows
Mermi. In-Game asset. 2d. High contrast. No shadows
Şarjör. In-Game asset. 2d. High contrast. No shadows
Alev topu. In-Game asset. 2d. High contrast. No shadows