User prompt
שיהיה ברקע של המשחק, רק במהלך המשחק בלי המסך הראשי, כל הזמן המון נקודות קטנות כאלה. ביום הם יהיו בצבע ירוק כהה, בלילה הם יהיו בצבע לבן. קטנים ובהירים, חלק מהרקע, זזים כל הזמן ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
תשתמש באפקטים הזוהרים של הלילה, כל שנייה וחצי במהלך הזמן של הלילה. תגביר את הזוהר באפקט ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
תוריד ל9 שניות את הזמן חיים המקסימלי של טיל באוויר
User prompt
כאשר הרקע הופך להיות כהה, תשתמש באפקטים ושהכל יהיה זוהר כאשר נפגעים מטיל ויורד חיים, שכל המסך יהבהב לרגע בצבע אדום ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
כאשר המשחק במצב לילה, תעשה שכל הטילים וכל האלמנטים במשחק זוהרים ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
אחרי שהמשחק נטען, תהפוך את הרקע לחום מדברי. אחרי 20 שניות של משחק הרקע הופך למדברי אבל מאוד כהה ודומה ללילה, ואחרי עוד 10 שניות חוזר להיות מדברי. ואז שוב, 20 שניות והופך ללילה, 10 שניות ולמדברי ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Raise up the B-2 Mission raise up and make bigger the start button The legend and instructions: make much bigger, the text and the symbols
User prompt
Add the flare symbol near the flare instruction
User prompt
Delete the Click mouse to fire Move mouse forward ti drop bomb Shake mouse ti use flares and add under cannon: Flares - Shake the mouse left and right to use
User prompt
Remove the explain that write with the white colour at the start page
User prompt
תסיר את ההסבר על ההזזות של העכבר תגביה את כפתור הstart תגביה את כל ההסברים. בהסבר על הפצצה תכתוב שצריך להזיז את העכבר קדימה, בהסבר על התותח תכתוב ללחוץ על הכבר
User prompt
במסך הראשי, שכל הרקע יהיה שחור. הכל הכל, לא רק מאחורי הStart
User prompt
אל תכתוב במילים. תראה את הבניינים ואת הסוללה, ותכתוב באמצעות פצצות ותראה את הפצצה תראה את הרכבים ותכתוב עם תותח רגיל ותראה אותו תעשה מקרא של כל המבנים והרכבים, כמה כל אחד נותן בניקוד
User prompt
The title should be "B-2 Mission". At the bottom of the screen, display the following instructions along with an illustration of a mouse showing the actions: Move the mouse to control the bomber Click the mouse to fire Drag the mouse forward to drop bombs Shake the mouse to use flares explain that: Buildings and S-300 can be destroyd using bombs only Cars with the main cannon
User prompt
Please fix the bug: 'ReferenceError: updateFlareDisplay is not defined' in or related to this line: 'updateFlareDisplay();' Line Number: 138
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'x')' in or related to this line: 'missile.targetX = fighterJet.x;' Line Number: 237
User prompt
Please fix the bug: 'ReferenceError: missiles is not defined' in or related to this line: 'for (var i = 0; i < missiles.length; i++) {' Line Number: 156
User prompt
Please fix the bug: 'ReferenceError: scrollSpeed is not defined' in or related to this line: 'self.y += scrollSpeed;' Line Number: 200
User prompt
Please fix the bug: 'ReferenceError: scrollSpeed is not defined' in or related to this line: 'self.y += scrollSpeed;' Line Number: 200
User prompt
Please fix the bug: 'Uncaught ReferenceError: getPointsForTarget is not defined' in or related to this line: 'self.points = getPointsForTarget(targetType);' Line Number: 190
User prompt
Please fix the bug: 'Uncaught ReferenceError: getPointsForTarget is not defined' in or related to this line: 'self.points = getPointsForTarget(targetType);' Line Number: 190
User prompt
Please fix the bug: 'Uncaught ReferenceError: getPointsForTarget is not defined' in or related to this line: 'self.points = getPointsForTarget(targetType);' Line Number: 190
User prompt
Please fix the bug: 'Uncaught ReferenceError: fighterJet is not defined' in or related to this line: 'fighterJet.x = 1024;' Line Number: 375
User prompt
תוסיף מסך לפני שהמשחק נטען. בהתחלה יש רק את המסך, כשמתחילים לשחק, המסך הזה נסגר ומתחיל המשחק. 2 מסכים שונים. במסך הזה יהיה כפתור start
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'bullet.x = fighterJet.x;' Line Number: 930
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bomb = Container.expand(function () { var self = Container.call(this); var bombGraphics = self.attachAsset('bomb', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.targetX = 0; self.targetY = 0; self.update = function () { // Basic fallback movement if no tween is active if (!self.targetX && !self.targetY) { 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.lastX = 0; self.lastY = 0; self.stuckTimer = 0; self.update = function () { self.y += self.speed; // Track last position to detect if bullet is stuck var moveThreshold = 2; // Minimum movement required var dx = Math.abs(self.x - self.lastX); var dy = Math.abs(self.y - self.lastY); var totalMovement = dx + dy; // If bullet hasn't moved enough, increment stuck timer if (totalMovement < moveThreshold) { self.stuckTimer++; } else { self.stuckTimer = 0; // Reset timer if bullet is moving } // If stuck for more than 3 seconds (180 frames at 60fps), mark for destruction if (self.stuckTimer >= 180) { self.destroy(); return; } // Store current position for next frame comparison self.lastX = self.x; self.lastY = self.y; }; return self; }); var DestructionMark = Container.expand(function () { var self = Container.call(this); var markGraphics = self.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); markGraphics.tint = 0x000000; // Black color markGraphics.alpha = 0.8; self.update = function () { self.y += scrollSpeed; // Move with ground scroll }; return self; }); var Explosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); self.lifespan = 30; self.update = function () { self.lifespan--; self.alpha = self.lifespan / 30; if (self.lifespan <= 0) { self.destroy(); } }; return self; }); var FighterJet = Container.expand(function () { var self = Container.call(this); var jetGraphics = self.attachAsset('fighterJet', { anchorX: 0.5, anchorY: 0.5 }); var bombTargetCircle = self.attachAsset('bombTarget', { anchorX: 0.5, anchorY: 0.5 }); bombTargetCircle.y = -400; // Position much further in front of the jet bombTargetCircle.alpha = 0.6; bombTargetCircle.visible = false; self.bombTargetCircle = bombTargetCircle; self.lives = 3; self.flareCount = 3; self.maxFlares = 3; self.flareRechargeTimer = 0; self.aaSystemsDestroyed = 0; self.update = function () { // Recharge flares over time if (self.flareCount < self.maxFlares) { self.flareRechargeTimer++; if (self.flareRechargeTimer >= 150) { // 2.5 seconds at 60fps self.flareCount++; self.flareRechargeTimer = 0; updateFlareDisplay(); } } }; return self; }); var Flare = Container.expand(function () { var self = Container.call(this); var flareGraphics = self.attachAsset('flare', { anchorX: 0.5, anchorY: 0.5 }); self.lifespan = 240; // 4 seconds at 60fps self.update = function () { self.lifespan--; // Track nearest missile var nearestMissile = null; var nearestDistance = Infinity; for (var i = 0; i < missiles.length; i++) { var missile = missiles[i]; var dx = missile.x - self.x; var dy = missile.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < nearestDistance) { nearestDistance = distance; nearestMissile = missile; } } // Move towards nearest missile if within tracking range if (nearestMissile && nearestDistance < 300) { var dx = nearestMissile.x - self.x; var dy = nearestMissile.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.x += dx / distance * 8; self.y += dy / distance * 8; } } // Destroy flare after 4 seconds no matter what if (self.lifespan <= 0) { self.destroy(); } }; return self; }); var GroundTarget = Container.expand(function (targetType) { var self = Container.call(this); var targetGraphics = self.attachAsset(targetType, { anchorX: 0.5, anchorY: 0.5 }); self.targetType = targetType; self.points = getPointsForTarget(targetType); self.canShootMissiles = targetType === 's300System'; self.missileTimer = 0; // Set random movement direction for vehicles (only once at creation) if (targetType === 'car' || targetType === 'armyVan') { self.moveDirection = Math.random() < 0.5 ? -4 : 4; // Either -4 (left) or 4 (right) } else { self.moveDirection = 0; } self.update = function () { self.y += scrollSpeed; // Movement for cars and army vans in one consistent direction if (self.targetType === 'car' || self.targetType === 'armyVan') { // Move consistently in the chosen direction self.x += self.moveDirection; // Mirror vehicle to face movement direction if (self.moveDirection > 0) { // Moving right - no flip needed (default orientation) targetGraphics.scale.x = Math.abs(targetGraphics.scale.x); } else { // Moving left - flip horizontally targetGraphics.scale.x = -Math.abs(targetGraphics.scale.x); } // Keep vehicles within screen bounds and reverse direction if hitting edges if (self.x < 50) { self.x = 50; self.moveDirection = Math.abs(self.moveDirection); // Force positive direction } if (self.x > 1998) { self.x = 1998; self.moveDirection = -Math.abs(self.moveDirection); // Force negative direction } } // S-300 systems shoot missiles at the player if (self.canShootMissiles && self.y > 200 && self.y < 2000) { self.missileTimer++; if (self.missileTimer >= 180) { // Every 3 seconds self.fireMissile(); self.missileTimer = 0; } } }; self.fireMissile = function () { var missile = new Missile(); missile.x = self.x; missile.y = self.y; missile.targetX = fighterJet.x; missile.targetY = fighterJet.y; missiles.push(missile); game.addChild(missile); LK.getSound('missile').play(); }; return self; }); var Missile = Container.expand(function () { var self = Container.call(this); var missileGraphics = self.attachAsset('missile', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 6; self.targetX = 0; self.targetY = 0; self.lastX = 0; self.lastY = 0; self.stuckTimer = 0; self.bottomTimer = 0; // Track time spent in bottom area self.lifeTimer = 600; // 10 seconds at 60fps self.update = function () { // Decrease lifespan timer self.lifeTimer--; if (self.lifeTimer <= 0) { self.destroy(); return; } // Track last position to detect if missile is stuck var moveThreshold = 2; // Minimum movement required var dx = Math.abs(self.x - self.lastX); var dy = Math.abs(self.y - self.lastY); var totalMovement = dx + dy; // If missile hasn't moved enough, increment stuck timer if (totalMovement < moveThreshold) { self.stuckTimer++; } else { self.stuckTimer = 0; // Reset timer if missile is moving } // If stuck for more than 3 seconds (180 frames at 60fps), mark for destruction if (self.stuckTimer >= 180) { self.destroy(); return; } // Check if missile is in bottom 20% of screen (2732 * 0.8 = 2185.6) if (self.y > 2185) { self.bottomTimer++; } else { self.bottomTimer = 0; // Reset timer if missile leaves bottom area } // If missile has been in bottom area for more than 3 seconds (180 frames at 60fps), mark for destruction if (self.bottomTimer >= 180) { self.destroy(); return; } // Store current position for next frame comparison self.lastX = self.x; self.lastY = self.y; // Move towards target (fighter jet) var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var gameStarted = false; var startScreen = null; var startButton = null; var fighterJet = null; var scrollSpeed = 3; var missiles = []; // Create start screen startScreen = new Container(); game.addChild(startScreen); // Add title text var titleText = new Text2('B-2 Mission', { size: 120, fill: '#ffffff' }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 800; startScreen.addChild(titleText); // Create start button startButton = LK.getAsset('road', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.8 }); startButton.x = 1024; startButton.y = 1400; startButton.tint = 0x27ae60; startScreen.addChild(startButton); // Add button text var buttonText = new Text2('START', { size: 80, fill: '#ffffff' }); buttonText.anchor.set(0.5, 0.5); buttonText.x = 1024; buttonText.y = 1400; startScreen.addChild(buttonText); // Add instructions at bottom var instructionsText = new Text2('Move mouse to control bomber\nClick mouse to fire\nDrag mouse forward to drop bombs\nShake mouse to use flares', { size: 50, fill: '#ffffff', align: 'center' }); instructionsText.anchor.set(0.5, 1); instructionsText.x = 1024; instructionsText.y = 2600; startScreen.addChild(instructionsText); // Add mouse illustration var mouseIllustration = LK.getAsset('road', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.15, scaleY: 0.4 }); mouseIllustration.x = 1024; mouseIllustration.y = 2200; mouseIllustration.tint = 0xcccccc; startScreen.addChild(mouseIllustration); // Add legend container var legendContainer = new Container(); startScreen.addChild(legendContainer); // Legend title var legendTitle = new Text2('TARGET LEGEND', { size: 60, fill: '#ffffff' }); legendTitle.anchor.set(0.5, 0.5); legendTitle.x = 1024; legendTitle.y = 1650; startScreen.addChild(legendTitle); // Create legend entries with visual representations var legendY = 1750; var legendSpacing = 120; // Buildings (Civilian) - Bombs only var civilianBuildingGraphic = LK.getAsset('building', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.3 }); civilianBuildingGraphic.x = 300; civilianBuildingGraphic.y = legendY; startScreen.addChild(civilianBuildingGraphic); var civilianBuildingText = new Text2('Civilian Building: -10 pts (Bombs Only)', { size: 40, fill: '#ff6666' }); civilianBuildingText.anchor.set(0, 0.5); civilianBuildingText.x = 400; civilianBuildingText.y = legendY; startScreen.addChild(civilianBuildingText); // Target Buildings (Military) - Bombs only legendY += legendSpacing; var targetBuildingGraphic = LK.getAsset('targetBuilding', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.3 }); targetBuildingGraphic.x = 300; targetBuildingGraphic.y = legendY; startScreen.addChild(targetBuildingGraphic); var targetBuildingText = new Text2('Military Building: +10 pts (Bombs Only)', { size: 40, fill: '#66ff66' }); targetBuildingText.anchor.set(0, 0.5); targetBuildingText.x = 400; targetBuildingText.y = legendY; startScreen.addChild(targetBuildingText); // S-300 Systems - Bombs only legendY += legendSpacing; var s300Graphic = LK.getAsset('s300System', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.4, scaleY: 0.4 }); s300Graphic.x = 300; s300Graphic.y = legendY; startScreen.addChild(s300Graphic); var s300Text = new Text2('S-300 System: +15 pts (Bombs Only)', { size: 40, fill: '#66ff66' }); s300Text.anchor.set(0, 0.5); s300Text.x = 400; s300Text.y = legendY; startScreen.addChild(s300Text); // Civilian Cars - Cannon only legendY += legendSpacing; var carGraphic = LK.getAsset('car', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.4, scaleY: 0.4 }); carGraphic.x = 300; carGraphic.y = legendY; startScreen.addChild(carGraphic); var carText = new Text2('Civilian Car: -5 pts (Cannon Only)', { size: 40, fill: '#ff6666' }); carText.anchor.set(0, 0.5); carText.x = 400; carText.y = legendY; startScreen.addChild(carText); // Army Vans - Cannon only legendY += legendSpacing; var armyVanGraphic = LK.getAsset('armyVan', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.4, scaleY: 0.4 }); armyVanGraphic.x = 300; armyVanGraphic.y = legendY; startScreen.addChild(armyVanGraphic); var armyVanText = new Text2('Army Van: +5 pts (Cannon Only)', { size: 40, fill: '#66ff66' }); armyVanText.anchor.set(0, 0.5); armyVanText.x = 400; armyVanText.y = legendY; startScreen.addChild(armyVanText); // Add weapon demonstrations var weaponY = 2300; var bombGraphic = LK.getAsset('bomb', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); bombGraphic.x = 400; bombGraphic.y = weaponY; startScreen.addChild(bombGraphic); var bombWeaponText = new Text2('BOMB - Destroys Buildings & S-300', { size: 45, fill: '#ffff00' }); bombWeaponText.anchor.set(0, 0.5); bombWeaponText.x = 500; bombWeaponText.y = weaponY; startScreen.addChild(bombWeaponText); weaponY += 80; var bulletGraphic = LK.getAsset('bullet', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); bulletGraphic.x = 400; bulletGraphic.y = weaponY; startScreen.addChild(bulletGraphic); var bulletWeaponText = new Text2('CANNON - Destroys Vehicles Only', { size: 45, fill: '#ffff00' }); bulletWeaponText.anchor.set(0, 0.5); bulletWeaponText.x = 500; bulletWeaponText.y = weaponY; startScreen.addChild(bulletWeaponText); // Add target explanation var targetExplanationText = new Text2('Buildings and S-300 can be destroyed using bombs only\nCars with the main cannon', { size: 45, fill: '#ffff00', align: 'center' }); targetExplanationText.anchor.set(0.5, 0.5); targetExplanationText.x = 1024; targetExplanationText.y = 1550; startScreen.addChild(targetExplanationText); // Handle start button click startButton.down = function (x, y, obj) { if (gameStarted) return; gameStarted = true; startScreen.destroy(); // Initialize game after start button is clicked initializeGame(); }; function getPointsForTarget(targetType) { switch (targetType) { case 'building': return -10; // Civilian building penalty case 'targetBuilding': return 10; // Military building points case 'car': return -5; // Regular truck penalty case 'armyVan': return 5; // Military truck points case 's300System': return 15; // S-300 system points default: return 10; } } function updateFlareDisplay() { if (fighterJet && fighterJet.flareCount !== undefined) { var flareText = LK.gui.top.children.find(function (child) { return child.text && child.text.includes('Flares:'); }); if (flareText) { flareText.setText('Flares: ' + fighterJet.flareCount); } } } function initializeGame() { // Create fighter jet instance fighterJet = new FighterJet(); game.addChild(fighterJet); fighterJet.x = 1024; fighterJet.y = 2200; var bullets = []; var bombs = []; var flares = []; var groundTargets = []; var explosions = []; var destructionMarks = []; var spawnTimer = 0; var gameSpeed = 1; var roadSystem = { roads: [], // Array to track active roads roadGraphics: [], // Array to track road graphics for movement nextRoadTime: 0, // Time for next road generation roadHeight: 80, // Height of road area generateNewRoad: true // Flag to generate road immediately at start }; var bombKeyPressed = false; var flareKeyPressed = false; var keyStates = {}; var fKeyPressed = false; var bKeyPressed = false; var lastMouseX = 0; var lastMouseY = 0; // Store bomb target position when bomb is released var bombTargetX = 0; var bombTargetY = 0; var bombCooldown = 0; var bombingActive = true; var bombTargetMarked = false; // UI Elements var scoreText = new Text2('Score: 0', { size: 60, fill: '#ffffff' }); scoreText.anchor.set(0, 0); scoreText.x = 150; scoreText.y = 50; LK.gui.topLeft.addChild(scoreText); var livesText = new Text2('Lives: 3', { size: 60, fill: '#ffffff' }); livesText.anchor.set(1, 0); LK.gui.topRight.addChild(livesText); var flareText = new Text2('Flares: 3', { size: 60, fill: '#ffffff' }); flareText.anchor.set(0.5, 0); LK.gui.top.addChild(flareText); var bombingText = new Text2('Bombing: Active', { size: 60, fill: '#ffffff' }); bombingText.anchor.set(0.5, 0); bombingText.y = 70; LK.gui.top.addChild(bombingText); function updateScore() { scoreText.setText('Score: ' + LK.getScore()); } function updateLivesDisplay() { livesText.setText('Lives: ' + fighterJet.lives); } function updateFlareDisplay() { flareText.setText('Flares: ' + fighterJet.flareCount); } function updateBombingDisplay() { bombingText.setText('Bombing: ' + (bombingActive ? 'Active' : 'Disabled')); } function generateRoadStructure() { // Check if we need to create a new road based on time if (roadSystem.generateNewRoad || LK.ticks >= roadSystem.nextRoadTime) { // Create new road at top of screen (y = 0) var roadY = 0; var road = { y: roadY, hasVehicles: true, // Always have vehicles (minimum 1) hasBuildings: true, // Always have buildings (minimum 1) vehicleCount: Math.floor(Math.random() * 4) + 1, // 1-4 vehicles buildingCount: Math.floor(Math.random() * 3) + 1 // 1-3 buildings }; roadSystem.roads.push(road); // Draw the actual road var roadGraphics = LK.getAsset('road', { anchorX: 0.5, anchorY: 0.5 }); roadGraphics.x = 1024; // Center of screen roadGraphics.y = roadY; roadSystem.roadGraphics.push(roadGraphics); game.addChild(roadGraphics); // Spawn vehicles on road (always at least 1) for (var v = 0; v < road.vehicleCount; v++) { var vehicleType = Math.random() < 0.6 ? 'car' : 'armyVan'; var vehicle = new GroundTarget(vehicleType); vehicle.x = Math.random() * 1700 + 174; // Increased travel distance vehicle.y = roadY; groundTargets.push(vehicle); game.addChild(vehicle); } // Spawn buildings adjacent to road (above it) - always at least 1 var placedBuildings = []; // Track placed building positions for (var b = 0; b < road.buildingCount; b++) { var buildingType; var rand = Math.random(); if (rand < 0.4) { buildingType = 'building'; } else if (rand < 0.8) { buildingType = 'targetBuilding'; } else if (rand < 0.82) { buildingType = 's300System'; } else { buildingType = 's300System'; } // Find valid position with minimum spacing var attempts = 0; var validPosition = false; var buildingX, buildingY; while (!validPosition && attempts < 20) { buildingX = Math.random() * 1400 + 324; // Slightly more constrained buildingY = roadY - 150; // Position above road validPosition = true; // Check distance from other buildings for (var pb = 0; pb < placedBuildings.length; pb++) { var placedBuilding = placedBuildings[pb]; var dx = buildingX - placedBuilding.x; var dy = buildingY - placedBuilding.y; var distance = Math.sqrt(dx * dx + dy * dy); // Minimum distance of 250 pixels between buildings if (distance < 250) { validPosition = false; break; } } attempts++; } // Only place building if valid position found if (validPosition) { var building = new GroundTarget(buildingType); building.x = buildingX; // Raise regular buildings by 25 pixels (original 5 + additional 20) if (buildingType === 'building') { building.y = buildingY - 25; } else if (buildingType === 's300System') { building.y = buildingY + 5; // Lower military buildings by 5 pixels } else { building.y = buildingY; } placedBuildings.push({ x: buildingX, y: buildingY }); groundTargets.push(building); game.addChild(building); } } // Calculate next road time: 5.5 seconds average ± 1.5 seconds (330 ± 90 ticks at 60fps) var baseTime = 330; // 5.5 seconds at 60fps var variance = 180; // ±3 seconds total range (1.5 second variance) var nextRoadDelay = baseTime + (Math.random() * variance - variance / 2); roadSystem.nextRoadTime = LK.ticks + nextRoadDelay; roadSystem.generateNewRoad = false; } } function spawnAntiAircraftSystems() { // Spawn S-300 systems in dead zones between roads if (Math.random() < 0.13) { // 13% chance per spawn cycle var s300 = new GroundTarget('s300System'); s300.x = Math.random() * 1600 + 224; s300.y = -100 - Math.random() * 200; // In dead zone area groundTargets.push(s300); game.addChild(s300); } } function spawnGroundTarget() { // This function is now called less frequently and handles structured generation generateRoadStructure(); spawnAntiAircraftSystems(); } function createExplosion(x, y) { var explosion = new Explosion(); explosion.x = x; explosion.y = y; explosions.push(explosion); game.addChild(explosion); LK.getSound('explosion').play(); } function checkMissileFlareCollision(missile) { for (var f = flares.length - 1; f >= 0; f--) { var flare = flares[f]; if (missile.intersects(flare)) { // Flare explodes and destroys missiles in radius createExplosion(flare.x, flare.y); // Destroy all missiles within explosion radius for (var m = missiles.length - 1; m >= 0; m--) { var targetMissile = missiles[m]; var dx = targetMissile.x - flare.x; var dy = targetMissile.y - flare.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 150) { // Explosion radius createExplosion(targetMissile.x, targetMissile.y); LK.setScore(LK.getScore() + 1); // +1 point for missile destruction by flare updateScore(); targetMissile.destroy(); missiles.splice(m, 1); } } flare.destroy(); flares.splice(f, 1); return true; } } return false; } // Generate first road at game start generateRoadStructure(); // Event handlers game.move = function (x, y, obj) { fighterJet.x = x; fighterJet.y = y; // Improved keyboard input simulation with better detection var deltaX = Math.abs(x - lastMouseX); var deltaY = Math.abs(y - lastMouseY); // F key simulation: horizontal movement with more sensitive detection if (deltaX > 30 && deltaY < 30) { fKeyPressed = true; } else { fKeyPressed = false; } // B key simulation: vertical movement with more sensitive detection if (deltaY > 30 && deltaX < 30) { bKeyPressed = true; } else { bKeyPressed = false; } lastMouseX = x; lastMouseY = y; }; game.down = function (x, y, obj) { // Check for special input zones for keyboard simulation if (y < 200 && x < 300) { // Top-left corner click - fire flare (F key simulation) if (fighterJet.flareCount > 0) { var flare = new Flare(); flare.x = fighterJet.x + (Math.random() - 0.5) * 100; flare.y = fighterJet.y + (Math.random() - 0.5) * 100; flares.push(flare); game.addChild(flare); fighterJet.flareCount--; updateFlareDisplay(); LK.getSound('flare').play(); } return; } else if (y < 200 && x > 1748) { // Top-right corner click - drop bomb (B key simulation) var bomb = new Bomb(); bomb.x = fighterJet.x; bomb.y = fighterJet.y + 50; bombs.push(bomb); game.addChild(bomb); LK.getSound('bomb').play(); return; } if (obj.event && obj.event.button === 0) { // Left click - fire bullet var bullet = new Bullet(); bullet.x = fighterJet.x; bullet.y = fighterJet.y - 50; bullets.push(bullet); game.addChild(bullet); LK.getSound('shoot').play(); } else if (obj.event && obj.event.button === 2) { // Right click - drop bomb var bomb = new Bomb(); bomb.x = fighterJet.x; bomb.y = fighterJet.y + 50; bombs.push(bomb); game.addChild(bomb); LK.getSound('bomb').play(); } else if (!obj.event) { // Default action for touch/tap (no event object) - fire bullet var bullet = new Bullet(); bullet.x = fighterJet.x; bullet.y = fighterJet.y - 50; bullets.push(bullet); game.addChild(bullet); LK.getSound('shoot').play(); } }; game.update = function () { // Handle keyboard input - using LK tick-based simulation // Since document is not available, we'll use mouse position changes to detect special actions var currentFlareKeyPressed = false; // Will be triggered by specific mouse positions var currentBombKeyPressed = false; // Will be triggered by specific mouse positions // Fire flare on F key press (only once per press) if (fKeyPressed && !flareKeyPressed && fighterJet.flareCount > 0) { var flare = new Flare(); flare.x = fighterJet.x + (Math.random() - 0.5) * 100; flare.y = fighterJet.y + (Math.random() - 0.5) * 100; flares.push(flare); game.addChild(flare); fighterJet.flareCount--; updateFlareDisplay(); LK.getSound('flare').play(); } flareKeyPressed = fKeyPressed; // Handle bomb cooldown if (bombCooldown > 0) { bombCooldown--; if (bombCooldown === 0) { bombingActive = true; updateBombingDisplay(); } } // Drop bomb on B key press (only once per press) if (bKeyPressed && !bombKeyPressed && bombingActive) { if (!bombTargetMarked) { // Calculate exact target position based on circle's current position, 55 pixels behind bombTargetX = fighterJet.x + fighterJet.bombTargetCircle.x; bombTargetY = fighterJet.y + fighterJet.bombTargetCircle.y + 60; bombTargetMarked = true; // Create and drop the bomb var bomb = new Bomb(); bomb.x = fighterJet.x; bomb.y = fighterJet.y + 50; bomb.targetX = bombTargetX; bomb.targetY = bombTargetY; // Animate bomb falling to target position tween(bomb, { x: bombTargetX, y: bombTargetY }, { duration: 2000, easing: tween.easeIn, onFinish: function onFinish() { // Create big explosion at exact target createExplosion(bombTargetX, bombTargetY); // Create persistent destruction mark var destructionMark = new DestructionMark(); destructionMark.x = bombTargetX; destructionMark.y = bombTargetY; destructionMarks.push(destructionMark); game.addChild(destructionMark); // Destroy ground targets in explosion radius for (var gt = groundTargets.length - 1; gt >= 0; gt--) { var target = groundTargets[gt]; var dx = target.x - bombTargetX; var dy = target.y - bombTargetY; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 200) { // Big explosion radius createExplosion(target.x, target.y); LK.setScore(LK.getScore() + target.points); updateScore(); if (target.targetType === 's300System') { fighterJet.aaSystemsDestroyed++; if (fighterJet.aaSystemsDestroyed >= 5 && fighterJet.lives < 3) { fighterJet.lives++; fighterJet.aaSystemsDestroyed = 0; updateLivesDisplay(); } } target.destroy(); groundTargets.splice(gt, 1); } } // Remove and destroy the bomb after explosion bomb.destroy(); for (var i = bombs.length - 1; i >= 0; i--) { if (bombs[i] === bomb) { bombs.splice(i, 1); break; } } // Start cooldown bombCooldown = 60; // 1 second at 60fps bombingActive = false; bombTargetMarked = false; updateBombingDisplay(); } }); bombs.push(bomb); game.addChild(bomb); LK.getSound('bomb').play(); } } bombKeyPressed = bKeyPressed; spawnTimer++; // Generate road structures and spawn targets if (spawnTimer >= 30) { // Every 0.5 seconds for more frequent spawning spawnGroundTarget(); spawnTimer = 0; } // Update road system - move roads with scroll speed and clean up for (var r = roadSystem.roads.length - 1; r >= 0; r--) { var road = roadSystem.roads[r]; // Move road down with scroll speed road.y += scrollSpeed; // Move corresponding road graphics if (roadSystem.roadGraphics[r]) { roadSystem.roadGraphics[r].y += scrollSpeed; } // Remove roads that are off screen if (road.y > 2800) { // Destroy road graphics if (roadSystem.roadGraphics[r]) { roadSystem.roadGraphics[r].destroy(); roadSystem.roadGraphics.splice(r, 1); } roadSystem.roads.splice(r, 1); } } // Show bomb target circle when mouse is in bombing position if (fighterJet.y < 2500) { fighterJet.bombTargetCircle.visible = true; } else { fighterJet.bombTargetCircle.visible = false; } // Update bullets for (var b = bullets.length - 1; b >= 0; b--) { var bullet = bullets[b]; if (bullet.y < -50) { bullet.destroy(); bullets.splice(b, 1); continue; } // Check bullet vs ground targets for (var gt = groundTargets.length - 1; gt >= 0; gt--) { var target = groundTargets[gt]; if (bullet.intersects(target)) { // Only allow bullets to destroy certain targets - not S-300, missile buildings, or regular buildings if (target.targetType === 's300System' || target.targetType === 'targetBuilding' || target.targetType === 'building') { // Bullets cannot destroy S-300 systems, missile buildings, or regular buildings bullet.destroy(); bullets.splice(b, 1); break; } createExplosion(target.x, target.y); // Apply scoring based on target type LK.setScore(LK.getScore() + target.points); updateScore(); bullet.destroy(); bullets.splice(b, 1); target.destroy(); groundTargets.splice(gt, 1); break; } } } // Update bombs - cleanup only for (var bo = bombs.length - 1; bo >= 0; bo--) { var bomb = bombs[bo]; if (bomb.destroyed) { bombs.splice(bo, 1); } } // Update missiles for (var m = missiles.length - 1; m >= 0; m--) { var missile = missiles[m]; // Skip if missile doesn't exist (already removed) if (!missile) { continue; } // Update missile target to current fighter jet position missile.targetX = fighterJet.x; missile.targetY = fighterJet.y; // Check if missile was intercepted by flare if (checkMissileFlareCollision(missile)) { missiles.splice(m, 1); continue; } // Check missile vs fighter jet (only the jet graphics, not the targeting circle) // Calculate distance to jet center for more precise collision var dx = missile.x - fighterJet.x; var dy = missile.y - fighterJet.y; var distance = Math.sqrt(dx * dx + dy * dy); // Only consider collision if missile is close to the actual jet (not the targeting circle) if (distance < 60) { // Jet is 120x80, so radius of ~60 should cover the jet body createExplosion(fighterJet.x, fighterJet.y); fighterJet.lives--; updateLivesDisplay(); if (fighterJet.lives <= 0) { LK.showGameOver(); return; } missile.destroy(); missiles.splice(m, 1); continue; } // Remove missiles that go off screen if (missile.y > 2800 || missile.y < -50 || missile.x < -50 || missile.x > 2100) { missile.destroy(); missiles.splice(m, 1); } } // Update ground targets for (var gt = groundTargets.length - 1; gt >= 0; gt--) { var target = groundTargets[gt]; if (target.y > 2800) { target.destroy(); groundTargets.splice(gt, 1); } } // Update flares for (var f = flares.length - 1; f >= 0; f--) { var flare = flares[f]; if (flare.destroyed) { flares.splice(f, 1); } } // Update explosions for (var e = explosions.length - 1; e >= 0; e--) { var explosion = explosions[e]; if (explosion.destroyed) { explosions.splice(e, 1); } } // Update destruction marks for (var dm = destructionMarks.length - 1; dm >= 0; dm--) { var destructionMark = destructionMarks[dm]; if (destructionMark.y > 2800) { destructionMark.destroy(); destructionMarks.splice(dm, 1); } } }; }
===================================================================
--- original.js
+++ change.js
@@ -286,9 +286,9 @@
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0xc19a6b
+ backgroundColor: 0x000000
});
/****
* Game Code
@@ -301,19 +301,8 @@
var missiles = [];
// Create start screen
startScreen = new Container();
game.addChild(startScreen);
-// Add background for start screen
-var startBackground = LK.getAsset('road', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1,
- scaleY: 10
-});
-startBackground.x = 1024;
-startBackground.y = 1366;
-startBackground.tint = 0x2c3e50;
-startScreen.addChild(startBackground);
// Add title text
var titleText = new Text2('B-2 Mission', {
size: 120,
fill: '#ffffff'
B-2 bombing jet. In-Game asset. 2d. High contrast. No shadows
S-300 Anti Air system from the bird view. In-Game asset. 2d. High contrast. No shadows
Hi-Teck buikding. In-Game asset. 2d. High contrast. No shadows
Tiny missile pointing up. In-Game asset. 2d. High contrast. No shadows
Strait anti air missile. In-Game asset. 2d. High contrast. No shadows
strait flare missile. In-Game asset. 2d. High contrast. No shadows
WW2 bomb. In-Game asset. 2d. High contrast. No shadows
Army building. In-Game asset. 2d. High contrast. No shadows
רכב צבאי ארוך וגדול, כמו תובלתית, מכוסה בברזנט, מבט מהפרופיל.
Missiles storage. In-Game asset. 2d. High contrast. No shadows
מתקן ענק לשיגור טיל שעליו מוכן טיל גרעיני. In-Game asset. 2d. High contrast. No shadows