User prompt
yazıyı tam ortala
User prompt
Sadece hp yazısının orda yeşil bar olsun
User prompt
Boss hp barı hatalı yerde düzelt
User prompt
Sadece yazının göründüğü yere kadar yap boss barını
User prompt
Boss hp barı çok küçük düzelt
User prompt
Boss hp barı boss un üstünde olsun
User prompt
bosslara hp barı ekle. Hp barı yeşil olsun. Can sayısı siyah renk olsun
User prompt
Boss hp barını kaldır
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'bullet.update(); // Update bullet position' Line Number: 1112
User prompt
100 lv boss un 500 hp si olsun. İlk boss un hp si 5 olucak ona göre dengele.
User prompt
Bossun canı çok fazla düzelt
User prompt
Boss hp barı çok büyük
User prompt
Hatar vurunca boss un canı 9999999 görünüyor
User prompt
Boss can barı hatalı görünüyor hasar vurunca
User prompt
Uzaylılar çok hızlı düzelt. Ölünce checkpoint sıfırlanmıyor düzelt
User prompt
Oyun donuyor düzelt
User prompt
Ateş etme sesini kaldır
User prompt
Ateş etme sesi sürekli gelsin
User prompt
Ateş etme sesini 3 saniyede bir uygula. Sesi çok fazla sesini azalt. Müzikle karışmasın ses. Müzik ön planda olucak.
User prompt
Oyuna müzik ekle
User prompt
5 5 10 12.6 15 20.3 20 28 25 35.6 30 43.2 35 50.9 40 58.5 45 66.1 50 73.8 55 81.4 60 89 65 96.7 70 104.3 75 111.9 80 119.6 85 127.2 90 134.8 95 142.5 100 150 boss canlarını böyle ayarla
User prompt
Hala eski lv sisteminde düzelt
User prompt
Level 01: 5 düşman Level 02: 7 düşman Level 03: 9 düşman Level 04: 10 düşman Level 05: 12 düşman Level 06: 14 düşman Level 07: 16 düşman Level 08: 17 düşman Level 09: 19 düşman Level 10: 21 düşman Level 11: 23 düşman Level 12: 24 düşman Level 13: 26 düşman Level 14: 28 düşman Level 15: 30 düşman Level 16: 31 düşman Level 17: 33 düşman Level 18: 35 düşman Level 19: 37 düşman Level 20: 38 düşman Level 21: 40 düşman Level 22: 42 düşman Level 23: 44 düşman Level 24: 45 düşman Level 25: 47 düşman Level 26: 49 düşman Level 27: 51 düşman Level 28: 52 düşman Level 29: 54 düşman Level 30: 56 düşman Level 31: 58 düşman Level 32: 59 düşman Level 33: 61 düşman Level 34: 63 düşman Level 35: 65 düşman Level 36: 66 düşman Level 37: 68 düşman Level 38: 70 düşman Level 39: 72 düşman Level 40: 73 düşman Level 41: 75 düşman Level 42: 77 düşman Level 43: 79 düşman Level 44: 80 düşman Level 45: 82 düşman Level 46: 84 düşman Level 47: 86 düşman Level 48: 87 düşman Level 49: 89 düşman Level 50: 91 düşman Level 51: 93 düşman Level 52: 94 düşman Level 53: 96 düşman Level 54: 98 düşman Level 55: 100 düşman Level 56: 101 düşman Level 57: 103 düşman Level 58: 105 düşman Level 59: 107 düşman Level 60: 108 düşman Level 61: 110 düşman Level 62: 112 düşman Level 63: 114 düşman Level 64: 115 düşman Level 65: 117 düşman Level 66: 119 düşman Level 67: 121 düşman Level 68: 122 düşman Level 69: 124 düşman Level 70: 126 düşman Level 71: 128 düşman Level 72: 129 düşman Level 73: 131 düşman Level 74: 133 düşman Level 75: 135 düşman Level 76: 136 düşman Level 77: 138 düşman Level 78: 140 düşman Level 79: 142 düşman Level 80: 143 düşman Level 81: 145 düşman Level 82: 147 düşman Level 83: 149 düşman Level 84: 150 düşman Level 85: 150 düşman Level 86: 150 düşman Level 87: 150 düşman Level 88: 150 düşman Level 89: 150 düşman Level 90: 150 düşman Level 91: 150 düşman Level 92: 150 düşman Level 93: 150 düşman Level 94: 150 düşman Level 95: 150 düşman Level 96: 150 düşman Level 97: 150 düşman Level 98: 150 düşman Level 99: 150 düşman Level 100: 150 düşman Lv i böyle ayarla
User prompt
Düşmanlar daha hızlı gelmesin
User prompt
Düşmanlar daha hızlı gelsin
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossNumber = Math.ceil(currentLevel / 10);
var assetName = bossNumber === 1 ? 'boss' : 'boss' + bossNumber;
var graphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
// Boss health scaling based on specific progression table
function getBossHealthForLevel(level) {
if (level <= 5) return 5;
if (level <= 10) return 12.6;
if (level <= 15) return 20.3;
if (level <= 20) return 28;
if (level <= 25) return 35.6;
if (level <= 30) return 43.2;
if (level <= 35) return 50.9;
if (level <= 40) return 58.5;
if (level <= 45) return 66.1;
if (level <= 50) return 73.8;
if (level <= 55) return 81.4;
if (level <= 60) return 89;
if (level <= 65) return 96.7;
if (level <= 70) return 104.3;
if (level <= 75) return 111.9;
if (level <= 80) return 119.6;
if (level <= 85) return 127.2;
if (level <= 90) return 134.8;
if (level <= 95) return 142.5;
if (level <= 100) return 150;
return 150; // Default fallback
}
self.maxHealth = getBossHealthForLevel(currentLevel);
self.health = self.maxHealth;
self.lastShot = 0;
self.shootCooldown = 180; // 3 seconds at 60fps
self.direction = 1;
self.defeated = false;
self.update = function () {
// Boss movement pattern
self.x += self.speed * self.direction;
if (self.x <= 200 || self.x >= 1848) {
self.direction *= -1;
}
// Boss shooting pattern - can shoot back-to-back
self.lastShot++;
if (self.lastShot >= self.shootCooldown) {
self.lastShot = Math.max(0, self.shootCooldown - 120); // Allow back-to-back shooting by reducing cooldown
// Shoot 3 bullets at the same position
for (var i = 0; i < 3; i++) {
var bullet = new EnemyBullet();
bullet.x = self.x;
bullet.y = self.y + 75;
enemyBullets.push(bullet);
game.addChild(bullet);
}
}
};
return self;
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1.5;
self.health = 1;
self.lastShot = 0;
self.shootCooldown = 120; // 2 seconds at 60fps for balanced shooting
self.direction = Math.random() < 0.5 ? -1 : 1; // Random initial direction
self.horizontalSpeed = 2;
self.update = function () {
self.y += self.speed;
// Horizontal movement with direction changes
self.x += self.horizontalSpeed * self.direction;
// Change direction when hitting screen edges or randomly
if (self.x <= 200 || self.x >= 1848 || Math.random() < 0.005) {
self.direction *= -1;
}
// Shoot at player occasionally - single shot only
self.lastShot++;
if (self.lastShot >= self.shootCooldown && Math.random() < 0.08) {
self.lastShot = 0; // Reset cooldown completely to prevent back-to-back shooting
var bullet = new EnemyBullet();
bullet.x = self.x;
bullet.y = self.y + 30;
enemyBullets.push(bullet);
game.addChild(bullet);
}
};
return self;
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('enemyBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = maxPlayerHealth;
self.maxHealth = maxPlayerHealth;
self.lastShot = 0;
self.invulnerable = false;
self.invulnerableTimer = 0;
self.shoot = function () {
if (self.lastShot > 0) return;
self.lastShot = getShootCooldown();
// Shooting sound removed
if (currentLevel >= 80) {
// Rapid fire - single bullet but faster
var bullet = new PlayerBullet();
bullet.x = self.x;
bullet.y = self.y - 40;
playerBullets.push(bullet);
game.addChild(bullet);
} else if (currentLevel >= 50) {
// Triple fire
for (var i = -1; i <= 1; i++) {
var bullet = new PlayerBullet();
bullet.x = self.x + i * 25;
bullet.y = self.y - 40;
playerBullets.push(bullet);
game.addChild(bullet);
}
} else if (currentLevel >= 20) {
// Dual fire
for (var i = -1; i <= 1; i += 2) {
var bullet = new PlayerBullet();
bullet.x = self.x + i * 20;
bullet.y = self.y - 40;
playerBullets.push(bullet);
game.addChild(bullet);
}
} else {
// Single fire
var bullet = new PlayerBullet();
bullet.x = self.x;
bullet.y = self.y - 40;
playerBullets.push(bullet);
game.addChild(bullet);
}
};
self.takeDamage = function () {
if (self.invulnerable) return;
self.health--;
self.invulnerable = true;
self.invulnerableTimer = 120; // 2 seconds invulnerability
LK.getSound('playerHit').play();
LK.effects.flashObject(self, 0xff0000, 500);
if (self.health <= 0) {
playerLives--;
storage.playerLives = playerLives;
self.health = self.maxHealth; // Reset health for next life
if (playerLives <= 0) {
LK.showGameOver();
} else {
// Respawn at starting position
self.x = 1024;
self.y = 2400;
// Restore from last checkpoint
var checkpointScore = storage.checkpointScore || 0;
var checkpointLevel = storage.checkpointLevel || 1;
// Reset to checkpoint level and score
currentLevel = checkpointLevel;
storage.currentLevel = currentLevel;
LK.setScore(checkpointScore);
// Reset level state
enemiesKilled = 0;
enemiesNeededForLevel = getEnemyCountForLevel(currentLevel);
isBossLevel = isBossLevelCheck(currentLevel);
levelCompleteTimer = 0;
// Update UI
levelTxt.setText('Level: ' + currentLevel);
updateWeaponDisplay();
updatePointsNeededDisplay();
// Clear all enemies and bullets
for (var e = enemies.length - 1; e >= 0; e--) {
enemies[e].destroy();
enemies.splice(e, 1);
}
for (var eb = enemyBullets.length - 1; eb >= 0; eb--) {
enemyBullets[eb].destroy();
enemyBullets.splice(eb, 1);
}
// Clear boss if exists
if (currentBoss) {
currentBoss.destroy();
currentBoss = null;
if (bossHealthBar) {
bossHealthBar.destroy();
bossHealthBar = null;
}
if (bossHealthBarBg) {
bossHealthBarBg.destroy();
bossHealthBarBg = null;
}
if (bossHealthTxt) {
bossHealthTxt.destroy();
bossHealthTxt = null;
}
if (bossHealthTextBg) {
bossHealthTextBg.destroy();
bossHealthTextBg = null;
}
}
}
}
};
self.update = function () {
if (self.lastShot > 0) {
self.lastShot--;
}
if (self.invulnerable) {
self.invulnerableTimer--;
if (self.invulnerableTimer <= 0) {
self.invulnerable = false;
}
}
};
return self;
});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('playerBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -12;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game state variables
var currentLevel = storage.currentLevel || 1;
var playerLives = storage.playerLives || 3;
var playerCoins = storage.playerCoins || 0;
var maxPlayerHealth = storage.maxPlayerHealth || 3;
var marketOpen = false;
var marketOverlay = null;
var marketButtons = [];
// Initialize checkpoint data
if (!storage.checkpointScore) storage.checkpointScore = 0;
if (!storage.checkpointLevel) storage.checkpointLevel = 1;
var playerBullets = [];
var enemyBullets = [];
var enemies = [];
var currentBoss = null;
var bossHealthBar = null;
var bossHealthBarBg = null;
var bossHealthTxt = null;
var bossHealthTextBg = null;
var isBossLevel = false;
var enemySpawnTimer = 0;
var levelCompleteTimer = 0;
var enemiesKilled = 0;
// Set exact enemy count per level based on specific requirements
function getEnemyCountForLevel(level) {
if (level <= 0) return 5;
if (level === 1) return 5;
if (level === 2) return 7;
if (level === 3) return 9;
if (level === 4) return 10;
if (level === 5) return 12;
if (level === 6) return 14;
if (level === 7) return 16;
if (level === 8) return 17;
if (level === 9) return 19;
if (level === 10) return 21;
if (level === 11) return 23;
if (level === 12) return 24;
if (level === 13) return 26;
if (level === 14) return 28;
if (level === 15) return 30;
if (level === 16) return 31;
if (level === 17) return 33;
if (level === 18) return 35;
if (level === 19) return 37;
if (level === 20) return 38;
if (level === 21) return 40;
if (level === 22) return 42;
if (level === 23) return 44;
if (level === 24) return 45;
if (level === 25) return 47;
if (level === 26) return 49;
if (level === 27) return 51;
if (level === 28) return 52;
if (level === 29) return 54;
if (level === 30) return 56;
if (level === 31) return 58;
if (level === 32) return 59;
if (level === 33) return 61;
if (level === 34) return 63;
if (level === 35) return 65;
if (level === 36) return 66;
if (level === 37) return 68;
if (level === 38) return 70;
if (level === 39) return 72;
if (level === 40) return 73;
if (level === 41) return 75;
if (level === 42) return 77;
if (level === 43) return 79;
if (level === 44) return 80;
if (level === 45) return 82;
if (level === 46) return 84;
if (level === 47) return 86;
if (level === 48) return 87;
if (level === 49) return 89;
if (level === 50) return 91;
if (level === 51) return 93;
if (level === 52) return 94;
if (level === 53) return 96;
if (level === 54) return 98;
if (level === 55) return 100;
if (level === 56) return 101;
if (level === 57) return 103;
if (level === 58) return 105;
if (level === 59) return 107;
if (level === 60) return 108;
if (level === 61) return 110;
if (level === 62) return 112;
if (level === 63) return 114;
if (level === 64) return 115;
if (level === 65) return 117;
if (level === 66) return 119;
if (level === 67) return 121;
if (level === 68) return 122;
if (level === 69) return 124;
if (level === 70) return 126;
if (level === 71) return 128;
if (level === 72) return 129;
if (level === 73) return 131;
if (level === 74) return 133;
if (level === 75) return 135;
if (level === 76) return 136;
if (level === 77) return 138;
if (level === 78) return 140;
if (level === 79) return 142;
if (level === 80) return 143;
if (level === 81) return 145;
if (level === 82) return 147;
if (level === 83) return 149;
// Levels 84-100 all have 150 enemies
if (level >= 84) return 150;
return 150; // Default fallback
}
var enemiesNeededForLevel = getEnemyCountForLevel(currentLevel);
// Create player
var player = game.addChild(new Player());
player.x = 1024;
player.y = 2400;
// Create UI elements
var shipHealthTxt = new Text2('Ship: 3/3', {
size: 40,
fill: 0x00FF00
});
shipHealthTxt.anchor.set(0, 0);
shipHealthTxt.x = 150;
shipHealthTxt.y = 50;
LK.gui.topLeft.addChild(shipHealthTxt);
// Create player health bar positioned below the text
var playerHealthBarBg = LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0,
scaleX: 0.3,
scaleY: 0.6
});
playerHealthBarBg.x = 150;
playerHealthBarBg.y = 100;
LK.gui.topLeft.addChild(playerHealthBarBg);
var playerHealthBar = LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 0,
scaleX: 0.3,
scaleY: 0.6
});
playerHealthBar.x = 150;
playerHealthBar.y = 100;
LK.gui.topLeft.addChild(playerHealthBar);
var levelTxt = new Text2('Level: 1', {
size: 40,
fill: 0xFFFFFF
});
levelTxt.anchor.set(0.5, 0);
levelTxt.x = 0;
levelTxt.y = 50;
LK.gui.top.addChild(levelTxt);
var scoreTxt = new Text2('Score: 0', {
size: 40,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(1, 0);
scoreTxt.x = -20;
scoreTxt.y = 50;
LK.gui.topRight.addChild(scoreTxt);
var pointsNeededTxt = new Text2('Next Level: 10', {
size: 35,
fill: 0xFFFF00
});
pointsNeededTxt.anchor.set(0.5, 0);
pointsNeededTxt.x = 0;
pointsNeededTxt.y = 90;
LK.gui.top.addChild(pointsNeededTxt);
var weaponTxt = new Text2('Weapon: Single', {
size: 35,
fill: 0xFFFF00
});
weaponTxt.anchor.set(0.5, 0);
weaponTxt.x = 0;
weaponTxt.y = 150;
LK.gui.top.addChild(weaponTxt);
var coinsTxt = new Text2('Coins: 0', {
size: 35,
fill: 0xFFD700
});
coinsTxt.anchor.set(1, 0);
coinsTxt.x = -20;
coinsTxt.y = 90;
LK.gui.topRight.addChild(coinsTxt);
// Helper functions
function getShootCooldown() {
if (currentLevel >= 80) return 20; // Rapid fire
if (currentLevel >= 50) return 30; // Triple fire
if (currentLevel >= 20) return 25; // Dual fire
return 20; // Single fire
}
function updateWeaponDisplay() {
if (currentLevel >= 80) {
weaponTxt.setText('Weapon: Rapid Fire');
} else if (currentLevel >= 50) {
weaponTxt.setText('Weapon: Triple Fire');
} else if (currentLevel >= 20) {
weaponTxt.setText('Weapon: Dual Fire');
} else {
weaponTxt.setText('Weapon: Single Fire');
}
}
function updatePointsNeededDisplay() {
if (isBossLevel) {
pointsNeededTxt.setText('BOSS LEVEL');
} else {
var pointsNeeded = enemiesNeededForLevel - enemiesKilled;
pointsNeededTxt.setText('Enemies Left: ' + pointsNeeded);
}
}
function isBossLevelCheck(level) {
return level % 5 === 0;
}
function openMarket() {
if (marketOpen) return;
marketOpen = true;
gamePaused = true;
// Create market overlay
marketOverlay = LK.getAsset('vo', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 20
});
marketOverlay.x = 1024;
marketOverlay.y = 1366;
game.addChild(marketOverlay);
// Market title
var marketTitle = new Text2('MARKET - Level ' + currentLevel, {
size: 60,
fill: 0x000000
});
marketTitle.anchor.set(0.5, 0.5);
marketTitle.x = 1024;
marketTitle.y = 800;
game.addChild(marketTitle);
marketButtons.push(marketTitle);
// Health upgrade button
var healthUpgrade = new Text2('Health +1 (50 coins)', {
size: 45,
fill: 0x000000
});
healthUpgrade.anchor.set(0.5, 0.5);
healthUpgrade.x = 1024;
healthUpgrade.y = 1000;
healthUpgrade.interactive = true;
healthUpgrade.down = function () {
if (playerCoins >= 50) {
playerCoins -= 50;
maxPlayerHealth++;
player.maxHealth = maxPlayerHealth;
player.health = Math.min(player.health + 1, maxPlayerHealth);
storage.playerCoins = playerCoins;
storage.maxPlayerHealth = maxPlayerHealth;
closeMarket();
}
};
game.addChild(healthUpgrade);
marketButtons.push(healthUpgrade);
// Damage upgrade button
var damageUpgrade = new Text2('Damage +1 (100 coins)', {
size: 45,
fill: 0x000000
});
damageUpgrade.anchor.set(0.5, 0.5);
damageUpgrade.x = 1024;
damageUpgrade.y = 1200;
damageUpgrade.interactive = true;
damageUpgrade.down = function () {
if (playerCoins >= 100) {
playerCoins -= 100;
storage.playerCoins = playerCoins;
closeMarket();
}
};
game.addChild(damageUpgrade);
marketButtons.push(damageUpgrade);
// Close button
var closeButton = new Text2('Close Market', {
size: 45,
fill: 0xFF0000
});
closeButton.anchor.set(0.5, 0.5);
closeButton.x = 1024;
closeButton.y = 1600;
closeButton.interactive = true;
closeButton.down = function () {
closeMarket();
};
game.addChild(closeButton);
marketButtons.push(closeButton);
}
function closeMarket() {
if (!marketOpen) return;
marketOpen = false;
gamePaused = false;
if (marketOverlay) {
marketOverlay.destroy();
marketOverlay = null;
}
for (var i = 0; i < marketButtons.length; i++) {
marketButtons[i].destroy();
}
marketButtons = [];
}
function spawnBoss() {
if (currentBoss) return;
currentBoss = new Boss();
currentBoss.x = 1024;
currentBoss.y = 400;
game.addChild(currentBoss);
// Create boss health bar
bossHealthBarBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0.5,
anchorY: 0.5
}));
bossHealthBarBg.x = currentBoss.x;
bossHealthBarBg.y = currentBoss.y - 150;
bossHealthBarBg.scaleX = 0.8;
bossHealthBarBg.scaleY = 0.8;
bossHealthBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0.5,
anchorY: 0.5
}));
bossHealthBar.x = currentBoss.x;
bossHealthBar.y = currentBoss.y - 150;
bossHealthBar.scaleX = 0.8;
bossHealthBar.scaleY = 0.8;
// Create green background box for boss health text
bossHealthTextBg = game.addChild(LK.getAsset('vo', {
anchorX: 0.5,
anchorY: 0.5
}));
bossHealthTextBg.x = currentBoss.x;
bossHealthTextBg.y = currentBoss.y - 150;
bossHealthTextBg.scaleX = 0.4;
bossHealthTextBg.scaleY = 0.3;
// Create boss health text
bossHealthTxt = new Text2(currentBoss.health + '/' + currentBoss.maxHealth, {
size: 40,
fill: 0x000000
});
bossHealthTxt.anchor.set(0.5, 0.5);
bossHealthTxt.x = currentBoss.x;
bossHealthTxt.y = currentBoss.y - 150;
game.addChild(bossHealthTxt);
// Spawn enemies alongside boss
var enemyCount = Math.min(Math.floor(currentLevel / 5) + 2, 6);
for (var e = 0; e < enemyCount; e++) {
var enemy = new Enemy();
enemy.x = Math.random() * 1648 + 200;
enemy.y = Math.random() * 300 + 50;
enemies.push(enemy);
game.addChild(enemy);
}
}
function spawnEnemy() {
if (isBossLevel) return;
var enemy = new Enemy();
enemy.x = Math.random() * 1648 + 200;
enemy.y = -50;
enemies.push(enemy);
game.addChild(enemy);
}
function nextLevel() {
currentLevel++;
storage.currentLevel = currentLevel;
// Check if we've reached the maximum level
if (currentLevel > 100) {
LK.showYouWin();
return;
}
levelTxt.setText('Level: ' + currentLevel);
isBossLevel = isBossLevelCheck(currentLevel);
enemiesKilled = 0;
levelCompleteTimer = 0;
enemiesNeededForLevel = getEnemyCountForLevel(currentLevel);
updateWeaponDisplay();
updatePointsNeededDisplay();
// Award life at checkpoints (every 5 levels)
if (currentLevel % 5 === 0) {
playerLives++;
storage.playerLives = playerLives;
// Save score at checkpoint
storage.checkpointScore = LK.getScore();
storage.checkpointLevel = currentLevel;
LK.effects.flashScreen(0x00ff00, 500); // Green flash for life gained
}
if (isBossLevel) {
spawnBoss();
}
}
// Input handling
var dragActive = false;
var gamePaused = false;
var pauseOverlay = null;
game.down = function (x, y, obj) {
// Right click pause - check for right mouse button (button 2)
if (obj && obj.event && obj.event.button === 2) {
obj.event.preventDefault(); // Prevent context menu
gamePaused = !gamePaused;
if (gamePaused) {
// Create pause overlay
pauseOverlay = new Text2('GAME PAUSED\nRight-click to resume', {
size: 80,
fill: 0xFFFFFF
});
pauseOverlay.anchor.set(0.5, 0.5);
pauseOverlay.x = 1024;
pauseOverlay.y = 1366;
game.addChild(pauseOverlay);
} else {
// Remove pause overlay
if (pauseOverlay) {
pauseOverlay.destroy();
pauseOverlay = null;
}
}
return;
}
if (gamePaused) return;
dragActive = true;
var targetX = Math.max(40, Math.min(2008, x));
var targetY = Math.max(200, Math.min(2600, y));
player.x = targetX;
player.y = targetY;
player.shoot();
};
game.move = function (x, y, obj) {
if (gamePaused) return;
// Direct mouse movement - ship follows mouse cursor immediately
var targetX = Math.max(40, Math.min(2008, x));
var targetY = Math.max(200, Math.min(2600, y));
player.x = targetX;
player.y = targetY;
};
game.up = function (x, y, obj) {
if (gamePaused) return;
dragActive = false;
};
// Initialize level
updateWeaponDisplay();
updatePointsNeededDisplay();
levelTxt.setText('Level: ' + currentLevel);
isBossLevel = isBossLevelCheck(currentLevel);
if (isBossLevel) {
spawnBoss();
}
// Play background music
LK.playMusic('gamemusic');
// Main game loop
game.update = function () {
// Skip updates if game is paused
if (gamePaused) return;
// Update player
player.update();
// Update UI
scoreTxt.setText('Score: ' + LK.getScore());
coinsTxt.setText('Coins: ' + playerCoins);
shipHealthTxt.setText('Ship: ' + player.health + '/' + player.maxHealth);
// Update player health bar
var healthPercent = player.health / player.maxHealth;
playerHealthBar.scaleX = healthPercent * 0.3;
// Set color based on health
if (player.health <= 1) {
shipHealthTxt.fill = 0xff0000; // Red for low health
} else if (player.health <= 2) {
shipHealthTxt.fill = 0xffff00; // Yellow for medium health
} else {
shipHealthTxt.fill = 0x00ff00; // Green for full health
}
updatePointsNeededDisplay();
// Check for market opening (every 10 levels)
if (currentLevel % 10 === 0 && !marketOpen && !isBossLevel) {
openMarket();
return;
}
// Auto-shoot continuously
player.shoot();
// Spawn enemies for non-boss levels
if (!isBossLevel) {
enemySpawnTimer++;
var spawnRate = Math.max(20, 60 - Math.floor(currentLevel / 5) * 5);
if (enemySpawnTimer >= spawnRate) {
enemySpawnTimer = 0;
spawnEnemy();
}
} else if (isBossLevel && currentBoss) {
// Spawn additional enemies during boss levels at reduced rate
enemySpawnTimer++;
if (enemySpawnTimer >= 90) {
enemySpawnTimer = 0;
spawnEnemy();
}
}
// Update player bullets
for (var i = playerBullets.length - 1; i >= 0; i--) {
var bullet = playerBullets[i];
bullet.update(); // Update bullet position
if (bullet.lastY === undefined) bullet.lastY = bullet.y;
// Remove bullets that go off screen
if (bullet.lastY >= -10 && bullet.y < -10) {
bullet.destroy();
playerBullets.splice(i, 1);
continue;
}
// Check collision with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
LK.getSound('enemyHit').play();
LK.setScore(LK.getScore() + 10);
playerCoins += 2;
storage.playerCoins = playerCoins;
bullet.destroy();
playerBullets.splice(i, 1);
enemy.destroy();
enemies.splice(j, 1);
enemiesKilled++;
break;
}
}
// Check collision with boss
if (currentBoss && bullet.intersects(currentBoss)) {
LK.getSound('bossHit').play();
LK.setScore(LK.getScore() + 50);
playerCoins += 5;
storage.playerCoins = playerCoins;
bullet.destroy();
playerBullets.splice(i, 1);
currentBoss.health--;
// Update boss health bar
if (bossHealthBar) {
var healthPercent = currentBoss.health / currentBoss.maxHealth;
bossHealthBar.scaleX = healthPercent * 0.8;
}
// Update boss health text with bounds checking
if (bossHealthTxt) {
var displayHealth = Math.max(0, Math.min(currentBoss.health, currentBoss.maxHealth));
var displayMaxHealth = currentBoss.maxHealth;
bossHealthTxt.setText(displayHealth + '/' + displayMaxHealth);
}
if (currentBoss.health <= 0) {
currentBoss.defeated = true;
currentBoss.destroy();
currentBoss = null;
if (bossHealthBar) {
bossHealthBar.destroy();
bossHealthBar = null;
}
if (bossHealthBarBg) {
bossHealthBarBg.destroy();
bossHealthBarBg = null;
}
if (bossHealthTxt) {
bossHealthTxt.destroy();
bossHealthTxt = null;
}
if (bossHealthTextBg) {
bossHealthTextBg.destroy();
bossHealthTextBg = null;
}
LK.setScore(LK.getScore() + 500);
levelCompleteTimer = 180; // 3 seconds delay before next level
}
break;
}
if (bullet.parent) {
bullet.lastY = bullet.y;
}
}
// Update enemy bullets
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var bullet = enemyBullets[i];
bullet.update(); // Update bullet position
if (bullet.lastY === undefined) bullet.lastY = bullet.y;
// Remove bullets that go off screen
if (bullet.lastY <= 2742 && bullet.y > 2742) {
bullet.destroy();
enemyBullets.splice(i, 1);
continue;
}
// Check collision with player
if (bullet.intersects(player)) {
player.takeDamage();
bullet.destroy();
enemyBullets.splice(i, 1);
continue;
}
if (bullet.parent) {
bullet.lastY = bullet.y;
}
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
enemy.update(); // Update enemy position and behavior
if (enemy.lastY === undefined) enemy.lastY = enemy.y;
// Remove enemies that go off screen
if (enemy.lastY <= 2742 && enemy.y > 2742) {
enemy.destroy();
enemies.splice(i, 1);
continue;
}
// Check collision with player
if (enemy.intersects(player)) {
player.takeDamage();
enemy.destroy();
enemies.splice(i, 1);
continue;
}
if (enemy.parent) {
enemy.lastY = enemy.y;
}
}
// Update boss
if (currentBoss && currentBoss.parent) {
currentBoss.update();
// Update boss health bar position
if (bossHealthBar) {
bossHealthBar.x = currentBoss.x;
bossHealthBar.y = currentBoss.y - 150;
}
if (bossHealthBarBg) {
bossHealthBarBg.x = currentBoss.x;
bossHealthBarBg.y = currentBoss.y - 150;
}
if (bossHealthTxt) {
bossHealthTxt.x = currentBoss.x;
bossHealthTxt.y = currentBoss.y - 150;
}
if (bossHealthTextBg) {
bossHealthTextBg.x = currentBoss.x;
bossHealthTextBg.y = currentBoss.y - 150;
}
// Check collision with player
if (currentBoss.intersects(player)) {
player.takeDamage();
}
}
// Level progression
if (!isBossLevel && enemiesKilled >= enemiesNeededForLevel) {
levelCompleteTimer++;
if (levelCompleteTimer >= 180) {
// 3 seconds delay
nextLevel();
}
} else if (isBossLevel && currentBoss && currentBoss.defeated) {
if (levelCompleteTimer > 0) {
levelCompleteTimer--;
if (levelCompleteTimer <= 0) {
nextLevel();
}
}
} else if (isBossLevel && !currentBoss && levelCompleteTimer > 0) {
levelCompleteTimer--;
if (levelCompleteTimer <= 0) {
nextLevel();
}
} else if (isBossLevel && !currentBoss) {
// Boss level but no boss exists, spawn one
spawnBoss();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -600,10 +600,10 @@
anchorY: 0.5
}));
bossHealthTextBg.x = currentBoss.x;
bossHealthTextBg.y = currentBoss.y - 150;
- bossHealthTextBg.scaleX = 1.0;
- bossHealthTextBg.scaleY = 0.6;
+ bossHealthTextBg.scaleX = 0.4;
+ bossHealthTextBg.scaleY = 0.3;
// Create boss health text
bossHealthTxt = new Text2(currentBoss.health + '/' + currentBoss.maxHealth, {
size: 40,
fill: 0x000000