User prompt
1 tane boss kestik Ten sonra oyun zorlassin wave olsun her boşa kestigimisde 1 wave artsın dusmanlarda
User prompt
3 ccanli şeyler daha hızlı vursun ve yukarda bossun ne zaman gelcegi yazsın
User prompt
Sadece bosslarin üstünde canı yazmasın hepsinde yazsın ve 2 3 canlı küçük şeyler de doğsun onlar daha güçlü olsun
User prompt
Ve ustende canı gözüksün
User prompt
Boss oldurdugumuzde shop açılmasın
User prompt
Shop yerini küçült sigadak şekilde yap
User prompt
Sıgmadı
User prompt
Shop tuşuna basıldığında başka yükseltmeleri görelim
User prompt
Advence shop olmasin oda shop un devamı olsun energy yükseltme gibi temel şeyler olsun
User prompt
Shopta başka şeylerde olsun energy yükseltme gibi
User prompt
Bide shoptan mesala 60 saniye işe yarayan bişi aldın sayaç olsun
User prompt
Tuş biraz daha belirgin olsun
User prompt
O ileri gitme yeri shop yerinin sağında olsun
User prompt
O ileri gitme tuşu sadece shop acildiginda gözüksün
User prompt
Shop yerinde sağ üste bir tuş olsun o tuşa basıldığında başka şeyler olsun eski şeyler soldada geriye gitme. Olsun
User prompt
Shop yerinde başka şeylerde olsun
User prompt
Shop tuşuna basıldığında düşmanlar silinsin close tuşuna basıldığında da devam etsin
User prompt
Her on adam yerine değilde mağaza tuşu olsun o tusa basıldığında mağaza açılsın
User prompt
Please fix the bug: 'TypeError: LK.pauseGame is not a function' in or related to this line: 'LK.pauseGame();' Line Number: 588
User prompt
Shop yerine gelince oyun dursun ve her dusman oldurdugumuzda oyun zorlassin ama çok değil
User prompt
Ve point yerine para olsun her 10 adam oldurdugumuzde bir mağaza olsun enerji hızlandırma ve enerjiyi yükseltme olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Normal mod yanında bir buton olsun kucuk ona basınca 3 ki bida basınca 8 li bida basinca 16 gibi
User prompt
Ve triple shoot sununun yanında ok olsun onla ileri gidelim mesala ondan sonra 8 li ok atma olsun geride gidelim
User prompt
Boss vurdugumuzda point artmasin
User prompt
Boss doğduğunda sadece boss olsun
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Archer = Container.expand(function () { var self = Container.call(this); var archerGraphics = self.attachAsset('archer', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Arrow = Container.expand(function () { var self = Container.call(this); var arrowGraphics = self.attachAsset('arrow', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = 0; self.speedY = 0; self.update = function () { self.x += self.speedX; self.y += self.speedY; }; return self; }); var Boss = Container.expand(function () { var self = Container.call(this); var bossGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.health = 10; self.shootTimer = 0; self.shootRate = 60; // Faster shooting than regular enemies self.moveToNewPosition = function () { var newX = Math.random() * (2048 - 400) + 200; var newY = Math.random() * (2732 - 400) + 200; // Make sure boss doesn't spawn too close to archer var distToArcher = Math.sqrt(Math.pow(newX - archer.x, 2) + Math.pow(newY - archer.y, 2)); if (distToArcher < 300) { newX = Math.random() * (2048 - 600) + 300; if (newX > archer.x - 300 && newX < archer.x + 300) { newX += 400; } } // Animate movement to new position tween(self, { x: newX, y: newY }, { duration: 800, easing: tween.easeInOut }); }; self.update = function () { self.shootTimer++; if (self.shootTimer >= self.shootRate) { self.shootTimer = 0; // Shoot at player var dirX = archer.x - self.x; var dirY = archer.y - self.y; var distance = Math.sqrt(dirX * dirX + dirY * dirY); var normalX = dirX / distance; var normalY = dirY / distance; // Make boss face the shooting direction self.rotation = Math.atan2(normalY, normalX); // Boss shoots 3 arrows at once for (var i = 0; i < 3; i++) { var spreadAngle = (i - 1) * 0.3; // More spread than triple shot var finalAngle = Math.atan2(normalY, normalX) + spreadAngle; var finalNormalX = Math.cos(finalAngle); var finalNormalY = Math.sin(finalAngle); var enemyArrow = new EnemyArrow(); enemyArrow.x = self.x; enemyArrow.y = self.y; enemyArrow.speedX = finalNormalX * 10; enemyArrow.speedY = finalNormalY * 10; enemyArrow.rotation = finalAngle; enemyArrows.push(enemyArrow); game.addChild(enemyArrow); } } }; return self; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.shootTimer = 0; self.shootRate = 120 + Math.random() * 60; // Random shooting interval self.update = function () { // Enemies don't move, they stay in place and shoot self.shootTimer++; if (self.shootTimer >= self.shootRate) { self.shootTimer = 0; // Shoot at player var dirX = archer.x - self.x; var dirY = archer.y - self.y; var distance = Math.sqrt(dirX * dirX + dirY * dirY); var normalX = dirX / distance; var normalY = dirY / distance; // Make enemy face the shooting direction self.rotation = Math.atan2(normalY, normalX); var enemyArrow = new EnemyArrow(); enemyArrow.x = self.x; enemyArrow.y = self.y; enemyArrow.speedX = normalX * 8; enemyArrow.speedY = normalY * 8; enemyArrow.rotation = Math.atan2(normalY, normalX); enemyArrows.push(enemyArrow); game.addChild(enemyArrow); } }; return self; }); var EnemyArrow = Container.expand(function () { var self = Container.call(this); var arrowGraphics = self.attachAsset('enemyArrow', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = 0; self.speedY = 0; self.update = function () { self.x += self.speedX; self.y += self.speedY; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var archer = game.addChild(new Archer()); archer.x = 150; archer.y = 2732 / 2; var arrows = []; var enemies = []; var enemyArrows = []; var enemySpawnTimer = 0; var enemySpawnRate = 120; // frames between spawns var playerHealth = 10; var maxEnemies = 1; // Start with 1 enemy, increase over time var energy = 100; var energyRegenTimer = 0; var isShooting = false; var shootingTimer = 0; var scoreTxt = new Text2('0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.setText(LK.getScore()); var energyTxt = new Text2('Energy: 100', { size: 80, fill: 0x00ff00 }); energyTxt.anchor.set(1, 0); LK.gui.topRight.addChild(energyTxt); energyTxt.x = -20; energyTxt.y = 20; var healthTxt = new Text2('Health: 10', { size: 80, fill: 0xff0000 }); healthTxt.anchor.set(0, 0); LK.gui.topLeft.addChild(healthTxt); healthTxt.x = 120; // Avoid the platform menu icon healthTxt.y = 20; var autoShootTimer = 0; var autoBattleActive = false; // Create hack mode button var autoBattleButton = new Text2('HACK MODE', { size: 80, fill: 0xff0000 }); autoBattleButton.anchor.set(0.5, 1); LK.gui.bottom.addChild(autoBattleButton); autoBattleButton.y = -50; // Create triple shot toggle button var tripleShootButton = new Text2('TRIPLE SHOOT: OFF', { size: 60, fill: 0xff0000 }); tripleShootButton.anchor.set(0.5, 1); LK.gui.bottom.addChild(tripleShootButton); tripleShootButton.y = -150; // Button click handler autoBattleButton.down = function (x, y, obj) { autoBattleActive = !autoBattleActive; if (autoBattleActive) { autoBattleButton.setText('STOP HACK'); autoBattleButton.tint = 0x00ff00; // Green when active } else { autoBattleButton.setText('HACK MODE'); autoBattleButton.tint = 0xff0000; // Red when inactive } ; }; // Triple shoot variables var tripleShootActive = false; var tripleShootTimer = 0; var boss = null; var bossHealth = 10; var bossSpawnScore = 200; // Triple shoot button click handler tripleShootButton.down = function (x, y, obj) { tripleShootActive = !tripleShootActive; if (tripleShootActive) { tripleShootButton.setText('TRIPLE SHOOT: ON'); tripleShootButton.tint = 0x00ff00; // Green when active } else { tripleShootButton.setText('TRIPLE SHOOT: OFF'); tripleShootButton.tint = 0xff0000; // Red when inactive } }; // Manual shooting - touch screen to shoot game.down = function (x, y, obj) { // Only allow manual shooting when hack mode is not active if (!autoBattleActive && energy > 0) { // Convert touch position to game coordinates // Check if obj and obj.parent exist before calling toGlobal if (obj && obj.parent && obj.parent.toGlobal) { var gamePos = game.toLocal(obj.parent.toGlobal({ x: x, y: y })); shootArrowAtTarget(gamePos.x, gamePos.y); } else { // Fallback: use x, y directly as they should already be in the correct coordinate system shootArrowAtTarget(x, y); } } }; function shootArrowAtTarget(targetX, targetY) { // Check if player has enough energy if (energy <= 0) { return; } // Calculate direction from archer to target point var dirX = targetX - archer.x; var dirY = targetY - archer.y; var distance = Math.sqrt(dirX * dirX + dirY * dirY); // Normalize direction var normalX = dirX / distance; var normalY = dirY / distance; // Calculate base angle for arrow direction var baseAngle = Math.atan2(normalY, normalX); // Make archer face the shooting direction archer.rotation = baseAngle; // Fire arrows - either 1 or 3 depending on triple shoot mode var arrowCount = tripleShootActive ? 3 : 1; var energyCost = tripleShootActive ? 6 : 2; // Check if we have enough energy for the shot type if (energy < energyCost) { return; } for (var i = 0; i < arrowCount; i++) { // Add spread for triple shot var spreadAngle = 0; if (tripleShootActive) { spreadAngle = (i - 1) * 0.2; // -0.2, 0, 0.2 radians spread } var finalAngle = baseAngle + spreadAngle; var finalNormalX = Math.cos(finalAngle); var finalNormalY = Math.sin(finalAngle); // Create arrow var newArrow = new Arrow(); newArrow.x = archer.x; newArrow.y = archer.y; newArrow.speedX = finalNormalX * 15; newArrow.speedY = finalNormalY * 15; // Rotate arrow to face direction newArrow.rotation = finalAngle; arrows.push(newArrow); game.addChild(newArrow); } LK.getSound('shoot').play(); // Decrease energy energy -= energyCost; // Set shooting state isShooting = true; shootingTimer = 0; // Update energy display energyTxt.setText('Energy: ' + energy); // Change color based on energy level if (energy <= 20) { energyTxt.tint = 0xff0000; // Red when low } else if (energy <= 50) { energyTxt.tint = 0xffff00; // Yellow when medium } else { energyTxt.tint = 0x00ff00; // Green when high } } game.update = function () { // Automatic shooting logic - only when hack mode is active if (autoBattleActive) { autoShootTimer++; if (autoShootTimer >= 15) { // Shoot every 0.25 seconds (faster rate for hack mode) autoShootTimer = 0; // Shoot at boss first if present, then at all enemies var targets = []; if (boss) { targets.push(boss); } for (var e = 0; e < enemies.length; e++) { if (enemies[e]) { targets.push(enemies[e]); } } for (var t = 0; t < targets.length; t++) { var target = targets[t]; // Calculate direction from archer to target var dirX = target.x - archer.x; var dirY = target.y - archer.y; var distance = Math.sqrt(dirX * dirX + dirY * dirY); // Normalize direction var normalX = dirX / distance; var normalY = dirY / distance; // Make archer face the shooting direction archer.rotation = Math.atan2(normalY, normalX); // Create arrow without energy cost var newArrow = new Arrow(); newArrow.x = archer.x; newArrow.y = archer.y; newArrow.speedX = normalX * 15; newArrow.speedY = normalY * 15; // Rotate arrow to face direction newArrow.rotation = Math.atan2(normalY, normalX); arrows.push(newArrow); game.addChild(newArrow); } // Play shoot sound if we shot any arrows if (targets.length > 0) { LK.getSound('shoot').play(); } } } // Update shooting timer if (isShooting) { shootingTimer++; if (shootingTimer >= 30) { // Stop shooting state after 0.5 seconds isShooting = false; } } // Update energy regeneration only when not shooting (every 60 frames = 1 second at 60 FPS) if (!isShooting) { energyRegenTimer++; if (energyRegenTimer >= 60) { energyRegenTimer = 0; if (energy < 100) { energy += 1; // Update energy display energyTxt.setText('Energy: ' + energy); // Change color based on energy level if (energy <= 20) { energyTxt.tint = 0xff0000; // Red when low } else if (energy <= 50) { energyTxt.tint = 0xffff00; // Yellow when medium } else { energyTxt.tint = 0x00ff00; // Green when high } } } } else { energyRegenTimer = 0; // Reset regen timer when shooting } // Spawn enemies randomly on screen when needed (only when no boss is active) if (!boss && enemies.length < maxEnemies) { enemySpawnTimer++; if (enemySpawnTimer >= enemySpawnRate) { enemySpawnTimer = 0; // Spawn new enemy at random position var newEnemy = new Enemy(); newEnemy.x = Math.random() * (2048 - 200) + 100; newEnemy.y = Math.random() * (2732 - 200) + 100; // Make sure enemy doesn't spawn too close to archer var distToArcher = Math.sqrt(Math.pow(newEnemy.x - archer.x, 2) + Math.pow(newEnemy.y - archer.y, 2)); if (distToArcher < 200) { // Respawn farther away newEnemy.x = Math.random() * (2048 - 400) + 200; if (newEnemy.x > archer.x - 200 && newEnemy.x < archer.x + 200) { newEnemy.x += 300; } } enemies.push(newEnemy); game.addChild(newEnemy); } } // Update arrows for (var i = arrows.length - 1; i >= 0; i--) { var arrow = arrows[i]; // Remove arrows that hit walls or go off screen if (arrow.x >= 2048 || arrow.x <= 0 || arrow.y >= 2732 || arrow.y <= 0) { arrow.destroy(); arrows.splice(i, 1); continue; } // Check arrow-enemy arrow collisions var arrowDestroyed = false; for (var k = enemyArrows.length - 1; k >= 0; k--) { var enemyArrow = enemyArrows[k]; if (arrow && enemyArrow && arrow.intersects(enemyArrow)) { // Both arrows destroy each other arrow.destroy(); arrows.splice(i, 1); enemyArrow.destroy(); enemyArrows.splice(k, 1); arrowDestroyed = true; break; } } // Skip enemy collision check if arrow was destroyed by enemy arrow if (arrowDestroyed) { continue; } // Check arrow-enemy collisions for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (enemy && arrow && arrow.intersects(enemy)) { // Hit enemy LK.setScore(LK.getScore() + 10); scoreTxt.setText(LK.getScore()); LK.getSound('hit').play(); LK.effects.flashObject(enemy, 0xff0000, 200); // Remove arrow and enemy arrow.destroy(); arrows.splice(i, 1); enemy.destroy(); enemies.splice(j, 1); break; } } // Check arrow-boss collision if (boss && arrow && arrow.intersects(boss)) { // Hit boss boss.health--; LK.setScore(LK.getScore() + 20); scoreTxt.setText(LK.getScore()); LK.getSound('hit').play(); LK.effects.flashObject(boss, 0xff0000, 300); // Remove arrow arrow.destroy(); arrows.splice(i, 1); // Boss moves to new position when hit boss.moveToNewPosition(); // Check if boss is defeated if (boss.health <= 0) { LK.setScore(LK.getScore() + 100); // Bonus points for defeating boss scoreTxt.setText(LK.getScore()); boss.destroy(); boss = null; bossSpawnScore += 200; // Next boss spawns after another 200 points } break; } } // Update enemy arrows for (var m = enemyArrows.length - 1; m >= 0; m--) { var enemyArrow = enemyArrows[m]; // Remove arrows that hit walls or go off screen if (enemyArrow.x >= 2048 || enemyArrow.x <= 0 || enemyArrow.y >= 2732 || enemyArrow.y <= 0) { enemyArrow.destroy(); enemyArrows.splice(m, 1); continue; } // Check if enemy arrow hits player if (enemyArrow.intersects(archer)) { playerHealth--; healthTxt.setText('Health: ' + playerHealth); LK.getSound('playerHit').play(); LK.effects.flashObject(archer, 0xff0000, 300); enemyArrow.destroy(); enemyArrows.splice(m, 1); // Check if player is dead if (playerHealth <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } continue; } } // Check if hack mode is active and score exceeds 200 to show HACKER text if (autoBattleActive && LK.getScore() > 200) { // Create red HACKER text if it doesn't exist if (!game.hackerText) { game.hackerText = new Text2('HACKER', { size: 200, fill: 0xff0000 }); game.hackerText.anchor.set(0.5, 0.5); game.hackerText.x = 2048 / 2; game.hackerText.y = 2732 / 2; game.addChild(game.hackerText); // Apply pulsing red glow effect tween(game.hackerText, { alpha: 0.3 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { tween(game.hackerText, { alpha: 1 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { // Restart the pulsing effect if (game.hackerText) { tween(game.hackerText, { alpha: 0.3 }, { duration: 500, easing: tween.easeInOut, onFinish: arguments.callee.caller }); } } }); } }); } } else if (game.hackerText) { // Remove HACKER text if conditions not met game.hackerText.destroy(); game.hackerText = null; } // Spawn boss every 200 points if (boss === null && LK.getScore() >= bossSpawnScore) { // Clear all existing enemies when boss spawns for (var e = enemies.length - 1; e >= 0; e--) { enemies[e].destroy(); enemies.splice(e, 1); } boss = new Boss(); boss.x = Math.random() * (2048 - 400) + 200; boss.y = Math.random() * (2732 - 400) + 200; // Make sure boss doesn't spawn too close to archer var distToArcher = Math.sqrt(Math.pow(boss.x - archer.x, 2) + Math.pow(boss.y - archer.y, 2)); if (distToArcher < 300) { boss.x = Math.random() * (2048 - 600) + 300; if (boss.x > archer.x - 300 && boss.x < archer.x + 300) { boss.x += 400; } } boss.health = 10; game.addChild(boss); } // When enemy dies, increase max enemies and spawn rate for difficulty if (LK.getScore() > 0 && LK.getScore() % 50 === 0) { if (maxEnemies < 5) { maxEnemies++; } if (enemySpawnRate > 30) { enemySpawnRate -= 5; } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Archer = Container.expand(function () {
var self = Container.call(this);
var archerGraphics = self.attachAsset('archer', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Arrow = Container.expand(function () {
var self = Container.call(this);
var arrowGraphics = self.attachAsset('arrow', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 0;
self.speedY = 0;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
};
return self;
});
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.health = 10;
self.shootTimer = 0;
self.shootRate = 60; // Faster shooting than regular enemies
self.moveToNewPosition = function () {
var newX = Math.random() * (2048 - 400) + 200;
var newY = Math.random() * (2732 - 400) + 200;
// Make sure boss doesn't spawn too close to archer
var distToArcher = Math.sqrt(Math.pow(newX - archer.x, 2) + Math.pow(newY - archer.y, 2));
if (distToArcher < 300) {
newX = Math.random() * (2048 - 600) + 300;
if (newX > archer.x - 300 && newX < archer.x + 300) {
newX += 400;
}
}
// Animate movement to new position
tween(self, {
x: newX,
y: newY
}, {
duration: 800,
easing: tween.easeInOut
});
};
self.update = function () {
self.shootTimer++;
if (self.shootTimer >= self.shootRate) {
self.shootTimer = 0;
// Shoot at player
var dirX = archer.x - self.x;
var dirY = archer.y - self.y;
var distance = Math.sqrt(dirX * dirX + dirY * dirY);
var normalX = dirX / distance;
var normalY = dirY / distance;
// Make boss face the shooting direction
self.rotation = Math.atan2(normalY, normalX);
// Boss shoots 3 arrows at once
for (var i = 0; i < 3; i++) {
var spreadAngle = (i - 1) * 0.3; // More spread than triple shot
var finalAngle = Math.atan2(normalY, normalX) + spreadAngle;
var finalNormalX = Math.cos(finalAngle);
var finalNormalY = Math.sin(finalAngle);
var enemyArrow = new EnemyArrow();
enemyArrow.x = self.x;
enemyArrow.y = self.y;
enemyArrow.speedX = finalNormalX * 10;
enemyArrow.speedY = finalNormalY * 10;
enemyArrow.rotation = finalAngle;
enemyArrows.push(enemyArrow);
game.addChild(enemyArrow);
}
}
};
return self;
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.shootTimer = 0;
self.shootRate = 120 + Math.random() * 60; // Random shooting interval
self.update = function () {
// Enemies don't move, they stay in place and shoot
self.shootTimer++;
if (self.shootTimer >= self.shootRate) {
self.shootTimer = 0;
// Shoot at player
var dirX = archer.x - self.x;
var dirY = archer.y - self.y;
var distance = Math.sqrt(dirX * dirX + dirY * dirY);
var normalX = dirX / distance;
var normalY = dirY / distance;
// Make enemy face the shooting direction
self.rotation = Math.atan2(normalY, normalX);
var enemyArrow = new EnemyArrow();
enemyArrow.x = self.x;
enemyArrow.y = self.y;
enemyArrow.speedX = normalX * 8;
enemyArrow.speedY = normalY * 8;
enemyArrow.rotation = Math.atan2(normalY, normalX);
enemyArrows.push(enemyArrow);
game.addChild(enemyArrow);
}
};
return self;
});
var EnemyArrow = Container.expand(function () {
var self = Container.call(this);
var arrowGraphics = self.attachAsset('enemyArrow', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 0;
self.speedY = 0;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var archer = game.addChild(new Archer());
archer.x = 150;
archer.y = 2732 / 2;
var arrows = [];
var enemies = [];
var enemyArrows = [];
var enemySpawnTimer = 0;
var enemySpawnRate = 120; // frames between spawns
var playerHealth = 10;
var maxEnemies = 1; // Start with 1 enemy, increase over time
var energy = 100;
var energyRegenTimer = 0;
var isShooting = false;
var shootingTimer = 0;
var scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.setText(LK.getScore());
var energyTxt = new Text2('Energy: 100', {
size: 80,
fill: 0x00ff00
});
energyTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(energyTxt);
energyTxt.x = -20;
energyTxt.y = 20;
var healthTxt = new Text2('Health: 10', {
size: 80,
fill: 0xff0000
});
healthTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthTxt);
healthTxt.x = 120; // Avoid the platform menu icon
healthTxt.y = 20;
var autoShootTimer = 0;
var autoBattleActive = false;
// Create hack mode button
var autoBattleButton = new Text2('HACK MODE', {
size: 80,
fill: 0xff0000
});
autoBattleButton.anchor.set(0.5, 1);
LK.gui.bottom.addChild(autoBattleButton);
autoBattleButton.y = -50;
// Create triple shot toggle button
var tripleShootButton = new Text2('TRIPLE SHOOT: OFF', {
size: 60,
fill: 0xff0000
});
tripleShootButton.anchor.set(0.5, 1);
LK.gui.bottom.addChild(tripleShootButton);
tripleShootButton.y = -150;
// Button click handler
autoBattleButton.down = function (x, y, obj) {
autoBattleActive = !autoBattleActive;
if (autoBattleActive) {
autoBattleButton.setText('STOP HACK');
autoBattleButton.tint = 0x00ff00; // Green when active
} else {
autoBattleButton.setText('HACK MODE');
autoBattleButton.tint = 0xff0000; // Red when inactive
}
;
};
// Triple shoot variables
var tripleShootActive = false;
var tripleShootTimer = 0;
var boss = null;
var bossHealth = 10;
var bossSpawnScore = 200;
// Triple shoot button click handler
tripleShootButton.down = function (x, y, obj) {
tripleShootActive = !tripleShootActive;
if (tripleShootActive) {
tripleShootButton.setText('TRIPLE SHOOT: ON');
tripleShootButton.tint = 0x00ff00; // Green when active
} else {
tripleShootButton.setText('TRIPLE SHOOT: OFF');
tripleShootButton.tint = 0xff0000; // Red when inactive
}
};
// Manual shooting - touch screen to shoot
game.down = function (x, y, obj) {
// Only allow manual shooting when hack mode is not active
if (!autoBattleActive && energy > 0) {
// Convert touch position to game coordinates
// Check if obj and obj.parent exist before calling toGlobal
if (obj && obj.parent && obj.parent.toGlobal) {
var gamePos = game.toLocal(obj.parent.toGlobal({
x: x,
y: y
}));
shootArrowAtTarget(gamePos.x, gamePos.y);
} else {
// Fallback: use x, y directly as they should already be in the correct coordinate system
shootArrowAtTarget(x, y);
}
}
};
function shootArrowAtTarget(targetX, targetY) {
// Check if player has enough energy
if (energy <= 0) {
return;
}
// Calculate direction from archer to target point
var dirX = targetX - archer.x;
var dirY = targetY - archer.y;
var distance = Math.sqrt(dirX * dirX + dirY * dirY);
// Normalize direction
var normalX = dirX / distance;
var normalY = dirY / distance;
// Calculate base angle for arrow direction
var baseAngle = Math.atan2(normalY, normalX);
// Make archer face the shooting direction
archer.rotation = baseAngle;
// Fire arrows - either 1 or 3 depending on triple shoot mode
var arrowCount = tripleShootActive ? 3 : 1;
var energyCost = tripleShootActive ? 6 : 2;
// Check if we have enough energy for the shot type
if (energy < energyCost) {
return;
}
for (var i = 0; i < arrowCount; i++) {
// Add spread for triple shot
var spreadAngle = 0;
if (tripleShootActive) {
spreadAngle = (i - 1) * 0.2; // -0.2, 0, 0.2 radians spread
}
var finalAngle = baseAngle + spreadAngle;
var finalNormalX = Math.cos(finalAngle);
var finalNormalY = Math.sin(finalAngle);
// Create arrow
var newArrow = new Arrow();
newArrow.x = archer.x;
newArrow.y = archer.y;
newArrow.speedX = finalNormalX * 15;
newArrow.speedY = finalNormalY * 15;
// Rotate arrow to face direction
newArrow.rotation = finalAngle;
arrows.push(newArrow);
game.addChild(newArrow);
}
LK.getSound('shoot').play();
// Decrease energy
energy -= energyCost;
// Set shooting state
isShooting = true;
shootingTimer = 0;
// Update energy display
energyTxt.setText('Energy: ' + energy);
// Change color based on energy level
if (energy <= 20) {
energyTxt.tint = 0xff0000; // Red when low
} else if (energy <= 50) {
energyTxt.tint = 0xffff00; // Yellow when medium
} else {
energyTxt.tint = 0x00ff00; // Green when high
}
}
game.update = function () {
// Automatic shooting logic - only when hack mode is active
if (autoBattleActive) {
autoShootTimer++;
if (autoShootTimer >= 15) {
// Shoot every 0.25 seconds (faster rate for hack mode)
autoShootTimer = 0;
// Shoot at boss first if present, then at all enemies
var targets = [];
if (boss) {
targets.push(boss);
}
for (var e = 0; e < enemies.length; e++) {
if (enemies[e]) {
targets.push(enemies[e]);
}
}
for (var t = 0; t < targets.length; t++) {
var target = targets[t];
// Calculate direction from archer to target
var dirX = target.x - archer.x;
var dirY = target.y - archer.y;
var distance = Math.sqrt(dirX * dirX + dirY * dirY);
// Normalize direction
var normalX = dirX / distance;
var normalY = dirY / distance;
// Make archer face the shooting direction
archer.rotation = Math.atan2(normalY, normalX);
// Create arrow without energy cost
var newArrow = new Arrow();
newArrow.x = archer.x;
newArrow.y = archer.y;
newArrow.speedX = normalX * 15;
newArrow.speedY = normalY * 15;
// Rotate arrow to face direction
newArrow.rotation = Math.atan2(normalY, normalX);
arrows.push(newArrow);
game.addChild(newArrow);
}
// Play shoot sound if we shot any arrows
if (targets.length > 0) {
LK.getSound('shoot').play();
}
}
}
// Update shooting timer
if (isShooting) {
shootingTimer++;
if (shootingTimer >= 30) {
// Stop shooting state after 0.5 seconds
isShooting = false;
}
}
// Update energy regeneration only when not shooting (every 60 frames = 1 second at 60 FPS)
if (!isShooting) {
energyRegenTimer++;
if (energyRegenTimer >= 60) {
energyRegenTimer = 0;
if (energy < 100) {
energy += 1;
// Update energy display
energyTxt.setText('Energy: ' + energy);
// Change color based on energy level
if (energy <= 20) {
energyTxt.tint = 0xff0000; // Red when low
} else if (energy <= 50) {
energyTxt.tint = 0xffff00; // Yellow when medium
} else {
energyTxt.tint = 0x00ff00; // Green when high
}
}
}
} else {
energyRegenTimer = 0; // Reset regen timer when shooting
}
// Spawn enemies randomly on screen when needed (only when no boss is active)
if (!boss && enemies.length < maxEnemies) {
enemySpawnTimer++;
if (enemySpawnTimer >= enemySpawnRate) {
enemySpawnTimer = 0;
// Spawn new enemy at random position
var newEnemy = new Enemy();
newEnemy.x = Math.random() * (2048 - 200) + 100;
newEnemy.y = Math.random() * (2732 - 200) + 100;
// Make sure enemy doesn't spawn too close to archer
var distToArcher = Math.sqrt(Math.pow(newEnemy.x - archer.x, 2) + Math.pow(newEnemy.y - archer.y, 2));
if (distToArcher < 200) {
// Respawn farther away
newEnemy.x = Math.random() * (2048 - 400) + 200;
if (newEnemy.x > archer.x - 200 && newEnemy.x < archer.x + 200) {
newEnemy.x += 300;
}
}
enemies.push(newEnemy);
game.addChild(newEnemy);
}
}
// Update arrows
for (var i = arrows.length - 1; i >= 0; i--) {
var arrow = arrows[i];
// Remove arrows that hit walls or go off screen
if (arrow.x >= 2048 || arrow.x <= 0 || arrow.y >= 2732 || arrow.y <= 0) {
arrow.destroy();
arrows.splice(i, 1);
continue;
}
// Check arrow-enemy arrow collisions
var arrowDestroyed = false;
for (var k = enemyArrows.length - 1; k >= 0; k--) {
var enemyArrow = enemyArrows[k];
if (arrow && enemyArrow && arrow.intersects(enemyArrow)) {
// Both arrows destroy each other
arrow.destroy();
arrows.splice(i, 1);
enemyArrow.destroy();
enemyArrows.splice(k, 1);
arrowDestroyed = true;
break;
}
}
// Skip enemy collision check if arrow was destroyed by enemy arrow
if (arrowDestroyed) {
continue;
}
// Check arrow-enemy collisions
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (enemy && arrow && arrow.intersects(enemy)) {
// Hit enemy
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
LK.getSound('hit').play();
LK.effects.flashObject(enemy, 0xff0000, 200);
// Remove arrow and enemy
arrow.destroy();
arrows.splice(i, 1);
enemy.destroy();
enemies.splice(j, 1);
break;
}
}
// Check arrow-boss collision
if (boss && arrow && arrow.intersects(boss)) {
// Hit boss
boss.health--;
LK.setScore(LK.getScore() + 20);
scoreTxt.setText(LK.getScore());
LK.getSound('hit').play();
LK.effects.flashObject(boss, 0xff0000, 300);
// Remove arrow
arrow.destroy();
arrows.splice(i, 1);
// Boss moves to new position when hit
boss.moveToNewPosition();
// Check if boss is defeated
if (boss.health <= 0) {
LK.setScore(LK.getScore() + 100); // Bonus points for defeating boss
scoreTxt.setText(LK.getScore());
boss.destroy();
boss = null;
bossSpawnScore += 200; // Next boss spawns after another 200 points
}
break;
}
}
// Update enemy arrows
for (var m = enemyArrows.length - 1; m >= 0; m--) {
var enemyArrow = enemyArrows[m];
// Remove arrows that hit walls or go off screen
if (enemyArrow.x >= 2048 || enemyArrow.x <= 0 || enemyArrow.y >= 2732 || enemyArrow.y <= 0) {
enemyArrow.destroy();
enemyArrows.splice(m, 1);
continue;
}
// Check if enemy arrow hits player
if (enemyArrow.intersects(archer)) {
playerHealth--;
healthTxt.setText('Health: ' + playerHealth);
LK.getSound('playerHit').play();
LK.effects.flashObject(archer, 0xff0000, 300);
enemyArrow.destroy();
enemyArrows.splice(m, 1);
// Check if player is dead
if (playerHealth <= 0) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
continue;
}
}
// Check if hack mode is active and score exceeds 200 to show HACKER text
if (autoBattleActive && LK.getScore() > 200) {
// Create red HACKER text if it doesn't exist
if (!game.hackerText) {
game.hackerText = new Text2('HACKER', {
size: 200,
fill: 0xff0000
});
game.hackerText.anchor.set(0.5, 0.5);
game.hackerText.x = 2048 / 2;
game.hackerText.y = 2732 / 2;
game.addChild(game.hackerText);
// Apply pulsing red glow effect
tween(game.hackerText, {
alpha: 0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(game.hackerText, {
alpha: 1
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart the pulsing effect
if (game.hackerText) {
tween(game.hackerText, {
alpha: 0.3
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: arguments.callee.caller
});
}
}
});
}
});
}
} else if (game.hackerText) {
// Remove HACKER text if conditions not met
game.hackerText.destroy();
game.hackerText = null;
}
// Spawn boss every 200 points
if (boss === null && LK.getScore() >= bossSpawnScore) {
// Clear all existing enemies when boss spawns
for (var e = enemies.length - 1; e >= 0; e--) {
enemies[e].destroy();
enemies.splice(e, 1);
}
boss = new Boss();
boss.x = Math.random() * (2048 - 400) + 200;
boss.y = Math.random() * (2732 - 400) + 200;
// Make sure boss doesn't spawn too close to archer
var distToArcher = Math.sqrt(Math.pow(boss.x - archer.x, 2) + Math.pow(boss.y - archer.y, 2));
if (distToArcher < 300) {
boss.x = Math.random() * (2048 - 600) + 300;
if (boss.x > archer.x - 300 && boss.x < archer.x + 300) {
boss.x += 400;
}
}
boss.health = 10;
game.addChild(boss);
}
// When enemy dies, increase max enemies and spawn rate for difficulty
if (LK.getScore() > 0 && LK.getScore() % 50 === 0) {
if (maxEnemies < 5) {
maxEnemies++;
}
if (enemySpawnRate > 30) {
enemySpawnRate -= 5;
}
}
};