User prompt
Gör så att plant fast ser utt som vilse fast
User prompt
Kan du göra så att man kan spela igen
User prompt
Kan du göra så att alla svårig heter har oendligt med waves
User prompt
Kan du göra så att varge peng man tar i medium är värd 1.0 pengar och vidare med +0.5
User prompt
Gör så att i medium är poäng =1.0 och i hard är poäng=1.5 och i extrem är peng =2.5
User prompt
Man ska inte kuna se shopen när man är i en mach
User prompt
Kan du göra så att alla mods har oendligt med waves
User prompt
Gör så att när man dör så sparas ens pengar och man kan anvenda dom till att köpa nya flygplan som är snabbare eller kan sluta missiler och mer ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
Gör så att pengarna har bilden po
User prompt
Kan du Ada så att man också samlar pengar på vägen lät=0.5 pär peng och plus 0.5 för varge ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kan you Ada EXTRIM MOD
User prompt
Ada wave complet nar man klarar av en wave ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Hard mod lite letar men svårare en medium
User prompt
På Hard modA-10 ett skot Pär sekund på wave 3 och SR-71 ska skuta en Misil Pär 3 sekund på wave 5 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Enkel= Easy Medium=Medium svår=Hard
User prompt
Ada enkel medium och svår så att man kan välga svårighets Gard
User prompt
Radera Enemi 4
User prompt
Det ska finas oendligt med wave
User prompt
Alla fienden dödas med 1 skot förutom Enemi 2 som dödas med 2
User prompt
Enemi 3 för snab
User prompt
Enemi1 1 bomb Pär 2,5 sekund
User prompt
När man har klarat av en wave ska det koma en text där det står WAVE COMPLETED
User prompt
Enemi 2 ska skuta et skot Pär 1.5 sekunder och skotet ska göra 0,5 skada
User prompt
Mer liv
User prompt
Mer HP
/****
* 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('player', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x00FF00
});
self.speed = 12;
self.health = 4;
self.shootRate = 8;
self.canShootMissiles = false;
} else if (self.aircraftType === 'missile') {
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFF8800
});
self.speed = 6;
self.health = 6;
self.shootRate = 12;
self.canShootMissiles = true;
self.missileTimer = 0;
}
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 () {
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);
// Back button for shop
var backButton = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 6,
tint: 0xFF0000
});
backButton.x = 1024;
backButton.y = 1400;
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 = 1400;
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 >= 1340 && y <= 1460) {
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);
}
}
} 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;
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;
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;
}
// 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) {
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;
}
// 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
enemiesPerWave = 5 + currentWave * 2; // Increase enemies per wave indefinitely
maxEnemySpawnRate = Math.max(15, 60 - currentWave * 2); // Faster spawning each wave, minimum 15 ticks
waveTxt.setText('Wave: ' + currentWave);
}
if (waveInProgress && enemiesSpawnedThisWave < enemiesPerWave) {
enemySpawnTimer++;
if (enemySpawnTimer > maxEnemySpawnRate) {
// Randomly choose enemy type
var 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
enemy.speed += Math.floor(currentWave / 3);
enemies.push(enemy);
game.addChild(enemy);
enemySpawnTimer = 0;
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)) {
money += coin.value;
// Add bonus score based on difficulty level
var coinPoints = 0.5; // Default for easy
if (difficulty === 'medium') {
coinPoints = 1.0;
} else if (difficulty === 'hard') {
coinPoints = 1.5;
} else if (difficulty === 'extreme') {
coinPoints = 2.5;
}
score += coinPoints;
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;
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1208,10 +1208,18 @@
}
// Check coin-player collision
if (coin.intersects(player)) {
money += coin.value;
- // Add bonus score based on money collected (0.5 for each coin)
- score += money * 0.5;
+ // Add bonus score based on difficulty level
+ var coinPoints = 0.5; // Default for easy
+ if (difficulty === 'medium') {
+ coinPoints = 1.0;
+ } else if (difficulty === 'hard') {
+ coinPoints = 1.5;
+ } else if (difficulty === 'extreme') {
+ coinPoints = 2.5;
+ }
+ score += coinPoints;
LK.setScore(score);
scoreTxt.setText('Score: ' + score);
moneyTxt.setText('Money: ' + money.toFixed(1));
// Visual effect for coin collection
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