/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Ant = Container.expand(function () { var self = Container.call(this); var antGraphics = self.attachAsset('ant', { anchorX: 0.5, anchorY: 0.5 }); self.shootTimer = 0; self.shootDelay = 30; self.update = function () { self.shootTimer++; if (self.shootTimer >= self.shootDelay) { self.shootTimer = 0; fireAntBullet(); } }; return self; }); var AntBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('antBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -8; self.update = function () { self.y += self.speed; }; return self; }); var Background = Container.expand(function () { var self = Container.call(this); self.currentBackground = 'grass'; var grassBg = self.attachAsset('grassBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); var skyBg = self.attachAsset('skyBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); skyBg.visible = false; self.setBackground = function (type) { if (type === 'grass') { grassBg.visible = true; skyBg.visible = false; self.currentBackground = 'grass'; } else if (type === 'sky') { grassBg.visible = false; skyBg.visible = true; self.currentBackground = 'sky'; } }; self.getCurrentBackground = function () { return self.currentBackground; }; return self; }); var Bee = Container.expand(function () { var self = Container.call(this); var beeGraphics = self.attachAsset('bee', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.horizontalSpeed = 1; self.direction = Math.random() > 0.5 ? 1 : -1; self.update = function () { self.y += self.speed; self.x += self.horizontalSpeed * self.direction; if (self.x <= 50 || self.x >= 1998) { self.direction *= -1; } }; return self; }); var BossBee = Container.expand(function () { var self = Container.call(this); var beeGraphics = self.attachAsset('bee', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.speed = 1; self.horizontalSpeed = 0.5; self.direction = Math.random() > 0.5 ? 1 : -1; self.health = 15; self.maxHealth = 15; self.lastHit = false; self.update = function () { self.y += self.speed; self.x += self.horizontalSpeed * self.direction; if (self.x <= 100 || self.x >= 1948) { self.direction *= -1; } }; return self; }); var PowerUp = Container.expand(function () { var self = Container.call(this); var powerUpGraphics = self.attachAsset('powerUp', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.bobTimer = 0; self.update = function () { self.y += self.speed; self.bobTimer += 0.2; self.rotation = Math.sin(self.bobTimer) * 0.3; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228b22 }); /**** * Game Code ****/ // Game variables var ant; var background; var bees = []; var antBullets = []; var powerUps = []; var waveTimer = 0; var currentWave = 1; var beesPerWave = 20; var waveDelay = 60; var nextWaveTimer = 0; var dragNode = null; var gameRunning = true; var bossBee = null; var isBossWave = false; // UI Elements var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var waveTxt = new Text2('Wave: 1', { size: 50, fill: 0xFFFF00 }); waveTxt.anchor.set(0, 0); waveTxt.x = 50; waveTxt.y = 100; LK.gui.topLeft.addChild(waveTxt); var bossHealthTxt = new Text2('', { size: 40, fill: 0xFF0000 }); bossHealthTxt.anchor.set(0.5, 0); bossHealthTxt.x = 1024; bossHealthTxt.y = 150; LK.gui.top.addChild(bossHealthTxt); // Initialize background background = game.addChild(new Background()); // Initialize ant ant = game.addChild(new Ant()); ant.x = 1024; ant.y = 2600; // Functions function fireAntBullet() { if (!gameRunning) return; var bullet = new AntBullet(); bullet.x = ant.x; bullet.y = ant.y - 40; // Apply current theme color to new bullet if (background.getCurrentBackground() === 'sky') { bullet.children[0].tint = 0x44ffff; } antBullets.push(bullet); game.addChild(bullet); LK.getSound('shoot').play(); } function spawnBee() { var bee = new Bee(); bee.x = Math.random() * 1800 + 124; bee.y = -50; bee.speed = 1 + currentWave * 0.3; // Apply current theme color to new bee if (background.getCurrentBackground() === 'sky') { bee.children[0].tint = 0x8844ff; } bees.push(bee); game.addChild(bee); } function spawnBossBee() { bossBee = new BossBee(); bossBee.x = 1024; bossBee.y = -100; bossBee.speed = 0.5 + currentWave * 0.1; // Apply current theme color to boss bee if (background.getCurrentBackground() === 'sky') { bossBee.children[0].tint = 0x8844ff; } game.addChild(bossBee); bossHealthTxt.setText('Boss Health: ' + bossBee.health + '/' + bossBee.maxHealth); } function spawnWave() { // Check if this is a boss wave (every 5th wave) if (currentWave % 5 === 0) { isBossWave = true; spawnBossBee(); } else { isBossWave = false; var beesToSpawn = 13 + currentWave * 2; for (var i = 0; i < beesToSpawn; i++) { LK.setTimeout(function () { spawnBee(); }, i * 50); } } } function spawnPowerUp(x, y) { if (Math.random() < 0.05) { var powerUp = new PowerUp(); powerUp.x = x; powerUp.y = y; powerUps.push(powerUp); game.addChild(powerUp); } } function handleMove(x, y, obj) { if (!gameRunning) return; if (dragNode) { dragNode.x = Math.max(50, Math.min(1998, x)); } } // Theme switching function - changes all visual assets function switchTheme() { if (background.getCurrentBackground() === 'grass') { background.setBackground('sky'); // Change ant color to blue for space theme ant.children[0].tint = 0x4444ff; // Change all bee colors to purple for space theme for (var i = 0; i < bees.length; i++) { bees[i].children[0].tint = 0x8844ff; } // Change bullet color to cyan for (var i = 0; i < antBullets.length; i++) { antBullets[i].children[0].tint = 0x44ffff; } } else { background.setBackground('grass'); // Reset ant to original color ant.children[0].tint = 0xffffff; // Reset all bee colors for (var i = 0; i < bees.length; i++) { bees[i].children[0].tint = 0xffffff; } // Reset bullet colors for (var i = 0; i < antBullets.length; i++) { antBullets[i].children[0].tint = 0xffffff; } } } // Event handlers game.move = handleMove; game.down = function (x, y, obj) { if (!gameRunning) return; // Check if touch is in top right area for theme switching if (x > 1548 && y < 200) { switchTheme(); return; } dragNode = ant; handleMove(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; // Start first wave spawnWave(); // Play background music LK.playMusic('arkaplan'); // Main game loop game.update = function () { if (!gameRunning) return; // Update ant bullets for (var i = antBullets.length - 1; i >= 0; i--) { var bullet = antBullets[i]; if (bullet.y < -50) { bullet.destroy(); antBullets.splice(i, 1); continue; } // Check collision with boss bee if (isBossWave && bossBee && bullet.intersects(bossBee)) { bossBee.health--; bossHealthTxt.setText('Boss Health: ' + bossBee.health + '/' + bossBee.maxHealth); bullet.destroy(); antBullets.splice(i, 1); LK.getSound('beeDestroy').play(); LK.effects.flashObject(bossBee, 0xffffff, 200); if (bossBee.health <= 0) { LK.setScore(LK.getScore() + 100 * currentWave); scoreTxt.setText('Score: ' + LK.getScore()); spawnPowerUp(bossBee.x, bossBee.y); bossBee.destroy(); bossBee = null; bossHealthTxt.setText(''); } break; } // Check collision with bees for (var j = bees.length - 1; j >= 0; j--) { var bee = bees[j]; if (bullet.intersects(bee)) { // Destroy bee and bullet LK.setScore(LK.getScore() + 10 * currentWave); scoreTxt.setText('Score: ' + LK.getScore()); spawnPowerUp(bee.x, bee.y); bee.destroy(); bees.splice(j, 1); bullet.destroy(); antBullets.splice(i, 1); LK.getSound('beeDestroy').play(); LK.effects.flashObject(bee, 0xffffff, 200); break; } } } // Update boss bee if (isBossWave && bossBee) { // Check if boss bee reached bottom - game over if (bossBee.y > 2732) { gameRunning = false; LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Check collision with ant if (bossBee.intersects(ant)) { gameRunning = false; LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } } // Update bees for (var i = bees.length - 1; i >= 0; i--) { var bee = bees[i]; // Check if bee reached bottom - game over if (bee.y > 2732) { gameRunning = false; LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Check collision with ant if (bee.intersects(ant)) { gameRunning = false; LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } } // Update power-ups for (var i = powerUps.length - 1; i >= 0; i--) { var powerUp = powerUps[i]; if (powerUp.y > 2732) { powerUp.destroy(); powerUps.splice(i, 1); continue; } // Check collision with ant if (powerUp.intersects(ant)) { LK.setScore(LK.getScore() + 50); scoreTxt.setText('Score: ' + LK.getScore()); ant.shootDelay = Math.max(5, ant.shootDelay - 2); powerUp.destroy(); powerUps.splice(i, 1); LK.getSound('powerUpCollect').play(); LK.effects.flashObject(ant, 0x00ff00, 300); } } // Wave management var waveComplete = false; if (isBossWave) { waveComplete = bossBee === null; } else { waveComplete = bees.length === 0; } if (waveComplete) { nextWaveTimer++; if (nextWaveTimer >= waveDelay) { currentWave++; waveTxt.setText('Wave: ' + currentWave); nextWaveTimer = 0; spawnWave(); // Victory condition if (currentWave > 10) { gameRunning = false; LK.showYouWin(); return; } } } // Keep ant within bounds ant.x = Math.max(50, Math.min(1998, ant.x)); };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Ant = Container.expand(function () {
var self = Container.call(this);
var antGraphics = self.attachAsset('ant', {
anchorX: 0.5,
anchorY: 0.5
});
self.shootTimer = 0;
self.shootDelay = 30;
self.update = function () {
self.shootTimer++;
if (self.shootTimer >= self.shootDelay) {
self.shootTimer = 0;
fireAntBullet();
}
};
return self;
});
var AntBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('antBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -8;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Background = Container.expand(function () {
var self = Container.call(this);
self.currentBackground = 'grass';
var grassBg = self.attachAsset('grassBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
var skyBg = self.attachAsset('skyBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
skyBg.visible = false;
self.setBackground = function (type) {
if (type === 'grass') {
grassBg.visible = true;
skyBg.visible = false;
self.currentBackground = 'grass';
} else if (type === 'sky') {
grassBg.visible = false;
skyBg.visible = true;
self.currentBackground = 'sky';
}
};
self.getCurrentBackground = function () {
return self.currentBackground;
};
return self;
});
var Bee = Container.expand(function () {
var self = Container.call(this);
var beeGraphics = self.attachAsset('bee', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.horizontalSpeed = 1;
self.direction = Math.random() > 0.5 ? 1 : -1;
self.update = function () {
self.y += self.speed;
self.x += self.horizontalSpeed * self.direction;
if (self.x <= 50 || self.x >= 1998) {
self.direction *= -1;
}
};
return self;
});
var BossBee = Container.expand(function () {
var self = Container.call(this);
var beeGraphics = self.attachAsset('bee', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.speed = 1;
self.horizontalSpeed = 0.5;
self.direction = Math.random() > 0.5 ? 1 : -1;
self.health = 15;
self.maxHealth = 15;
self.lastHit = false;
self.update = function () {
self.y += self.speed;
self.x += self.horizontalSpeed * self.direction;
if (self.x <= 100 || self.x >= 1948) {
self.direction *= -1;
}
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.bobTimer = 0;
self.update = function () {
self.y += self.speed;
self.bobTimer += 0.2;
self.rotation = Math.sin(self.bobTimer) * 0.3;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228b22
});
/****
* Game Code
****/
// Game variables
var ant;
var background;
var bees = [];
var antBullets = [];
var powerUps = [];
var waveTimer = 0;
var currentWave = 1;
var beesPerWave = 20;
var waveDelay = 60;
var nextWaveTimer = 0;
var dragNode = null;
var gameRunning = true;
var bossBee = null;
var isBossWave = false;
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var waveTxt = new Text2('Wave: 1', {
size: 50,
fill: 0xFFFF00
});
waveTxt.anchor.set(0, 0);
waveTxt.x = 50;
waveTxt.y = 100;
LK.gui.topLeft.addChild(waveTxt);
var bossHealthTxt = new Text2('', {
size: 40,
fill: 0xFF0000
});
bossHealthTxt.anchor.set(0.5, 0);
bossHealthTxt.x = 1024;
bossHealthTxt.y = 150;
LK.gui.top.addChild(bossHealthTxt);
// Initialize background
background = game.addChild(new Background());
// Initialize ant
ant = game.addChild(new Ant());
ant.x = 1024;
ant.y = 2600;
// Functions
function fireAntBullet() {
if (!gameRunning) return;
var bullet = new AntBullet();
bullet.x = ant.x;
bullet.y = ant.y - 40;
// Apply current theme color to new bullet
if (background.getCurrentBackground() === 'sky') {
bullet.children[0].tint = 0x44ffff;
}
antBullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
function spawnBee() {
var bee = new Bee();
bee.x = Math.random() * 1800 + 124;
bee.y = -50;
bee.speed = 1 + currentWave * 0.3;
// Apply current theme color to new bee
if (background.getCurrentBackground() === 'sky') {
bee.children[0].tint = 0x8844ff;
}
bees.push(bee);
game.addChild(bee);
}
function spawnBossBee() {
bossBee = new BossBee();
bossBee.x = 1024;
bossBee.y = -100;
bossBee.speed = 0.5 + currentWave * 0.1;
// Apply current theme color to boss bee
if (background.getCurrentBackground() === 'sky') {
bossBee.children[0].tint = 0x8844ff;
}
game.addChild(bossBee);
bossHealthTxt.setText('Boss Health: ' + bossBee.health + '/' + bossBee.maxHealth);
}
function spawnWave() {
// Check if this is a boss wave (every 5th wave)
if (currentWave % 5 === 0) {
isBossWave = true;
spawnBossBee();
} else {
isBossWave = false;
var beesToSpawn = 13 + currentWave * 2;
for (var i = 0; i < beesToSpawn; i++) {
LK.setTimeout(function () {
spawnBee();
}, i * 50);
}
}
}
function spawnPowerUp(x, y) {
if (Math.random() < 0.05) {
var powerUp = new PowerUp();
powerUp.x = x;
powerUp.y = y;
powerUps.push(powerUp);
game.addChild(powerUp);
}
}
function handleMove(x, y, obj) {
if (!gameRunning) return;
if (dragNode) {
dragNode.x = Math.max(50, Math.min(1998, x));
}
}
// Theme switching function - changes all visual assets
function switchTheme() {
if (background.getCurrentBackground() === 'grass') {
background.setBackground('sky');
// Change ant color to blue for space theme
ant.children[0].tint = 0x4444ff;
// Change all bee colors to purple for space theme
for (var i = 0; i < bees.length; i++) {
bees[i].children[0].tint = 0x8844ff;
}
// Change bullet color to cyan
for (var i = 0; i < antBullets.length; i++) {
antBullets[i].children[0].tint = 0x44ffff;
}
} else {
background.setBackground('grass');
// Reset ant to original color
ant.children[0].tint = 0xffffff;
// Reset all bee colors
for (var i = 0; i < bees.length; i++) {
bees[i].children[0].tint = 0xffffff;
}
// Reset bullet colors
for (var i = 0; i < antBullets.length; i++) {
antBullets[i].children[0].tint = 0xffffff;
}
}
}
// Event handlers
game.move = handleMove;
game.down = function (x, y, obj) {
if (!gameRunning) return;
// Check if touch is in top right area for theme switching
if (x > 1548 && y < 200) {
switchTheme();
return;
}
dragNode = ant;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Start first wave
spawnWave();
// Play background music
LK.playMusic('arkaplan');
// Main game loop
game.update = function () {
if (!gameRunning) return;
// Update ant bullets
for (var i = antBullets.length - 1; i >= 0; i--) {
var bullet = antBullets[i];
if (bullet.y < -50) {
bullet.destroy();
antBullets.splice(i, 1);
continue;
}
// Check collision with boss bee
if (isBossWave && bossBee && bullet.intersects(bossBee)) {
bossBee.health--;
bossHealthTxt.setText('Boss Health: ' + bossBee.health + '/' + bossBee.maxHealth);
bullet.destroy();
antBullets.splice(i, 1);
LK.getSound('beeDestroy').play();
LK.effects.flashObject(bossBee, 0xffffff, 200);
if (bossBee.health <= 0) {
LK.setScore(LK.getScore() + 100 * currentWave);
scoreTxt.setText('Score: ' + LK.getScore());
spawnPowerUp(bossBee.x, bossBee.y);
bossBee.destroy();
bossBee = null;
bossHealthTxt.setText('');
}
break;
}
// Check collision with bees
for (var j = bees.length - 1; j >= 0; j--) {
var bee = bees[j];
if (bullet.intersects(bee)) {
// Destroy bee and bullet
LK.setScore(LK.getScore() + 10 * currentWave);
scoreTxt.setText('Score: ' + LK.getScore());
spawnPowerUp(bee.x, bee.y);
bee.destroy();
bees.splice(j, 1);
bullet.destroy();
antBullets.splice(i, 1);
LK.getSound('beeDestroy').play();
LK.effects.flashObject(bee, 0xffffff, 200);
break;
}
}
}
// Update boss bee
if (isBossWave && bossBee) {
// Check if boss bee reached bottom - game over
if (bossBee.y > 2732) {
gameRunning = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Check collision with ant
if (bossBee.intersects(ant)) {
gameRunning = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
// Update bees
for (var i = bees.length - 1; i >= 0; i--) {
var bee = bees[i];
// Check if bee reached bottom - game over
if (bee.y > 2732) {
gameRunning = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Check collision with ant
if (bee.intersects(ant)) {
gameRunning = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
// Update power-ups
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
if (powerUp.y > 2732) {
powerUp.destroy();
powerUps.splice(i, 1);
continue;
}
// Check collision with ant
if (powerUp.intersects(ant)) {
LK.setScore(LK.getScore() + 50);
scoreTxt.setText('Score: ' + LK.getScore());
ant.shootDelay = Math.max(5, ant.shootDelay - 2);
powerUp.destroy();
powerUps.splice(i, 1);
LK.getSound('powerUpCollect').play();
LK.effects.flashObject(ant, 0x00ff00, 300);
}
}
// Wave management
var waveComplete = false;
if (isBossWave) {
waveComplete = bossBee === null;
} else {
waveComplete = bees.length === 0;
}
if (waveComplete) {
nextWaveTimer++;
if (nextWaveTimer >= waveDelay) {
currentWave++;
waveTxt.setText('Wave: ' + currentWave);
nextWaveTimer = 0;
spawnWave();
// Victory condition
if (currentWave > 10) {
gameRunning = false;
LK.showYouWin();
return;
}
}
}
// Keep ant within bounds
ant.x = Math.max(50, Math.min(1998, ant.x));
};
siyah sarı renki arı. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Dik duran robotik bir karınca. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
BAL PETEĞİ. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
MAVİ BİR SÜMÜK. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat