User prompt
make helicopter no automatic shoot
User prompt
smugler boay cannot shoot
User prompt
fix smugler boat bugs
User prompt
begin from level 0
User prompt
smugler boat can shoot attack
User prompt
make helicopter slowly movement
User prompt
just one bullet per taping
User prompt
erase virtual keypad
User prompt
make helicopter just moving horizontal
User prompt
make helicopter easy to control
User prompt
make multiple virtual keypad look like nes controler
User prompt
make virtual keypad for game
User prompt
create separate parts to move the helicopter and shoot bullets
User prompt
make manualy control helicopter
User prompt
the frequent appearance of civilian boats
User prompt
make touch pad for controlling helicopter
User prompt
make easy controling helicopter
User prompt
add more civilian boat appear
User prompt
manual shoot
User prompt
reduce the appearance of civilian boats
Code edit (1 edits merged)
Please save this source code
User prompt
Sea Patrol: Helicopter Warfare
Initial prompt
make game war helicopter shoot drugs smugler boat at ocean blue
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Boat = Container.expand(function (isSmuggler, speed) {
var self = Container.call(this);
var assetId = isSmuggler ? 'smugglerBoat' : 'civilianBoat';
var boatGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.isSmuggler = isSmuggler;
self.speed = speed || 2;
self.active = true;
self.direction = Math.random() > 0.5 ? 1 : -1;
// Set initial position
if (self.direction > 0) {
self.x = -100;
boatGraphics.scaleX = 1;
} else {
self.x = 2048 + 100;
boatGraphics.scaleX = -1;
}
self.update = function () {
self.x += self.speed * self.direction;
// Remove if off screen on the other side
if (self.direction > 0 && self.x > 2048 + 100 || self.direction < 0 && self.x < -100) {
self.active = false;
// If it's a smuggler and it escaped, lose a point
if (self.isSmuggler && gameActive) {
score--;
if (score < 0) {
score = 0;
}
updateScore();
}
}
};
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 = 15;
self.active = true;
self.update = function () {
self.y += self.speed;
// Remove if off screen
if (self.y > 2732) {
self.active = false;
}
};
return self;
});
var Helicopter = Container.expand(function () {
var self = Container.call(this);
var helicopterBody = self.attachAsset('helicopter', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.fireRate = 30; // frames between shots
self.cooldown = 0;
self.moveLeft = function () {
self.x -= self.speed;
if (self.x < 100) {
self.x = 100;
}
};
self.moveRight = function () {
self.x += self.speed;
if (self.x > 2048 - 100) {
self.x = 2048 - 100;
}
};
self.canFire = function () {
return self.cooldown <= 0;
};
self.resetCooldown = function () {
self.cooldown = self.fireRate;
};
self.update = function () {
if (self.cooldown > 0) {
self.cooldown--;
}
// Ensure helicopter stays within screen bounds
if (self.x < 0) {
self.x = 0;
} else if (self.x > 2048) {
self.x = 2048;
}
if (self.y < 0) {
self.y = 0;
} else if (self.y > 2732) {
self.y = 2732;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0066cc
});
/****
* Game Code
****/
// Game variables
var helicopter;
var bullets = [];
var boats = [];
var score = 0;
var level = 0;
var gameActive = true;
var spawnInterval = 120; // frames between boat spawns
var spawnCounter = 0;
var difficulty = 1;
var levelThreshold = 10; // score needed to level up
var targetPressed = false;
var targetX, targetY;
// UI elements
var scoreTxt;
var levelTxt;
var instructionsTxt;
// Initialize game
function initGame() {
// Create ocean background
var ocean = LK.getAsset('ocean', {
anchorX: 0,
anchorY: 0
});
game.addChild(ocean);
// Create helicopter
helicopter = new Helicopter();
helicopter.x = 2048 / 2;
helicopter.y = 150;
game.addChild(helicopter);
// Create score text
scoreTxt = new Text2('Score: 0', {
size: 50,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
LK.gui.topRight.addChild(scoreTxt);
// Create level text
levelTxt = new Text2('Level: 1', {
size: 50,
fill: 0xFFFFFF
});
levelTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(levelTxt);
// Create instructions text
instructionsTxt = new Text2('Tap to move and shoot. Hit smuggler boats (red) and avoid civilian boats (green).', {
size: 30,
fill: 0xFFFFFF
});
instructionsTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionsTxt);
// Remove instructions after 5 seconds
LK.setTimeout(function () {
if (instructionsTxt && instructionsTxt.parent) {
instructionsTxt.parent.removeChild(instructionsTxt);
instructionsTxt = null;
}
}, 5000);
// Start background music
LK.playMusic('bgMusic', {
fade: {
start: 0,
end: 0.4,
duration: 1000
}
});
}
// Update score display
function updateScore() {
scoreTxt.setText('Score: ' + score);
// Check for level up
if (score >= level * levelThreshold) {
levelUp();
}
}
// Level up
function levelUp() {
level++;
levelTxt.setText('Level: ' + level);
// Increase difficulty
difficulty += 0.2;
spawnInterval = Math.max(30, Math.floor(120 / difficulty));
// Flash level text
LK.effects.flashObject(levelTxt, 0xffff00, 1000);
}
// Spawn a new boat
function spawnBoat() {
var isSmuggler = Math.random() < 0.4; // 40% chance for smuggler, increasing civilian boat appearance
var speed = (1 + Math.random() * 0.5) * difficulty;
var boat = new Boat(isSmuggler, speed);
// Set y position - distribute across the bottom 3/4 of the screen
boat.y = 800 + Math.random() * 1500;
boats.push(boat);
game.addChild(boat);
}
// Fire a bullet
function fireBullet() {
if (!helicopter.canFire()) {
return;
}
createBullet(helicopter.x, helicopter.y + 50);
helicopter.resetCooldown();
}
// Create a bullet at a specified position
function createBullet(x, y) {
var bullet = new Bullet();
bullet.x = x;
bullet.y = y;
bullets.push(bullet);
game.addChild(bullet);
// Play sound
LK.getSound('shoot').play();
}
// Check collisions
function checkCollisions() {
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (!bullet.active) {
continue;
}
for (var j = boats.length - 1; j >= 0; j--) {
var boat = boats[j];
if (!boat.active) {
continue;
}
if (bullet.intersects(boat)) {
// Hit a boat
bullet.active = false;
boat.active = false;
// Update score
if (boat.isSmuggler) {
// Hit smuggler - good!
score += 1;
LK.effects.flashObject(boat, 0xff0000, 500);
LK.getSound('explosion').play();
} else {
// Hit civilian - bad!
score -= 2;
if (score < 0) {
score = 0;
}
LK.effects.flashObject(boat, 0xffff00, 500);
LK.getSound('miss').play();
// Game over if score drops too low or too many civilians hit
if (score <= -5) {
gameActive = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
updateScore();
// Check for win condition
if (score >= 50) {
gameActive = false;
LK.showYouWin();
}
break;
}
}
}
}
// Clean up inactive objects
function cleanupObjects() {
// Clean up bullets
for (var i = bullets.length - 1; i >= 0; i--) {
if (!bullets[i].active) {
game.removeChild(bullets[i]);
bullets.splice(i, 1);
}
}
// Clean up boats
for (var i = boats.length - 1; i >= 0; i--) {
if (!boats[i].active) {
game.removeChild(boats[i]);
boats.splice(i, 1);
}
}
}
// Handle game touches
function handleGameTouch(x, y) {
if (!gameActive) {
return;
}
// Move helicopter directly to touch point
helicopter.x = x;
// Fire if touched below helicopter
if (y > helicopter.y) {
fireBullet();
}
}
// Handle touch pad for helicopter control
function handleTouchPad(x, y) {
if (!gameActive) {
return;
}
moveHelicopter(x, helicopter.y);
}
// Move helicopter towards a target position
function moveHelicopter(targetX, targetY) {
// Gradually move helicopter towards target position
var moveSpeed = 2; // Adjust speed for slower movement
if (helicopter.x < targetX) {
helicopter.x = Math.min(helicopter.x + moveSpeed, targetX);
} else if (helicopter.x > targetX) {
helicopter.x = Math.max(helicopter.x - moveSpeed, targetX);
}
}
// Game event handlers
game.down = function (x, y, obj) {
handleTouchPad(x, y);
targetPressed = true;
};
game.move = function (x, y, obj) {
if (targetPressed) {
handleTouchPad(x, y);
}
};
game.up = function (x, y, obj) {
targetPressed = false;
};
// Main game update
game.update = function () {
if (!gameActive) {
return;
}
// Update helicopter
helicopter.update();
// Update bullets
for (var i = 0; i < bullets.length; i++) {
bullets[i].update();
}
// Update boats
for (var i = 0; i < boats.length; i++) {
boats[i].update();
}
// Spawn boats
spawnCounter++;
if (spawnCounter >= spawnInterval) {
spawnBoat();
spawnCounter = 0;
}
// Check collisions
checkCollisions();
// Clean up inactive objects
cleanupObjects();
};
// Initialize the game
initGame(); ===================================================================
--- original.js
+++ change.js
@@ -342,12 +342,8 @@
return;
}
// Update helicopter
helicopter.update();
- // Fire if target is pressed
- if (targetPressed) {
- fireBullet();
- }
// Update bullets
for (var i = 0; i < bullets.length; i++) {
bullets[i].update();
}
horizontal top down image drugs smugler super boat. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
blue white color fishing ship. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
tiger stripe helicopter war. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
drop bom tube. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
red fire explosion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows