User prompt
"Add a special enemy unit called 'Enemy-B52' that releases small decoy explosives when a laser approaches, distracting or blocking the laser. The B52 should also attempt to dodge the laser by changing direction. Upon destruction, it causes area damage to all nearby objects within a defined radius."
User prompt
Add Enemy-B52 like an enemy
User prompt
"Change the background gradient based on screen zones: sky blue at the top (enemy spawn area), transitioning to green and brown at the bottom where the laser device stands, resembling grass and ground."
User prompt
"Divide the game into levels. With each level, increase both the player's power (laser speed, fire rate, movement) and the enemy's difficulty (speed, health, maneuverability). Rewards should also scale with each level." --- 🔹 Level 1 5 Rockets, 3 Drones, 1 F-35 Enemy health: Low Player: Normal laser speed and single beam Rewards: $1000 (Rocket), $2500 (Drone), $5000 (F-35) Score to advance: 10,000 --- 🔹 Level 2 10 Rockets, 6 Drones, 2 F-35s Enemy health: Medium, speed increased Player: Faster laser fire rate and movement Rewards: $1200 (Rocket), $3000 (Drone), $6000 (F-35) Score to advance: 25,000 --- 🔹 Level 3 15 Rockets, 9 Drones, 3 F-35s Enemy health: High, faster and agile Player: Double laser beams, high fire rate Rewards: $1500 (Rocket), $4000 (Drone), $8000 (F-35) Score to advance: 50,000
User prompt
Laser Fire Rate: From 1 shot/sec → 3 shots/sec Movement Speed: From 5 px/s → 8 px/s New Rewards: Rocket – $1000, Drone – $2500, F-35 – $10,000
User prompt
"Increase the laser firing rate and the left-right movement speed of the laser device. Also, raise the reward amounts for destroying enemies — current values are too low."
User prompt
"Set different hit points, speed, maneuverability, and rewards for each enemy: Rocket (1 hit, fast, $500), Drone/UAV (2 hits, medium speed, $1000), F-35 (3 hits, slow, agile, $5000). Also, use different laser effects for each."
User prompt
Add rockets like an enemy
User prompt
"Fix the laser movement so it doesn't get stuck when reaching the far left or right edges of the screen."
User prompt
"Disable or remove the two green square indicators near the laser device, as they block laser control when approached."
User prompt
Use gun sound only when a player pushes laser
User prompt
All UAVs and enemy aircraft are classified as hostile and will move directly towards the Zirve L-1 laser defense unit."
User prompt
“Go back to Step 2.” ➡️ Returns to the second command.
User prompt
🔹 Step 3: Add Laser Firing from Cannon Command (Step 3): > When the player taps the FIRE button, spawn a vertical green laser beam from the top center of the playerCannon. The laser should travel straight upward and destroy the first enemy it touches.
User prompt
🔹 Step 2 (repeat): Enable Horizontal Movement for the Cannon Command (Step 2): > Allow the playerCannon at the bottom of the screen to move left and right. Movement should respond to touch drag or two on-screen arrow buttons. The cannon must always stay within the screen boundaries.
Code edit (1 edits merged)
Please save this source code
User prompt
Laser Cannon Defense
Initial prompt
🔹 Step 1: Create the Player Cannon Object Command (Step 1): > Create a player-controlled laser cannon object. Place it at the bottom center of the screen, aligned to the ground. The cannon should be able to move horizontally only. Name the object: playerCannon.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Cannon = Container.expand(function () { var self = Container.call(this); var cannonGraphics = self.attachAsset('cannon', { anchorX: 0.5, anchorY: 1.0 }); self.fireRate = 0; self.maxFireRate = 15; // Fire every 15 frames at max self.update = function () { if (self.fireRate > 0) { self.fireRate--; } }; self.canFire = function () { return self.fireRate <= 0; }; self.fire = function () { if (self.canFire()) { self.fireRate = self.maxFireRate; return true; } return false; }; return self; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.health = 1; self.update = function () { self.y += self.speed; }; self.takeDamage = function () { self.health--; if (self.health <= 0) { return true; // Enemy destroyed } return false; }; return self; }); var Laser = Container.expand(function () { var self = Container.call(this); var laserGraphics = self.attachAsset('laser', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -12; self.update = function () { self.y += self.speed; }; return self; }); var Rocket = Container.expand(function () { var self = Container.call(this); var rocketGraphics = self.attachAsset('Rockets', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.health = 3; self.targetX = 0; self.targetY = 0; self.update = function () { // Move directly towards the cannon with higher speed 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; } }; self.setTarget = function (x, y) { self.targetX = x; self.targetY = y; }; self.takeDamage = function () { self.health--; if (self.health <= 0) { return true; // Rocket destroyed } return false; }; return self; }); var UAV = Container.expand(function () { var self = Container.call(this); var uavGraphics = self.attachAsset('UAV', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.health = 2; self.targetX = 0; self.targetY = 0; self.update = function () { // Move directly towards the cannon 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; } }; self.setTarget = function (x, y) { self.targetX = x; self.targetY = y; }; self.takeDamage = function () { self.health--; if (self.health <= 0) { return true; // UAV destroyed } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x001122 }); /**** * Game Code ****/ // Game variables var cannon; var lasers = []; var enemies = []; var enemySpawnTimer = 0; var enemySpawnRate = 120; // Spawn enemy every 2 seconds initially var gameSpeed = 1; var waveNumber = 1; // UI Elements var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var waveTxt = new Text2('Wave: 1', { size: 50, fill: 0xFFFF00 }); waveTxt.anchor.set(1, 0); LK.gui.topRight.addChild(waveTxt); // Initialize cannon cannon = game.addChild(new Cannon()); cannon.x = 2048 / 2; cannon.y = 2732 - 100; // Touch controls var isDragging = false; var cannonSpeed = 8; game.down = function (x, y, obj) { // Check if touch is in the cannon control area for dragging if (y > 2732 - 300) { isDragging = true; cannon.x = Math.max(60, Math.min(2048 - 60, x)); } // Fire laser on any tap/touch - gun sound plays when player pushes laser if (cannon.fire()) { var laser = new Laser(); laser.x = cannon.x; laser.y = cannon.y - 50; lasers.push(laser); game.addChild(laser); LK.getSound('shoot').play(); } }; game.move = function (x, y, obj) { if (isDragging) { cannon.x = Math.max(60, Math.min(2048 - 60, x)); } }; game.up = function (x, y, obj) { isDragging = false; }; // Spawn enemy function function spawnEnemy() { // Randomly spawn between regular enemy, UAV, or Rocket var spawnRandom = Math.random(); if (spawnRandom < 0.15) { // Spawn Rocket (15% chance) var rocket = new Rocket(); rocket.x = Math.random() * (2048 - 160) + 80; rocket.y = -100; rocket.speed = 3 + Math.random() * 1.5 + waveNumber * 0.3; rocket.setTarget(cannon.x, cannon.y); enemies.push(rocket); game.addChild(rocket); } else if (spawnRandom < 0.35) { // Spawn UAV (20% chance) var uav = new UAV(); uav.x = Math.random() * (2048 - 160) + 80; uav.y = -100; uav.speed = 2 + Math.random() * 1.5 + waveNumber * 0.2; uav.setTarget(cannon.x, cannon.y); enemies.push(uav); game.addChild(uav); } else { // Spawn regular enemy (65% chance) var enemy = new Enemy(); enemy.x = Math.random() * (2048 - 160) + 80; enemy.y = -100; enemy.speed = 1 + Math.random() * 2 + waveNumber * 0.3; enemies.push(enemy); game.addChild(enemy); } } // Update wave difficulty function updateWave() { waveNumber++; enemySpawnRate = Math.max(30, enemySpawnRate - 10); waveTxt.setText('Wave: ' + waveNumber); // Flash effect for new wave LK.effects.flashScreen(0x00FF00, 500); } // Main game loop game.update = function () { // Player-controlled laser firing - only when player touches/taps // No automatic firing - gun sound only plays when player pushes laser // Update enemy spawn timer enemySpawnTimer++; if (enemySpawnTimer >= enemySpawnRate) { spawnEnemy(); enemySpawnTimer = 0; } // Update lasers for (var i = lasers.length - 1; i >= 0; i--) { var laser = lasers[i]; if (laser.lastY === undefined) laser.lastY = laser.y; // Remove laser if off screen if (laser.lastY >= -50 && laser.y < -50) { laser.destroy(); lasers.splice(i, 1); continue; } // Check collision with enemies var hitEnemy = false; for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (laser.intersects(enemy)) { // Hit enemy LK.getSound('enemyHit').play(); if (enemy.takeDamage()) { // Enemy destroyed LK.setScore(LK.getScore() + 100); scoreTxt.setText('Score: ' + LK.getScore()); LK.getSound('enemyDestroy').play(); // Flash effect LK.effects.flashObject(enemy, 0xFFFFFF, 200); enemy.destroy(); enemies.splice(j, 1); } else { // Enemy damaged but not destroyed LK.effects.flashObject(enemy, 0xFF0000, 300); } laser.destroy(); lasers.splice(i, 1); hitEnemy = true; break; } } if (!hitEnemy) { laser.lastY = laser.y; } } // Update enemies for (var k = enemies.length - 1; k >= 0; k--) { var enemy = enemies[k]; if (enemy.lastY === undefined) enemy.lastY = enemy.y; // Update UAV and Rocket targets to track cannon if (enemy.setTarget) { enemy.setTarget(cannon.x, cannon.y); } // Check if enemy reached bottom if (enemy.y > 2732 + 100) { enemy.destroy(); enemies.splice(k, 1); continue; } // Check collision with cannon if (enemy.intersects(cannon)) { // Game over LK.effects.flashScreen(0xFF0000, 1000); LK.showGameOver(); return; } enemy.lastY = enemy.y; } // Check for wave completion and increase difficulty if (LK.ticks % 1800 === 0) { // Every 30 seconds updateWave(); } // Victory condition - survive for a long time with high score if (LK.getScore() >= 10000) { LK.showYouWin(); } };
===================================================================
--- original.js
+++ change.js
@@ -62,8 +62,41 @@
self.y += self.speed;
};
return self;
});
+var Rocket = Container.expand(function () {
+ var self = Container.call(this);
+ var rocketGraphics = self.attachAsset('Rockets', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 4;
+ self.health = 3;
+ self.targetX = 0;
+ self.targetY = 0;
+ self.update = function () {
+ // Move directly towards the cannon with higher speed
+ 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;
+ }
+ };
+ self.setTarget = function (x, y) {
+ self.targetX = x;
+ self.targetY = y;
+ };
+ self.takeDamage = function () {
+ self.health--;
+ if (self.health <= 0) {
+ return true; // Rocket destroyed
+ }
+ return false;
+ };
+ return self;
+});
var UAV = Container.expand(function () {
var self = Container.call(this);
var uavGraphics = self.attachAsset('UAV', {
anchorX: 0.5,
@@ -160,20 +193,30 @@
isDragging = false;
};
// Spawn enemy function
function spawnEnemy() {
- // Randomly spawn either regular enemy or UAV
- if (Math.random() < 0.3) {
- // Spawn UAV (30% chance)
+ // Randomly spawn between regular enemy, UAV, or Rocket
+ var spawnRandom = Math.random();
+ if (spawnRandom < 0.15) {
+ // Spawn Rocket (15% chance)
+ var rocket = new Rocket();
+ rocket.x = Math.random() * (2048 - 160) + 80;
+ rocket.y = -100;
+ rocket.speed = 3 + Math.random() * 1.5 + waveNumber * 0.3;
+ rocket.setTarget(cannon.x, cannon.y);
+ enemies.push(rocket);
+ game.addChild(rocket);
+ } else if (spawnRandom < 0.35) {
+ // Spawn UAV (20% chance)
var uav = new UAV();
uav.x = Math.random() * (2048 - 160) + 80;
uav.y = -100;
uav.speed = 2 + Math.random() * 1.5 + waveNumber * 0.2;
uav.setTarget(cannon.x, cannon.y);
enemies.push(uav);
game.addChild(uav);
} else {
- // Spawn regular enemy (70% chance)
+ // Spawn regular enemy (65% chance)
var enemy = new Enemy();
enemy.x = Math.random() * (2048 - 160) + 80;
enemy.y = -100;
enemy.speed = 1 + Math.random() * 2 + waveNumber * 0.3;
@@ -242,9 +285,9 @@
// Update enemies
for (var k = enemies.length - 1; k >= 0; k--) {
var enemy = enemies[k];
if (enemy.lastY === undefined) enemy.lastY = enemy.y;
- // Update UAV targets to track cannon
+ // Update UAV and Rocket targets to track cannon
if (enemy.setTarget) {
enemy.setTarget(cannon.x, cannon.y);
}
// Check if enemy reached bottom
F35 like fighter jet. In-Game asset. 2d. High contrast. No shadows
Overwiev of unmanned aircraft coming to us. 2d. High contrast. No shadows
Looking like real rocket. Rocket picture. In-Game asset. 2d. High contrast. No shadows
Imagine that a Big laser machine you see from upside. Stands from back to the forward. Tries to hit enemy's.. In-Game asset. 2d. High contrast. No shadows