/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletAsset = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.radius = bulletAsset.width / 2; self.speed = -18; self.update = function () { self.y += self.speed; }; return self; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyAsset = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.radius = enemyAsset.width / 2; self.speed = 3 + Math.random() * 2; // Speed increases with waves self.update = function () { self.y += self.speed; }; return self; }); // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroAsset = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.radius = heroAsset.width / 2; self.weaponLevel = 1; // 1: single, 2: double, 3: triple, etc. // For touch drag self.down = function (x, y, obj) {}; self.up = function (x, y, obj) {}; self.move = function (x, y, obj) {}; return self; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obsAsset = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.radius = obsAsset.width / 2; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xcce6ff // Açık gökyüzü mavisi, bulutlu bir hava efekti için }); /**** * Game Code ****/ // --- Game Variables --- // --- Asset Initialization --- var hero; var enemies = []; var bullets = []; var obstacles = []; var dragNode = null; var lastScore = 0; var kills = 0; var wave = 1; var spawnTimer = 0; var weaponLevel = 1; var scoreTxt; // --- Super Power State --- var superPowerAvailable = 0; // Number of super powers available var superPowerActive = false; var superPowerTimer = 0; // --- UI --- scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // High Score UI var highScore = storage.highScore || 0; var highScoreTxt = new Text2('En Yüksek: ' + highScore, { size: 70, fill: 0xFFD700 }); highScoreTxt.anchor.set(0.5, 0); highScoreTxt.y = scoreTxt.height + 10; LK.gui.top.addChild(highScoreTxt); // --- Place Obstacles --- function placeObstacles() { // Clear old for (var i = 0; i < obstacles.length; i++) { obstacles[i].destroy(); } obstacles = []; // Place 3 obstacles in the arena, not blocking the hero spawn var obsY = [900, 1500, 2100]; for (var i = 0; i < 3; i++) { var obs = new Obstacle(); obs.x = 2048 / 2 + (i - 1) * 500; obs.y = obsY[i]; obstacles.push(obs); game.addChild(obs); } } // --- Spawn Hero --- function spawnHero() { hero = new Hero(); hero.x = 2048 / 2; hero.y = 2732 - 300; game.addChild(hero); weaponLevel = 1; hero.weaponLevel = 1; } // --- Spawn Enemy --- function spawnEnemy() { var enemy = new Enemy(); enemy.x = 300 + Math.random() * (2048 - 600); enemy.y = -120; // Increase enemy speed as score increases var baseSpeed = 3 + Math.random() * 2; var speedBonus = Math.floor(LK.getScore() / 20) * 0.8; // +0.8 per 20 score enemy.speed = baseSpeed + speedBonus; enemies.push(enemy); game.addChild(enemy); } // --- Fire Bullets --- function fireBullets() { var bulletCount = weaponLevel; var spread = 60; // px between bullets var baseX = hero.x - (bulletCount - 1) * spread / 2; for (var i = 0; i < bulletCount; i++) { var bullet = new Bullet(); bullet.x = baseX + i * spread; bullet.y = hero.y - hero.radius - 20; bullets.push(bullet); game.addChild(bullet); } } // --- Touch Controls --- function handleMove(x, y, obj) { if (dragNode) { // Clamp hero inside arena var minX = hero.radius + 20; var maxX = 2048 - hero.radius - 20; var minY = hero.radius + 200; var maxY = 2732 - hero.radius - 20; dragNode.x = Math.max(minX, Math.min(maxX, x)); dragNode.y = Math.max(minY, Math.min(maxY, y)); } } game.move = handleMove; game.down = function (x, y, obj) { // Only drag if touch is on hero var dx = x - hero.x; var dy = y - hero.y; if (dx * dx + dy * dy < hero.radius * hero.radius * 1.2) { // --- Super Power: Double tap to activate --- if (!game._lastTapTime) { game._lastTapTime = 0; } var now = Date.now(); if (now - game._lastTapTime < 350 && superPowerAvailable > 0 && !superPowerActive) { // Activate super power: clear all enemies superPowerActive = true; superPowerAvailable--; superPowerTimer = 30; // 0.5 seconds of effect (optional visual) // Destroy all enemies instantly for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].destroy(); enemies.splice(i, 1); } LK.effects.flashScreen(0x3399ff, 600); } game._lastTapTime = now; dragNode = hero; handleMove(x, y, obj); } }; game.up = function (x, y, obj) { dragNode = null; }; // --- Game Update --- game.update = function () { // --- Bullets --- for (var i = bullets.length - 1; i >= 0; i--) { var b = bullets[i]; b.update(); // Remove offscreen if (b.y < -50) { b.destroy(); bullets.splice(i, 1); continue; } // Collide with obstacles var hitObs = false; for (var j = 0; j < obstacles.length; j++) { if (b.intersects(obstacles[j])) { b.destroy(); bullets.splice(i, 1); hitObs = true; break; } } if (hitObs) { continue; } // Collide with enemies for (var j = enemies.length - 1; j >= 0; j--) { if (b.intersects(enemies[j])) { // Destroy both b.destroy(); bullets.splice(i, 1); enemies[j].destroy(); enemies.splice(j, 1); kills++; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // High score update if (LK.getScore() > highScore) { highScore = LK.getScore(); storage.highScore = highScore; highScoreTxt.setText('En Yüksek: ' + highScore); } // Weapon upgrade if (kills % 10 === 0) { weaponLevel++; hero.weaponLevel = weaponLevel; LK.effects.flashObject(hero, 0x00ff00, 600); } // Super Power gain every 20 kills if (kills % 20 === 0) { superPowerAvailable++; // Optional: flash hero blue to indicate super power gained LK.effects.flashObject(hero, 0x3399ff, 800); } break; } } } // --- Enemies --- for (var i = enemies.length - 1; i >= 0; i--) { var e = enemies[i]; e.update(); // Collide with obstacles var hitObs = false; for (var j = 0; j < obstacles.length; j++) { if (e.intersects(obstacles[j])) { // Bounce down a bit and change x direction e.y -= 30; e.x += (Math.random() - 0.5) * 200; hitObs = true; break; } } if (hitObs) { continue; } // Collide with hero if (e.intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Remove offscreen if (e.y > 2732 + 100) { e.destroy(); enemies.splice(i, 1); } } // --- Hero collides with obstacles (game over) --- for (var i = 0; i < obstacles.length; i++) { if (hero && hero.intersects(obstacles[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } } // --- Enemy Spawning --- // Difficulty scaling: more enemies and faster as score increases spawnTimer++; // Increase spawn rate as score increases (minimum interval 12) var difficulty = Math.floor(LK.getScore() / 10); var spawnInterval = Math.max(12, 90 - wave * 5 - difficulty * 4); if (spawnTimer >= spawnInterval) { // Spawn more enemies at once as score increases var extraEnemies = 1 + Math.floor(LK.getScore() / 25); for (var s = 0; s < extraEnemies; s++) { spawnEnemy(); } spawnTimer = 0; } // Increase wave every 15 kills wave = 1 + Math.floor(kills / 15); // --- Fire Bullets (auto fire) --- if (LK.ticks % 18 === 0) { fireBullets(); } ; // --- Super Power Timer --- if (superPowerActive) { superPowerTimer--; if (superPowerTimer <= 0) { superPowerActive = false; } } }; // --- Game Start --- placeObstacles(); spawnHero(); LK.setScore(0); scoreTxt.setText(0); // Reset high score UI (in case storage changed externally) highScore = storage.highScore || 0; highScoreTxt.setText('En Yüksek: ' + highScore); kills = 0; wave = 1; weaponLevel = 1; enemies = []; bullets = []; spawnTimer = 0; superPowerAvailable = 0; superPowerActive = false; superPowerTimer = 0; ;
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletAsset = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = bulletAsset.width / 2;
self.speed = -18;
self.update = function () {
self.y += self.speed;
};
return self;
});
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyAsset = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = enemyAsset.width / 2;
self.speed = 3 + Math.random() * 2; // Speed increases with waves
self.update = function () {
self.y += self.speed;
};
return self;
});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroAsset = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = heroAsset.width / 2;
self.weaponLevel = 1; // 1: single, 2: double, 3: triple, etc.
// For touch drag
self.down = function (x, y, obj) {};
self.up = function (x, y, obj) {};
self.move = function (x, y, obj) {};
return self;
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obsAsset = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = obsAsset.width / 2;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xcce6ff // Açık gökyüzü mavisi, bulutlu bir hava efekti için
});
/****
* Game Code
****/
// --- Game Variables ---
// --- Asset Initialization ---
var hero;
var enemies = [];
var bullets = [];
var obstacles = [];
var dragNode = null;
var lastScore = 0;
var kills = 0;
var wave = 1;
var spawnTimer = 0;
var weaponLevel = 1;
var scoreTxt;
// --- Super Power State ---
var superPowerAvailable = 0; // Number of super powers available
var superPowerActive = false;
var superPowerTimer = 0;
// --- UI ---
scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// High Score UI
var highScore = storage.highScore || 0;
var highScoreTxt = new Text2('En Yüksek: ' + highScore, {
size: 70,
fill: 0xFFD700
});
highScoreTxt.anchor.set(0.5, 0);
highScoreTxt.y = scoreTxt.height + 10;
LK.gui.top.addChild(highScoreTxt);
// --- Place Obstacles ---
function placeObstacles() {
// Clear old
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].destroy();
}
obstacles = [];
// Place 3 obstacles in the arena, not blocking the hero spawn
var obsY = [900, 1500, 2100];
for (var i = 0; i < 3; i++) {
var obs = new Obstacle();
obs.x = 2048 / 2 + (i - 1) * 500;
obs.y = obsY[i];
obstacles.push(obs);
game.addChild(obs);
}
}
// --- Spawn Hero ---
function spawnHero() {
hero = new Hero();
hero.x = 2048 / 2;
hero.y = 2732 - 300;
game.addChild(hero);
weaponLevel = 1;
hero.weaponLevel = 1;
}
// --- Spawn Enemy ---
function spawnEnemy() {
var enemy = new Enemy();
enemy.x = 300 + Math.random() * (2048 - 600);
enemy.y = -120;
// Increase enemy speed as score increases
var baseSpeed = 3 + Math.random() * 2;
var speedBonus = Math.floor(LK.getScore() / 20) * 0.8; // +0.8 per 20 score
enemy.speed = baseSpeed + speedBonus;
enemies.push(enemy);
game.addChild(enemy);
}
// --- Fire Bullets ---
function fireBullets() {
var bulletCount = weaponLevel;
var spread = 60; // px between bullets
var baseX = hero.x - (bulletCount - 1) * spread / 2;
for (var i = 0; i < bulletCount; i++) {
var bullet = new Bullet();
bullet.x = baseX + i * spread;
bullet.y = hero.y - hero.radius - 20;
bullets.push(bullet);
game.addChild(bullet);
}
}
// --- Touch Controls ---
function handleMove(x, y, obj) {
if (dragNode) {
// Clamp hero inside arena
var minX = hero.radius + 20;
var maxX = 2048 - hero.radius - 20;
var minY = hero.radius + 200;
var maxY = 2732 - hero.radius - 20;
dragNode.x = Math.max(minX, Math.min(maxX, x));
dragNode.y = Math.max(minY, Math.min(maxY, y));
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Only drag if touch is on hero
var dx = x - hero.x;
var dy = y - hero.y;
if (dx * dx + dy * dy < hero.radius * hero.radius * 1.2) {
// --- Super Power: Double tap to activate ---
if (!game._lastTapTime) {
game._lastTapTime = 0;
}
var now = Date.now();
if (now - game._lastTapTime < 350 && superPowerAvailable > 0 && !superPowerActive) {
// Activate super power: clear all enemies
superPowerActive = true;
superPowerAvailable--;
superPowerTimer = 30; // 0.5 seconds of effect (optional visual)
// Destroy all enemies instantly
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].destroy();
enemies.splice(i, 1);
}
LK.effects.flashScreen(0x3399ff, 600);
}
game._lastTapTime = now;
dragNode = hero;
handleMove(x, y, obj);
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// --- Game Update ---
game.update = function () {
// --- Bullets ---
for (var i = bullets.length - 1; i >= 0; i--) {
var b = bullets[i];
b.update();
// Remove offscreen
if (b.y < -50) {
b.destroy();
bullets.splice(i, 1);
continue;
}
// Collide with obstacles
var hitObs = false;
for (var j = 0; j < obstacles.length; j++) {
if (b.intersects(obstacles[j])) {
b.destroy();
bullets.splice(i, 1);
hitObs = true;
break;
}
}
if (hitObs) {
continue;
}
// Collide with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
if (b.intersects(enemies[j])) {
// Destroy both
b.destroy();
bullets.splice(i, 1);
enemies[j].destroy();
enemies.splice(j, 1);
kills++;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
// High score update
if (LK.getScore() > highScore) {
highScore = LK.getScore();
storage.highScore = highScore;
highScoreTxt.setText('En Yüksek: ' + highScore);
}
// Weapon upgrade
if (kills % 10 === 0) {
weaponLevel++;
hero.weaponLevel = weaponLevel;
LK.effects.flashObject(hero, 0x00ff00, 600);
}
// Super Power gain every 20 kills
if (kills % 20 === 0) {
superPowerAvailable++;
// Optional: flash hero blue to indicate super power gained
LK.effects.flashObject(hero, 0x3399ff, 800);
}
break;
}
}
}
// --- Enemies ---
for (var i = enemies.length - 1; i >= 0; i--) {
var e = enemies[i];
e.update();
// Collide with obstacles
var hitObs = false;
for (var j = 0; j < obstacles.length; j++) {
if (e.intersects(obstacles[j])) {
// Bounce down a bit and change x direction
e.y -= 30;
e.x += (Math.random() - 0.5) * 200;
hitObs = true;
break;
}
}
if (hitObs) {
continue;
}
// Collide with hero
if (e.intersects(hero)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Remove offscreen
if (e.y > 2732 + 100) {
e.destroy();
enemies.splice(i, 1);
}
}
// --- Hero collides with obstacles (game over) ---
for (var i = 0; i < obstacles.length; i++) {
if (hero && hero.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
// --- Enemy Spawning ---
// Difficulty scaling: more enemies and faster as score increases
spawnTimer++;
// Increase spawn rate as score increases (minimum interval 12)
var difficulty = Math.floor(LK.getScore() / 10);
var spawnInterval = Math.max(12, 90 - wave * 5 - difficulty * 4);
if (spawnTimer >= spawnInterval) {
// Spawn more enemies at once as score increases
var extraEnemies = 1 + Math.floor(LK.getScore() / 25);
for (var s = 0; s < extraEnemies; s++) {
spawnEnemy();
}
spawnTimer = 0;
}
// Increase wave every 15 kills
wave = 1 + Math.floor(kills / 15);
// --- Fire Bullets (auto fire) ---
if (LK.ticks % 18 === 0) {
fireBullets();
}
;
// --- Super Power Timer ---
if (superPowerActive) {
superPowerTimer--;
if (superPowerTimer <= 0) {
superPowerActive = false;
}
}
};
// --- Game Start ---
placeObstacles();
spawnHero();
LK.setScore(0);
scoreTxt.setText(0);
// Reset high score UI (in case storage changed externally)
highScore = storage.highScore || 0;
highScoreTxt.setText('En Yüksek: ' + highScore);
kills = 0;
wave = 1;
weaponLevel = 1;
enemies = [];
bullets = [];
spawnTimer = 0;
superPowerAvailable = 0;
superPowerActive = false;
superPowerTimer = 0;
;
Gerçek mermiye benzeyen mermi yap. In-Game asset. 2d. High contrast. No shadows
Düşman angry birdse benzesin. In-Game asset. 2d. High contrast. No shadows
Yeşil angry birds olsun. In-Game asset. 2d. High contrast. No shadows
Bulut deseni olsun ve parlak beyaz olsun. In-Game asset. 2d. High contrast. No shadows