User prompt
Kan du göra så att planet stelf är i stelf mod i 5,7 sekunder ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kan du göra så att när planet steks är mindre synligt kan det inte ta skada av skot och fiender inte kan skuta misiler mot spelaren när den är mindre synlig i planet stelf
User prompt
Kan du göra så att planet strof har biilde G
User prompt
50 wave på medium
User prompt
Kan du Ada bilden New til planet bombare
User prompt
Kan du adanågra fler flygplan i shop
User prompt
Kan du göra så att planet slow har bilden oc
User prompt
Kan du göra så att det fins minst 50 wave i varge svårighet
User prompt
Kan du göra så att om skoten från slow nudar en peng får man den och så att den skuter 5 skot i sekunden men dom tar 0.5 skada ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kan du göra så att slow skuter ett skot Pär sekund
User prompt
Ändra så att slow kostar 8.0 pengar
User prompt
Endra slow till 8.5
User prompt
Kan du Ada ett segt plan som tar pengarn som skotet landar på men bara skuter ett skot Pär 1.8 sekund ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kan du Ada ett flygplan som kan skuta på pengarn och så får man den pengen som skotet nudar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Endra priset på radar till 50
User prompt
Kan du ge planet radar lengre rang på miselerna ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kan du göra så att planet radar sluter missiler mot alla fienden men en Misil Pär sekund ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kan du göra så att planet radar har bilden J
User prompt
Kan du Ada ett flygplan som har en radar och liter missiler mot alla som är i radarn rang men 7 sekunder mellan misilerna och ska kosta 30 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kan du göra så att extrem har mera wave
User prompt
Can du göra så att planet dule shot har bilden Js
User prompt
Kan du Ada ett plan som kan akuta 2 linjer med skot
User prompt
Kan du göra så att planet missile har bilden misile
User prompt
Kan du göra så att planet fast har bilden fast
User prompt
Kan du göra så att när jag trycker play agen så kommer man till välg svårighets grad och shop
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Aircraft = Container.expand(function (type) {
var self = Container.call(this);
self.aircraftType = type || 'basic';
// Set properties based on aircraft type
if (self.aircraftType === 'basic') {
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.health = 5;
self.shootRate = 10;
self.canShootMissiles = false;
} else if (self.aircraftType === 'fast') {
var playerGraphics = self.attachAsset('Fast', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 12;
self.health = 4;
self.shootRate = 8;
self.canShootMissiles = false;
} else if (self.aircraftType === 'missile') {
var playerGraphics = self.attachAsset('Misile', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 6;
self.health = 6;
self.shootRate = 12;
self.canShootMissiles = true;
self.missileTimer = 0;
} else if (self.aircraftType === 'dualshot') {
var playerGraphics = self.attachAsset('Js', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 7;
self.health = 5;
self.shootRate = 15;
self.canShootMissiles = false;
self.canShootDual = true;
} else if (self.aircraftType === 'radar') {
var playerGraphics = self.attachAsset('J', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 6;
self.health = 4;
self.shootRate = 20;
self.canShootMissiles = false;
self.canShootDual = false;
self.hasRadar = true;
self.radarRange = 800;
self.lastMissileTime = 0;
self.missileInterval = 1000; // 1 second between missiles
} else if (self.aircraftType === 'slow') {
var playerGraphics = self.attachAsset('Po', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.health = 6;
self.shootRate = 510; // 8.5 seconds at 60fps
self.canShootMissiles = false;
self.canShootDual = false;
self.hasRadar = false;
self.canCollectMoney = true;
}
self.update = function () {
// Keep player in bounds - only allow movement along bottom edge
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
// Force player to stay at bottom of screen
self.y = 2400;
// Update missile timer for missile aircraft
if (self.canShootMissiles) {
self.missileTimer++;
}
};
return self;
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x444444,
scaleX: 2,
scaleY: 2
});
self.speed = 4;
self.damage = 2;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -12;
self.damage = 1;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudType = ['cloud1', 'cloud2', 'cloud3'][Math.floor(Math.random() * 3)];
var cloudGraphics = self.attachAsset(cloudType, {
anchorX: 0.5,
anchorY: 0.5
});
cloudGraphics.alpha = 0.7;
self.speed = Math.random() * 2 + 1;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('Po', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
self.speed = 2;
self.value = 0.5;
self.update = function () {
self.y += self.speed;
// Gentle floating animation
self.x += Math.sin(LK.ticks * 0.05) * 0.5;
};
return self;
});
// Game variables
var Enemy1 = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy1', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.health = 1;
self.scoreValue = 10;
self.enemyType = 1;
self.update = function () {
self.y += self.speed;
// Adjust shooting frequency based on difficulty and wave
var shootInterval;
if (difficulty === 'extreme' && currentWave >= 2) {
shootInterval = 30; // 2 shots per second (30 ticks = 0.5 seconds at 60fps)
} else if (difficulty === 'hard' && currentWave >= 3) {
shootInterval = 90; // 1.5 shots per second (90 ticks = 1.5 seconds at 60fps)
} else {
shootInterval = difficulty === 'easy' ? 450 : difficulty === 'medium' ? 300 : 250;
}
if (LK.ticks % shootInterval === 0) {
var enemyBullet = new EnemyBullet();
enemyBullet.x = self.x;
enemyBullet.y = self.y + 40;
enemyBullets.push(enemyBullet);
game.addChild(enemyBullet);
}
// Adjust bomb frequency based on difficulty
var bombInterval = difficulty === 'easy' ? 240 : difficulty === 'medium' ? 150 : difficulty === 'hard' ? 120 : 90;
if (LK.ticks % bombInterval === 0) {
var bomb = new Bomb();
bomb.x = self.x;
bomb.y = self.y + 40;
bombs.push(bomb);
game.addChild(bomb);
}
};
return self;
});
var Enemy2 = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy2', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.health = 2;
self.scoreValue = 20;
self.enemyType = 2;
self.nextBombTime = 0;
self.bombInterval = Math.random() * 1500 + 3000; // Random between 3-4.5 seconds
self.update = function () {
self.y += self.speed;
// Zigzag movement
self.x += Math.sin(LK.ticks * 0.1) * 2;
// Drop bombs based on difficulty
var bombTime = difficulty === 'easy' ? 5000 : difficulty === 'medium' ? 3000 : difficulty === 'hard' ? 2500 : 1500;
if (LK.ticks * 16.67 >= self.nextBombTime) {
// Convert ticks to milliseconds (60fps = 16.67ms per tick)
var bomb = new Bomb();
bomb.x = self.x;
bomb.y = self.y + 40;
bombs.push(bomb);
game.addChild(bomb);
// Set next bomb time based on difficulty
var bombVariation = difficulty === 'easy' ? 2000 : difficulty === 'medium' ? 1500 : difficulty === 'hard' ? 1250 : 800;
self.bombInterval = Math.random() * bombVariation + bombTime;
self.nextBombTime = LK.ticks * 16.67 + self.bombInterval;
}
// Shoot missiles on wave 5+ in hard mode, or wave 3+ in extreme mode
if (difficulty === 'extreme' && currentWave >= 3 || difficulty === 'hard' && currentWave >= 5) {
// Extreme mode: shoot missile every 2 seconds, Hard mode: every 4 seconds
var missileInterval = difficulty === 'extreme' ? 120 : 240;
if (LK.ticks % missileInterval === 0) {
var missile = new Missile();
missile.x = self.x;
missile.y = self.y + 40;
missiles.push(missile);
game.addChild(missile);
}
} else {
// Regular bullet shooting based on difficulty
var shootInterval = difficulty === 'easy' ? 150 : difficulty === 'medium' ? 90 : difficulty === 'hard' ? 75 : 45;
if (LK.ticks % shootInterval === 0) {
var enemyBullet = new EnemyBullet();
enemyBullet.x = self.x;
enemyBullet.y = self.y + 40;
enemyBullet.damage = difficulty === 'easy' ? 0.3 : difficulty === 'medium' ? 0.5 : difficulty === 'hard' ? 0.65 : 1.0;
enemyBullets.push(enemyBullet);
game.addChild(enemyBullet);
}
}
};
return self;
});
var Enemy3 = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy3', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.health = 1;
self.scoreValue = 15;
self.enemyType = 3;
self.hasSpottedPlayer = false; // Track if this Enemy3 has already spotted the player
self.update = function () {
self.y += self.speed;
// Scout behavior - scan for player when in range
var distanceToPlayer = Math.abs(self.x - player.x);
var verticalDistance = Math.abs(self.y - player.y);
// If Enemy3 is close enough to "spot" the player (within scanning range)
if (distanceToPlayer < 300 && verticalDistance < 400 && !self.hasSpottedPlayer) {
self.hasSpottedPlayer = true;
// Show warning text
warningTxt.alpha = 1;
tween(warningTxt, {
alpha: 0
}, {
duration: 3000
}); // Fade out warning over 3 seconds
// Trigger Enemy2 spawn after warning
LK.setTimeout(function () {
var enemy2 = new Enemy2();
enemy2.x = Math.random() * 1900 + 100;
enemy2.y = -50;
enemy2.speed += Math.floor(currentWave / 3);
enemies.push(enemy2);
game.addChild(enemy2);
}, 1000); // Spawn Enemy2 1 second after warning appears
}
};
return self;
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xff0000
});
self.speed = 8;
self.damage = 1;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Missile = Container.expand(function () {
var self = Container.call(this);
var missileGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFAA00,
scaleX: 2,
scaleY: 3
});
self.speed = 6;
self.damage = 3;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.health = 5;
self.update = function () {
// Keep player in bounds - only allow movement along bottom edge
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
// Force player to stay at bottom of screen
self.y = 2400;
};
return self;
});
var PlayerMissile = Container.expand(function () {
var self = Container.call(this);
var missileGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x00AAFF,
scaleX: 1.5,
scaleY: 2
});
self.speed = -15;
self.damage = 3;
self.update = function () {
if (self.isHoming && self.target && self.target.parent) {
// Homing behavior - move towards target
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
var moveSpeed = Math.abs(self.speed);
self.x += dx / distance * moveSpeed * 0.5;
self.y += dy / distance * moveSpeed;
} else {
self.y += self.speed;
}
} else {
self.y += self.speed;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var player;
var enemies = [];
var bullets = [];
var playerMissiles = [];
var enemyBullets = [];
var bombs = [];
var missiles = [];
var clouds = [];
var coins = [];
var score = 0;
var money = storage.money || 0;
var totalKills = 0;
var enemySpawnTimer = 0;
var cloudSpawnTimer = 0;
var coinSpawnTimer = 0;
var currentWave = 1;
var enemiesSpawnedThisWave = 0;
var enemiesKilledThisWave = 0;
var enemiesPerWave = 5;
var waveInProgress = false;
var waveStartDelay = 0;
var maxEnemySpawnRate = 60;
var difficulty = null; // null, 'easy', 'medium', 'hard'
var gameStarted = false;
var showingShop = false;
var selectedAircraft = storage.selectedAircraft || 'basic';
var ownedAircraft = storage.ownedAircraft || ['basic'];
// Difficulty selection menu
var difficultyTitle = new Text2('Select Difficulty', {
size: 100,
fill: 0xFFFFFF
});
difficultyTitle.anchor.set(0.5, 0.5);
difficultyTitle.x = 1024;
difficultyTitle.y = 800;
game.addChild(difficultyTitle);
// Easy button
var easyButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 8,
tint: 0x00FF00
});
easyButton.x = 1024;
easyButton.y = 1200;
game.addChild(easyButton);
var easyText = new Text2('EASY', {
size: 80,
fill: 0x000000
});
easyText.anchor.set(0.5, 0.5);
easyText.x = 1024;
easyText.y = 1200;
game.addChild(easyText);
// Medium button
var mediumButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 8,
tint: 0xFFFF00
});
mediumButton.x = 1024;
mediumButton.y = 1400;
game.addChild(mediumButton);
var mediumText = new Text2('MEDIUM', {
size: 80,
fill: 0x000000
});
mediumText.anchor.set(0.5, 0.5);
mediumText.x = 1024;
mediumText.y = 1400;
game.addChild(mediumText);
// Hard button
var hardButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 8,
tint: 0xFF0000
});
hardButton.x = 1024;
hardButton.y = 1600;
game.addChild(hardButton);
var hardText = new Text2('HARD', {
size: 80,
fill: 0x000000
});
hardText.anchor.set(0.5, 0.5);
hardText.x = 1024;
hardText.y = 1600;
game.addChild(hardText);
// Extreme button
var extremeButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 8,
tint: 0x8B0000
});
extremeButton.x = 1024;
extremeButton.y = 1800;
game.addChild(extremeButton);
var extremeText = new Text2('EXTREME', {
size: 80,
fill: 0xFFFFFF
});
extremeText.anchor.set(0.5, 0.5);
extremeText.x = 1024;
extremeText.y = 1800;
game.addChild(extremeText);
// Shop button
var shopButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 6,
tint: 0x8A2BE2
});
shopButton.x = 1024;
shopButton.y = 2000;
game.addChild(shopButton);
var shopText = new Text2('SHOP', {
size: 60,
fill: 0xFFFFFF
});
shopText.anchor.set(0.5, 0.5);
shopText.x = 1024;
shopText.y = 2000;
game.addChild(shopText);
// Shop interface (initially hidden)
var shopTitle = new Text2('AIRCRAFT SHOP', {
size: 80,
fill: 0xFFFFFF
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 1024;
shopTitle.y = 600;
shopTitle.alpha = 0;
game.addChild(shopTitle);
// Basic Aircraft (already owned)
var basicButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0x666666
});
basicButton.x = 512;
basicButton.y = 1000;
basicButton.alpha = 0;
game.addChild(basicButton);
var basicText = new Text2('BASIC\nOwned', {
size: 40,
fill: 0xFFFFFF
});
basicText.anchor.set(0.5, 0.5);
basicText.x = 512;
basicText.y = 1000;
basicText.alpha = 0;
game.addChild(basicText);
// Fast Aircraft
var fastButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0x00AA00
});
fastButton.x = 1024;
fastButton.y = 1000;
fastButton.alpha = 0;
game.addChild(fastButton);
var fastText = new Text2('FAST\n15.0', {
size: 40,
fill: 0xFFFFFF
});
fastText.anchor.set(0.5, 0.5);
fastText.x = 1024;
fastText.y = 1000;
fastText.alpha = 0;
game.addChild(fastText);
// Missile Aircraft
var missileButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0xFF8800
});
missileButton.x = 1536;
missileButton.y = 1000;
missileButton.alpha = 0;
game.addChild(missileButton);
var missileText = new Text2('MISSILE\n25.0', {
size: 40,
fill: 0xFFFFFF
});
missileText.anchor.set(0.5, 0.5);
missileText.x = 1536;
missileText.y = 1000;
missileText.alpha = 0;
game.addChild(missileText);
// Dual-shot Aircraft
var dualshotButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0x0080FF
});
dualshotButton.x = 1024;
dualshotButton.y = 1200;
dualshotButton.alpha = 0;
game.addChild(dualshotButton);
var dualshotText = new Text2('DUAL-SHOT\n20.0', {
size: 40,
fill: 0xFFFFFF
});
dualshotText.anchor.set(0.5, 0.5);
dualshotText.x = 1024;
dualshotText.y = 1200;
dualshotText.alpha = 0;
game.addChild(dualshotText);
// Radar Aircraft
var radarButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0xFF00FF
});
radarButton.x = 512;
radarButton.y = 1400;
radarButton.alpha = 0;
game.addChild(radarButton);
var radarText = new Text2('RADAR\n30.0', {
size: 40,
fill: 0xFFFFFF
});
radarText.anchor.set(0.5, 0.5);
radarText.x = 512;
radarText.y = 1400;
radarText.alpha = 0;
game.addChild(radarText);
// Radar Aircraft
radarButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0xFF00FF
});
radarButton.x = 512;
radarButton.y = 1400;
radarButton.alpha = 0;
game.addChild(radarButton);
radarText = new Text2('RADAR\n50.0', {
size: 40,
fill: 0xFFFFFF
});
radarText.anchor.set(0.5, 0.5);
radarText.x = 512;
radarText.y = 1400;
radarText.alpha = 0;
game.addChild(radarText);
// Slow Aircraft
var slowButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0x808080
});
slowButton.x = 1536;
slowButton.y = 1400;
slowButton.alpha = 0;
game.addChild(slowButton);
var slowText = new Text2('SLOW\n8.0', {
size: 40,
fill: 0xFFFFFF
});
slowText.anchor.set(0.5, 0.5);
slowText.x = 1536;
slowText.y = 1400;
slowText.alpha = 0;
game.addChild(slowText);
// Back button for shop
backButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 6,
tint: 0xFF0000
});
backButton.x = 1024;
backButton.y = 1600;
backButton.y = 1600;
backButton.alpha = 0;
game.addChild(backButton);
var backText = new Text2('BACK', {
size: 50,
fill: 0xFFFFFF
});
backText.anchor.set(0.5, 0.5);
backText.x = 1024;
backText.y = 1600;
backText.alpha = 0;
game.addChild(backText);
// Initialize background clouds
for (var i = 0; i < 8; i++) {
var cloud = new Cloud();
cloud.x = Math.random() * 2048;
cloud.y = Math.random() * 2732;
clouds.push(cloud);
game.addChild(cloud);
}
// Player will be created when game starts after difficulty selection
// Score display
var scoreTxt = new Text2('Score: ' + score, {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(scoreTxt);
scoreTxt.x = 120;
scoreTxt.y = 20;
// Wave display
var waveTxt = new Text2('Wave: ' + currentWave, {
size: 60,
fill: 0xFFFF00
});
waveTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(waveTxt);
waveTxt.y = 20;
// Health display
var healthTxt = new Text2('Health: 5', {
size: 60,
fill: 0xFF0000
});
healthTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(healthTxt);
healthTxt.x = -20;
healthTxt.y = 20;
// Kills counter display
var killsTxt = new Text2('Kills: ' + totalKills, {
size: 60,
fill: 0x00FF00
});
killsTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(killsTxt);
killsTxt.x = -20;
killsTxt.y = 90;
// Money display
var moneyTxt = new Text2('Money: ' + money.toFixed(1), {
size: 60,
fill: 0xFFD700
});
moneyTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(moneyTxt);
moneyTxt.x = 120;
moneyTxt.y = 90;
// Warning text (initially hidden)
var warningTxt = new Text2('WARNING', {
size: 120,
fill: 0xFF0000
});
warningTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(warningTxt);
warningTxt.alpha = 0; // Initially hidden
// Touch input handling for difficulty selection and player movement
game.down = function (x, y, obj) {
if (!gameStarted && !showingShop) {
// Check if easy button was touched
if (x >= 900 && x <= 1148 && y >= 1136 && y <= 1264) {
difficulty = 'easy';
startGame();
}
// Check if medium button was touched
else if (x >= 900 && x <= 1148 && y >= 1336 && y <= 1464) {
difficulty = 'medium';
startGame();
}
// Check if hard button was touched
else if (x >= 900 && x <= 1148 && y >= 1536 && y <= 1664) {
difficulty = 'hard';
startGame();
}
// Check if extreme button was touched
else if (x >= 900 && x <= 1148 && y >= 1736 && y <= 1864) {
difficulty = 'extreme';
startGame();
}
// Check if shop button was touched
else if (x >= 880 && x <= 1168 && y >= 1940 && y <= 2060) {
showShop();
}
} else if (showingShop) {
// Shop interactions
// Back button
if (x >= 920 && x <= 1128 && y >= 1540 && y <= 1660) {
hideShop();
}
// Basic aircraft selection
else if (x >= 408 && x <= 616 && y >= 940 && y <= 1060) {
selectAircraft('basic');
}
// Fast aircraft purchase/selection
else if (x >= 920 && x <= 1128 && y >= 940 && y <= 1060) {
if (ownedAircraft.indexOf('fast') !== -1) {
selectAircraft('fast');
} else if (money >= 15.0) {
purchaseAircraft('fast', 15.0);
}
}
// Missile aircraft purchase/selection
else if (x >= 1432 && x <= 1640 && y >= 940 && y <= 1060) {
if (ownedAircraft.indexOf('missile') !== -1) {
selectAircraft('missile');
} else if (money >= 25.0) {
purchaseAircraft('missile', 25.0);
}
}
// Dual-shot aircraft purchase/selection
else if (x >= 920 && x <= 1128 && y >= 1140 && y <= 1260) {
if (ownedAircraft.indexOf('dualshot') !== -1) {
selectAircraft('dualshot');
} else if (money >= 20.0) {
purchaseAircraft('dualshot', 20.0);
}
}
// Radar aircraft purchase/selection
else if (x >= 408 && x <= 616 && y >= 1340 && y <= 1460) {
if (ownedAircraft.indexOf('radar') !== -1) {
selectAircraft('radar');
} else if (money >= 50.0) {
purchaseAircraft('radar', 50.0);
}
}
// Slow aircraft purchase/selection
else if (x >= 1432 && x <= 1640 && y >= 1340 && y <= 1460) {
if (ownedAircraft.indexOf('slow') !== -1) {
selectAircraft('slow');
} else if (money >= 8.0) {
purchaseAircraft('slow', 8.0);
}
}
} else if (gameStarted) {
// Move player to touch x position, keeping y at bottom
player.x = x;
}
};
game.move = function (x, y, obj) {
if (gameStarted) {
// Move player to touch x position while dragging
player.x = x;
}
};
// Function to start game with selected difficulty
function startGame() {
gameStarted = true;
// Remove difficulty selection menu
difficultyTitle.destroy();
easyButton.destroy();
easyText.destroy();
mediumButton.destroy();
mediumText.destroy();
hardButton.destroy();
hardText.destroy();
extremeButton.destroy();
extremeText.destroy();
shopButton.destroy();
shopText.destroy();
// Hide shop interface elements
shopTitle.destroy();
basicButton.destroy();
basicText.destroy();
fastButton.destroy();
fastText.destroy();
missileButton.destroy();
missileText.destroy();
backButton.destroy();
backText.destroy();
// Create player with selected aircraft
player = game.addChild(new Aircraft(selectedAircraft));
player.x = 1024;
player.y = 2400;
// Apply difficulty settings
if (difficulty === 'easy') {
player.health = 8;
maxEnemySpawnRate = 80;
enemiesPerWave = 3;
} else if (difficulty === 'medium') {
player.health = 5;
maxEnemySpawnRate = 60;
enemiesPerWave = 5;
} else if (difficulty === 'hard') {
player.health = 4;
maxEnemySpawnRate = 50;
enemiesPerWave = 6;
} else if (difficulty === 'extreme') {
player.health = 3;
maxEnemySpawnRate = 30;
enemiesPerWave = 8;
}
// Update health display
healthTxt.setText('Health: ' + player.health);
}
function showShop() {
showingShop = true;
// Hide difficulty buttons
difficultyTitle.alpha = 0;
easyButton.alpha = 0;
easyText.alpha = 0;
mediumButton.alpha = 0;
mediumText.alpha = 0;
hardButton.alpha = 0;
hardText.alpha = 0;
extremeButton.alpha = 0;
extremeText.alpha = 0;
shopButton.alpha = 0;
shopText.alpha = 0;
// Show shop interface
shopTitle.alpha = 1;
basicButton.alpha = 1;
basicText.alpha = 1;
fastButton.alpha = 1;
fastText.alpha = 1;
missileButton.alpha = 1;
missileText.alpha = 1;
dualshotButton.alpha = 1;
dualshotText.alpha = 1;
radarButton.alpha = 1;
radarText.alpha = 1;
slowButton.alpha = 1;
slowText.alpha = 1;
backButton.alpha = 1;
backText.alpha = 1;
// Update button states based on ownership
updateShopDisplay();
}
function hideShop() {
showingShop = false;
// Show difficulty buttons
difficultyTitle.alpha = 1;
easyButton.alpha = 1;
easyText.alpha = 1;
mediumButton.alpha = 1;
mediumText.alpha = 1;
hardButton.alpha = 1;
hardText.alpha = 1;
extremeButton.alpha = 1;
extremeText.alpha = 1;
shopButton.alpha = 1;
shopText.alpha = 1;
// Hide shop interface
shopTitle.alpha = 0;
basicButton.alpha = 0;
basicText.alpha = 0;
fastButton.alpha = 0;
fastText.alpha = 0;
missileButton.alpha = 0;
missileText.alpha = 0;
dualshotButton.alpha = 0;
dualshotText.alpha = 0;
radarButton.alpha = 0;
radarText.alpha = 0;
slowButton.alpha = 0;
slowText.alpha = 0;
backButton.alpha = 0;
backText.alpha = 0;
}
function updateShopDisplay() {
// Update money display
moneyTxt.setText('Money: ' + money.toFixed(1));
// Update aircraft buttons based on ownership and selection
if (ownedAircraft.indexOf('fast') !== -1) {
fastText.setText(selectedAircraft === 'fast' ? 'FAST\nSELECTED' : 'FAST\nOwned');
fastButton.tint = selectedAircraft === 'fast' ? 0xFFFF00 : 0x00AA00;
} else {
fastText.setText('FAST\n15.0');
fastButton.tint = money >= 15.0 ? 0x00AA00 : 0x555555;
}
if (ownedAircraft.indexOf('missile') !== -1) {
missileText.setText(selectedAircraft === 'missile' ? 'MISSILE\nSELECTED' : 'MISSILE\nOwned');
missileButton.tint = selectedAircraft === 'missile' ? 0xFFFF00 : 0xFF8800;
} else {
missileText.setText('MISSILE\n25.0');
missileButton.tint = money >= 25.0 ? 0xFF8800 : 0x555555;
}
// Dual-shot aircraft
if (ownedAircraft.indexOf('dualshot') !== -1) {
dualshotText.setText(selectedAircraft === 'dualshot' ? 'DUAL-SHOT\nSELECTED' : 'DUAL-SHOT\nOwned');
dualshotButton.tint = selectedAircraft === 'dualshot' ? 0xFFFF00 : 0x0080FF;
} else {
dualshotText.setText('DUAL-SHOT\n20.0');
dualshotButton.tint = money >= 20.0 ? 0x0080FF : 0x555555;
}
// Radar aircraft
if (ownedAircraft.indexOf('radar') !== -1) {
radarText.setText(selectedAircraft === 'radar' ? 'RADAR\nSELECTED' : 'RADAR\nOwned');
radarButton.tint = selectedAircraft === 'radar' ? 0xFFFF00 : 0xFF00FF;
} else {
radarText.setText('RADAR\n50.0');
radarButton.tint = money >= 50.0 ? 0xFF00FF : 0x555555;
}
// Slow aircraft
if (ownedAircraft.indexOf('slow') !== -1) {
slowText.setText(selectedAircraft === 'slow' ? 'SLOW\nSELECTED' : 'SLOW\nOwned');
slowButton.tint = selectedAircraft === 'slow' ? 0xFFFF00 : 0x808080;
} else {
slowText.setText('SLOW\n8.0');
slowButton.tint = money >= 8.0 ? 0x808080 : 0x555555;
}
// Basic aircraft
basicText.setText(selectedAircraft === 'basic' ? 'BASIC\nSELECTED' : 'BASIC\nOwned');
basicButton.tint = selectedAircraft === 'basic' ? 0xFFFF00 : 0x666666;
}
function purchaseAircraft(type, cost) {
if (money >= cost) {
money -= cost;
ownedAircraft.push(type);
selectedAircraft = type;
// Save to storage
storage.money = money;
storage.ownedAircraft = ownedAircraft;
storage.selectedAircraft = selectedAircraft;
// Update display
updateShopDisplay();
// Visual feedback
LK.effects.flashScreen(0x00FF00, 300);
}
}
function selectAircraft(type) {
if (ownedAircraft.indexOf(type) !== -1) {
selectedAircraft = type;
storage.selectedAircraft = selectedAircraft;
updateShopDisplay();
}
}
// Main game loop
game.update = function () {
if (!gameStarted) return;
// Spawn new clouds
cloudSpawnTimer++;
if (cloudSpawnTimer > 120) {
var cloud = new Cloud();
cloud.x = Math.random() * 2048;
cloud.y = -100;
clouds.push(cloud);
game.addChild(cloud);
cloudSpawnTimer = 0;
}
// Spawn coins randomly
coinSpawnTimer++;
if (coinSpawnTimer > 180) {
// Spawn coin every 3 seconds
var coin = new Coin();
coin.x = Math.random() * 1800 + 124; // Keep away from edges
coin.y = -50;
coins.push(coin);
game.addChild(coin);
coinSpawnTimer = 0;
}
// Update clouds
for (var i = clouds.length - 1; i >= 0; i--) {
var cloud = clouds[i];
if (cloud.y > 2800) {
cloud.destroy();
clouds.splice(i, 1);
}
}
// Shooting based on aircraft shoot rate
if (LK.ticks % player.shootRate === 0) {
if (player.canShootDual) {
// Shoot two bullets in parallel lines
var bullet1 = new Bullet();
bullet1.x = player.x - 25; // Left bullet
bullet1.y = player.y - 60;
bullets.push(bullet1);
game.addChild(bullet1);
var bullet2 = new Bullet();
bullet2.x = player.x + 25; // Right bullet
bullet2.y = player.y - 60;
bullets.push(bullet2);
game.addChild(bullet2);
} else {
var bullet = new Bullet();
bullet.x = player.x; // Spawn bullet at player's exact x position
bullet.y = player.y - 60; // Spawn bullet slightly above player
bullets.push(bullet);
game.addChild(bullet);
}
LK.getSound('shoot').play();
}
// Missile shooting for missile aircraft
if (player.canShootMissiles && player.missileTimer >= 90) {
// Every 1.5 seconds
var playerMissile = new PlayerMissile();
playerMissile.x = player.x;
playerMissile.y = player.y - 60;
playerMissiles.push(playerMissile);
game.addChild(playerMissile);
player.missileTimer = 0;
}
// Radar missile firing for radar aircraft
if (player.hasRadar && LK.ticks * 16.67 >= player.lastMissileTime + player.missileInterval) {
// Find enemies within radar range
var enemiesInRange = [];
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
var distance = Math.sqrt(Math.pow(enemy.x - player.x, 2) + Math.pow(enemy.y - player.y, 2));
if (distance <= player.radarRange) {
enemiesInRange.push(enemy);
}
}
// Fire missile at all enemies in range, one missile per second
if (enemiesInRange.length > 0) {
for (var k = 0; k < enemiesInRange.length; k++) {
var targetEnemy = enemiesInRange[k];
var radarMissile = new PlayerMissile();
radarMissile.x = player.x;
radarMissile.y = player.y - 60;
// Add homing capability by storing target
radarMissile.target = targetEnemy;
radarMissile.isHoming = true;
playerMissiles.push(radarMissile);
game.addChild(radarMissile);
}
player.lastMissileTime = LK.ticks * 16.67;
}
}
// Wave system - spawn enemies based on current wave (infinite waves)
if (!waveInProgress && waveStartDelay <= 0) {
// Start new wave
waveInProgress = true;
enemiesSpawnedThisWave = 0;
enemiesKilledThisWave = 0;
// Infinite waves - enemies per wave increases indefinitely for all difficulties
// Extreme mode gets significantly more enemies per wave
if (difficulty === 'extreme') {
enemiesPerWave = 8 + currentWave * 4; // Much more aggressive scaling for extreme
maxEnemySpawnRate = Math.max(8, 45 - currentWave * 3); // Faster spawning, minimum 8 ticks
} else {
enemiesPerWave = 5 + currentWave * 2; // Standard scaling for other difficulties
maxEnemySpawnRate = Math.max(15, 60 - currentWave * 2); // Standard spawning rate
}
waveTxt.setText('Wave: ' + currentWave);
}
if (waveInProgress && enemiesSpawnedThisWave < enemiesPerWave) {
enemySpawnTimer++;
if (enemySpawnTimer > maxEnemySpawnRate) {
// Randomly choose enemy type - extreme mode favors stronger enemies in later waves
var enemyType;
if (difficulty === 'extreme' && currentWave >= 3) {
// In extreme mode from wave 3+, bias towards stronger enemies
var rand = Math.random();
if (rand < 0.2) {
enemyType = 1; // 20% Enemy1
} else if (rand < 0.6) {
enemyType = 2; // 40% Enemy2
} else {
enemyType = 3; // 40% Enemy3
}
} else {
enemyType = Math.floor(Math.random() * 3) + 1;
}
var enemy;
if (enemyType === 1) {
enemy = new Enemy1();
} else if (enemyType === 2) {
enemy = new Enemy2();
} else {
enemy = new Enemy3();
}
enemy.x = Math.random() * 1900 + 100;
enemy.y = -50;
// Make enemies faster in later waves - extreme mode gets even faster enemies
if (difficulty === 'extreme') {
enemy.speed += Math.floor(currentWave / 2); // Faster progression for extreme
} else {
enemy.speed += Math.floor(currentWave / 3);
}
enemies.push(enemy);
game.addChild(enemy);
enemySpawnTimer = 0;
enemiesSpawnedThisWave++;
// Extreme mode: spawn additional enemies in pairs occasionally
if (difficulty === 'extreme' && currentWave >= 5 && Math.random() < 0.3) {
var extraEnemy = new Enemy2();
extraEnemy.x = Math.random() * 1900 + 100;
extraEnemy.y = -50;
extraEnemy.speed += Math.floor(currentWave / 2);
enemies.push(extraEnemy);
game.addChild(extraEnemy);
enemiesSpawnedThisWave++;
}
}
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
// Remove bullets that are off screen
if (bullet.y < -50) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check bullet-enemy collisions
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
// Damage enemy
enemy.health -= bullet.damage;
bullet.destroy();
bullets.splice(i, 1);
// Check if enemy is destroyed
if (enemy.health <= 0) {
LK.getSound('explosion').play();
// Create explosion visual at enemy position
var explosion = LK.getAsset('Bomm', {
anchorX: 0.5,
anchorY: 0.5
});
explosion.x = enemy.x;
explosion.y = enemy.y;
game.addChild(explosion);
// Animate explosion - scale up and fade out
tween(explosion, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
explosion.destroy();
}
});
enemy.destroy();
enemies.splice(j, 1);
// Update score based on enemy type and wave
score += enemy.scoreValue * currentWave;
LK.setScore(score);
scoreTxt.setText('Score: ' + score);
// Update kills counter
totalKills++;
killsTxt.setText('Kills: ' + totalKills);
enemiesKilledThisWave++;
// Check if wave is complete - continue infinitely
if (waveInProgress && enemiesKilledThisWave >= enemiesPerWave) {
waveInProgress = false;
currentWave++;
waveStartDelay = 180; // 3 second delay between waves
LK.effects.flashScreen(0x00ff00, 500); // Green flash for wave complete
// Show wave completed text - infinite progression
var waveCompletedTxt = new Text2('WAVE ' + (currentWave - 1) + ' COMPLETED!', {
size: 120,
fill: 0x00FF00
});
waveCompletedTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(waveCompletedTxt);
// Animate wave completed text - scale up and fade in, then fade out
waveCompletedTxt.alpha = 0;
waveCompletedTxt.scaleX = 0.5;
waveCompletedTxt.scaleY = 0.5;
tween(waveCompletedTxt, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 800,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Hold the text for a moment, then fade out
LK.setTimeout(function () {
tween(waveCompletedTxt, {
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
waveCompletedTxt.destroy();
}
});
}, 1000);
}
});
}
} else {
// Enemy damaged but not destroyed - flash red
LK.effects.flashObject(enemy, 0xff0000, 200);
}
break;
}
}
}
// Update player missiles
for (var i = playerMissiles.length - 1; i >= 0; i--) {
var playerMissile = playerMissiles[i];
// Remove missiles that are off screen
if (playerMissile.y < -50) {
playerMissile.destroy();
playerMissiles.splice(i, 1);
continue;
}
// Check missile-enemy collisions
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (playerMissile.intersects(enemy)) {
// Damage enemy
enemy.health -= playerMissile.damage;
playerMissile.destroy();
playerMissiles.splice(i, 1);
// Check if enemy is destroyed
if (enemy.health <= 0) {
LK.getSound('explosion').play();
// Create explosion visual at enemy position
var explosion = LK.getAsset('Bomm', {
anchorX: 0.5,
anchorY: 0.5
});
explosion.x = enemy.x;
explosion.y = enemy.y;
game.addChild(explosion);
// Animate explosion - scale up and fade out
tween(explosion, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
explosion.destroy();
}
});
enemy.destroy();
enemies.splice(j, 1);
// Update score based on enemy type and wave
score += enemy.scoreValue * currentWave;
LK.setScore(score);
scoreTxt.setText('Score: ' + score);
// Update kills counter
totalKills++;
killsTxt.setText('Kills: ' + totalKills);
enemiesKilledThisWave++;
// Check if wave is complete - continue infinitely
if (waveInProgress && enemiesKilledThisWave >= enemiesPerWave) {
waveInProgress = false;
currentWave++;
waveStartDelay = 180; // 3 second delay between waves
LK.effects.flashScreen(0x00ff00, 500); // Green flash for wave complete
// Show wave completed text - infinite progression
var waveCompletedTxt = new Text2('WAVE ' + (currentWave - 1) + ' COMPLETED!', {
size: 120,
fill: 0x00FF00
});
waveCompletedTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(waveCompletedTxt);
// Animate wave completed text - scale up and fade in, then fade out
waveCompletedTxt.alpha = 0;
waveCompletedTxt.scaleX = 0.5;
waveCompletedTxt.scaleY = 0.5;
tween(waveCompletedTxt, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 800,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Hold the text for a moment, then fade out
LK.setTimeout(function () {
tween(waveCompletedTxt, {
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
waveCompletedTxt.destroy();
}
});
}, 1000);
}
});
}
} else {
// Enemy damaged but not destroyed - flash red
LK.effects.flashObject(enemy, 0xff0000, 200);
}
break;
}
}
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
// Remove enemies that are off screen
if (enemy.y > 2800) {
enemy.destroy();
enemies.splice(i, 1);
continue;
}
// Check enemy-player collision
if (enemy.intersects(player)) {
player.health--;
healthTxt.setText('Health: ' + player.health);
if (player.health <= 0) {
// Save money before game over
storage.money = money;
LK.showGameOver();
} else {
LK.effects.flashObject(player, 0xff0000, 500);
}
enemy.destroy();
enemies.splice(i, 1);
}
}
// Update enemy bullets
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var enemyBullet = enemyBullets[i];
// Remove bullets that are off screen
if (enemyBullet.y > 2800) {
enemyBullet.destroy();
enemyBullets.splice(i, 1);
continue;
}
// Check enemy bullet-player collision
if (enemyBullet.intersects(player)) {
player.health -= enemyBullet.damage;
healthTxt.setText('Health: ' + player.health);
enemyBullet.destroy();
enemyBullets.splice(i, 1);
if (player.health <= 0) {
// Save money before game over
storage.money = money;
LK.showGameOver();
} else {
LK.effects.flashObject(player, 0xff0000, 500);
}
}
}
// Update bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
// Remove bombs that are off screen
if (bomb.y > 2800) {
bomb.destroy();
bombs.splice(i, 1);
continue;
}
// Check bomb-player collision
if (bomb.intersects(player)) {
player.health -= bomb.damage;
healthTxt.setText('Health: ' + player.health);
bomb.destroy();
bombs.splice(i, 1);
if (player.health <= 0) {
// Save money before game over
storage.money = money;
LK.showGameOver();
} else {
LK.effects.flashObject(player, 0xff0000, 500);
}
}
}
// Update missiles
for (var i = missiles.length - 1; i >= 0; i--) {
var missile = missiles[i];
// Remove missiles that are off screen
if (missile.y > 2800) {
missile.destroy();
missiles.splice(i, 1);
continue;
}
// Check missile-player collision
if (missile.intersects(player)) {
player.health -= missile.damage;
healthTxt.setText('Health: ' + player.health);
missile.destroy();
missiles.splice(i, 1);
if (player.health <= 0) {
// Save money before game over
storage.money = money;
LK.showGameOver();
} else {
LK.effects.flashObject(player, 0xff0000, 500);
}
}
}
// Update coins
for (var i = coins.length - 1; i >= 0; i--) {
var coin = coins[i];
// Remove coins that are off screen
if (coin.y > 2800) {
coin.destroy();
coins.splice(i, 1);
continue;
}
// Check coin-player collision
if (coin.intersects(player)) {
// Add money based on difficulty level
var coinValue = 0.5; // Default for easy
if (difficulty === 'medium') {
coinValue = 1.0;
} else if (difficulty === 'hard') {
coinValue = 1.5;
} else if (difficulty === 'extreme') {
coinValue = 2.5;
}
// Double coin value for slow aircraft
if (player.canCollectMoney) {
coinValue *= 2;
}
money += coinValue;
// Add same value as points
score += coinValue;
LK.setScore(score);
scoreTxt.setText('Score: ' + score);
moneyTxt.setText('Money: ' + money.toFixed(1));
// Visual effect for coin collection
LK.effects.flashObject(coin, 0xFFD700, 200);
coin.destroy();
coins.splice(i, 1);
}
}
// Handle wave start delay
if (waveStartDelay > 0) {
waveStartDelay--;
}
// Check if player failed to eliminate all enemies (game over condition)
// If enemies reach the bottom of the screen without being destroyed, it's game over
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.y > 2600) {
// Enemy reached near bottom of screen
// Save money before game over
storage.money = money;
LK.showGameOver();
break;
}
}
};
// Function to reset game and allow playing again
function resetGame() {
// Reset all game variables to initial state
gameStarted = false;
showingShop = false;
difficulty = null;
score = 0;
totalKills = 0;
enemySpawnTimer = 0;
cloudSpawnTimer = 0;
coinSpawnTimer = 0;
currentWave = 1;
enemiesSpawnedThisWave = 0;
enemiesKilledThisWave = 0;
enemiesPerWave = 5;
waveInProgress = false;
waveStartDelay = 0;
maxEnemySpawnRate = 60;
// Clear all arrays and destroy remaining objects
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].destroy();
}
enemies = [];
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].destroy();
}
bullets = [];
for (var i = playerMissiles.length - 1; i >= 0; i--) {
playerMissiles[i].destroy();
}
playerMissiles = [];
for (var i = enemyBullets.length - 1; i >= 0; i--) {
enemyBullets[i].destroy();
}
enemyBullets = [];
for (var i = bombs.length - 1; i >= 0; i--) {
bombs[i].destroy();
}
bombs = [];
for (var i = missiles.length - 1; i >= 0; i--) {
missiles[i].destroy();
}
missiles = [];
for (var i = coins.length - 1; i >= 0; i--) {
coins[i].destroy();
}
coins = [];
// Destroy player if it exists
if (player) {
player.destroy();
player = null;
}
// Reset score display
LK.setScore(0);
scoreTxt.setText('Score: 0');
waveTxt.setText('Wave: 1');
killsTxt.setText('Kills: 0');
moneyTxt.setText('Money: ' + money.toFixed(1));
// Recreate difficulty selection menu
difficultyTitle = new Text2('Select Difficulty', {
size: 100,
fill: 0xFFFFFF
});
difficultyTitle.anchor.set(0.5, 0.5);
difficultyTitle.x = 1024;
difficultyTitle.y = 800;
game.addChild(difficultyTitle);
// Easy button
easyButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 8,
tint: 0x00FF00
});
easyButton.x = 1024;
easyButton.y = 1200;
game.addChild(easyButton);
easyText = new Text2('EASY', {
size: 80,
fill: 0x000000
});
easyText.anchor.set(0.5, 0.5);
easyText.x = 1024;
easyText.y = 1200;
game.addChild(easyText);
// Medium button
mediumButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 8,
tint: 0xFFFF00
});
mediumButton.x = 1024;
mediumButton.y = 1400;
game.addChild(mediumButton);
mediumText = new Text2('MEDIUM', {
size: 80,
fill: 0x000000
});
mediumText.anchor.set(0.5, 0.5);
mediumText.x = 1024;
mediumText.y = 1400;
game.addChild(mediumText);
// Hard button
hardButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 8,
tint: 0xFF0000
});
hardButton.x = 1024;
hardButton.y = 1600;
game.addChild(hardButton);
hardText = new Text2('HARD', {
size: 80,
fill: 0x000000
});
hardText.anchor.set(0.5, 0.5);
hardText.x = 1024;
hardText.y = 1600;
game.addChild(hardText);
// Extreme button
extremeButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 8,
tint: 0x8B0000
});
extremeButton.x = 1024;
extremeButton.y = 1800;
game.addChild(extremeButton);
extremeText = new Text2('EXTREME', {
size: 80,
fill: 0xFFFFFF
});
extremeText.anchor.set(0.5, 0.5);
extremeText.x = 1024;
extremeText.y = 1800;
game.addChild(extremeText);
// Shop button
shopButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 6,
tint: 0x8A2BE2
});
shopButton.x = 1024;
shopButton.y = 2000;
game.addChild(shopButton);
shopText = new Text2('SHOP', {
size: 60,
fill: 0xFFFFFF
});
shopText.anchor.set(0.5, 0.5);
shopText.x = 1024;
shopText.y = 2000;
game.addChild(shopText);
// Recreate shop interface (initially hidden)
shopTitle = new Text2('AIRCRAFT SHOP', {
size: 80,
fill: 0xFFFFFF
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 1024;
shopTitle.y = 600;
shopTitle.alpha = 0;
game.addChild(shopTitle);
// Basic Aircraft
basicButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0x666666
});
basicButton.x = 512;
basicButton.y = 1000;
basicButton.alpha = 0;
game.addChild(basicButton);
basicText = new Text2('BASIC\nOwned', {
size: 40,
fill: 0xFFFFFF
});
basicText.anchor.set(0.5, 0.5);
basicText.x = 512;
basicText.y = 1000;
basicText.alpha = 0;
game.addChild(basicText);
// Fast Aircraft
fastButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0x00AA00
});
fastButton.x = 1024;
fastButton.y = 1000;
fastButton.alpha = 0;
game.addChild(fastButton);
fastText = new Text2('FAST\n15.0', {
size: 40,
fill: 0xFFFFFF
});
fastText.anchor.set(0.5, 0.5);
fastText.x = 1024;
fastText.y = 1000;
fastText.alpha = 0;
game.addChild(fastText);
// Missile Aircraft
missileButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0xFF8800
});
missileButton.x = 1536;
missileButton.y = 1000;
missileButton.alpha = 0;
game.addChild(missileButton);
missileText = new Text2('MISSILE\n25.0', {
size: 40,
fill: 0xFFFFFF
});
missileText.anchor.set(0.5, 0.5);
missileText.x = 1536;
missileText.y = 1000;
missileText.alpha = 0;
game.addChild(missileText);
// Dual-shot Aircraft
dualshotButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0x0080FF
});
dualshotButton.x = 1024;
dualshotButton.y = 1200;
dualshotButton.alpha = 0;
game.addChild(dualshotButton);
dualshotText = new Text2('DUAL-SHOT\n20.0', {
size: 40,
fill: 0xFFFFFF
});
dualshotText.anchor.set(0.5, 0.5);
dualshotText.x = 1024;
dualshotText.y = 1200;
dualshotText.alpha = 0;
game.addChild(dualshotText);
// Slow Aircraft
slowButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0x808080
});
slowButton.x = 1536;
slowButton.y = 1400;
slowButton.alpha = 0;
game.addChild(slowButton);
slowText = new Text2('SLOW\n8.0', {
size: 40,
fill: 0xFFFFFF
});
slowText.anchor.set(0.5, 0.5);
slowText.x = 1536;
slowText.y = 1400;
slowText.alpha = 0;
game.addChild(slowText);
// Back button for shop
backButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 6,
tint: 0xFF0000
});
backButton.x = 1024;
backButton.alpha = 0;
game.addChild(backButton);
backText = new Text2('BACK', {
size: 50,
fill: 0xFFFFFF
});
backText.anchor.set(0.5, 0.5);
backText.x = 1024;
backText.y = 1600;
backText.alpha = 0;
game.addChild(backText);
// Update shop display to reflect current state
updateShopDisplay();
}
// Call resetGame when the game engine triggers a restart
LK.on('restart', function () {
resetGame();
}); ===================================================================
--- original.js
+++ change.js
@@ -652,9 +652,9 @@
slowButton.x = 1536;
slowButton.y = 1400;
slowButton.alpha = 0;
game.addChild(slowButton);
-var slowText = new Text2('SLOW\n35.0', {
+var slowText = new Text2('SLOW\n8.0', {
size: 40,
fill: 0xFFFFFF
});
slowText.anchor.set(0.5, 0.5);
@@ -817,10 +817,10 @@
// Slow aircraft purchase/selection
else if (x >= 1432 && x <= 1640 && y >= 1340 && y <= 1460) {
if (ownedAircraft.indexOf('slow') !== -1) {
selectAircraft('slow');
- } else if (money >= 35.0) {
- purchaseAircraft('slow', 35.0);
+ } else if (money >= 8.0) {
+ purchaseAircraft('slow', 8.0);
}
}
} else if (gameStarted) {
// Move player to touch x position, keeping y at bottom
@@ -985,10 +985,10 @@
if (ownedAircraft.indexOf('slow') !== -1) {
slowText.setText(selectedAircraft === 'slow' ? 'SLOW\nSELECTED' : 'SLOW\nOwned');
slowButton.tint = selectedAircraft === 'slow' ? 0xFFFF00 : 0x808080;
} else {
- slowText.setText('SLOW\n35.0');
- slowButton.tint = money >= 35.0 ? 0x808080 : 0x555555;
+ slowText.setText('SLOW\n8.0');
+ slowButton.tint = money >= 8.0 ? 0x808080 : 0x555555;
}
// Basic aircraft
basicText.setText(selectedAircraft === 'basic' ? 'BASIC\nSELECTED' : 'BASIC\nOwned');
basicButton.tint = selectedAircraft === 'basic' ? 0xFFFF00 : 0x666666;
@@ -1784,9 +1784,9 @@
slowButton.x = 1536;
slowButton.y = 1400;
slowButton.alpha = 0;
game.addChild(slowButton);
- slowText = new Text2('SLOW\n35.0', {
+ slowText = new Text2('SLOW\n8.0', {
size: 40,
fill: 0xFFFFFF
});
slowText.anchor.set(0.5, 0.5);
Moln. In-Game asset. 2d. High contrast. No shadows
Moln. In-Game asset. 2d. High contrast. No shadows
Misil rikdad upp. In-Game asset. 2d. High contrast. No shadows
F-22 upp ifrån. In-Game asset. 2d. High contrast. No shadows
SR-71 uppifrån. In-Game asset. 2d. High contrast. No shadows
B-2 uppifrån. In-Game asset. 2d. High contrast. No shadows
Explosion. In-Game asset. 2d. High contrast. No shadows
A-10 uppifrån. In-Game asset. 2d. High contrast. No shadows