User prompt
fix error score make upadate score
User prompt
make score display
User prompt
Please fix the bug: 'TypeError: storage.set is not a function' in or related to this line: 'storage.set('score', score);' Line Number: 223 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var score = storage.get('score') || 0;' Line Number: 149 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
fix error score
User prompt
make notif amazing when shoot ten enemy
User prompt
delete score indicator
User prompt
Please fix the bug: 'TypeError: storage.set is not a function' in or related to this line: 'storage.set('score', 0);' Line Number: 323 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var score = storage.get('score') || 0;' Line Number: 149 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
accumulate scores
User prompt
get score after shoot enemy by 1 point
User prompt
The higher the level, the more civilians there are and they move slowly, while the smugler boat moves faster.
User prompt
get score after succes attack enemy
User prompt
make more boats
User prompt
make normal speed at helicopter
User prompt
helicopter automaticly moving to left and right
User prompt
add background
User prompt
make variable speed of npc
User prompt
changed explosive when smugler boat was hit by gunfire
User prompt
add score bottom right of the screen
User prompt
make logic if helicopter shoot civilian boat game is over
User prompt
bring helicopter capable to attack
User prompt
manualy shoot
User prompt
make taping for helicopter shoot
User prompt
make button for helicopte shoot
/****
* 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 = 5;
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--;
}
// Automatic left and right movement
if (self.direction === undefined) {
self.direction = 1; // Start moving right
}
self.x += self.speed * self.direction;
// Change direction at screen edges
if (self.x <= 100) {
self.direction = 1; // Move right
} else if (self.x >= 2048 - 100) {
self.direction = -1; // Move left
}
// 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 = storage.get('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 shoot button
var shootButton = LK.getAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
shootButton.x = 2048 / 2;
shootButton.y = 2732 - 150;
game.addChild(shootButton);
// Add event listener for shoot button
shootButton.down = function () {
if (gameActive) {
fireBullet();
}
};
// Create ocean background
var ocean = LK.getAsset('ocean', {
anchorX: 0,
anchorY: 0
});
ocean.width = 2048; // Set width to match game width
ocean.height = 2732; // Set height to match game height
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.topLeft.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() {
storage.set('score', score);
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 boatCount = Math.floor(1 + Math.random() * (difficulty + level)); // Increase number of boats based on difficulty and level
for (var i = 0; i < boatCount; i++) {
var isSmuggler = Math.random() < 0.4; // 40% chance for smuggler, increasing civilian boat appearance
var speed = isSmuggler ? (1 + Math.random() * 0.5 + difficulty * 0.2) * (difficulty + level * 0.5) : (1 + Math.random() * 0.5) * (1 + level * 0.1);
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) {
score += 1; // Increase score for hitting a smuggler
updateScore(); // Update score display
// Check if score is a multiple of 10
if (score % 10 === 0) {
// Display an amazing notification
var amazingTxt = new Text2('Amazing!', {
size: 100,
fill: 0xFFD700 // Gold color
});
amazingTxt.anchor.set(0.5, 0.5);
amazingTxt.x = 2048 / 2;
amazingTxt.y = 2732 / 2;
LK.gui.center.addChild(amazingTxt);
// Remove the notification after 2 seconds
LK.setTimeout(function () {
LK.gui.center.removeChild(amazingTxt);
}, 2000);
}
// Create explosion effect
var explosion = LK.getAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5
});
explosion.x = boat.x;
explosion.y = boat.y;
game.addChild(explosion);
// Remove explosion after a short duration
LK.setTimeout(function () {
game.removeChild(explosion);
}, 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 helicopter shoots a civilian boat
gameActive = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
storage.set('score', 0);
}
updateScore();
// Check for win condition
if (score >= 50) {
gameActive = false;
LK.showYouWin();
storage.set('score', 0);
}
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;
}
// 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);
fireBullet();
targetPressed = true;
};
game.move = function (x, y, obj) {
if (targetPressed) {
handleTouchPad(x, y);
fireBullet();
}
};
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
@@ -130,9 +130,9 @@
// Game variables
var helicopter;
var bullets = [];
var boats = [];
-var score = storage.score || 0;
+var score = storage.get('score') || 0;
var level = 0;
var gameActive = true;
var spawnInterval = 120; // frames between boat spawns
var spawnCounter = 0;
@@ -211,9 +211,9 @@
});
}
// Update score display
function updateScore() {
- storage.score = score;
+ storage.set('score', score);
scoreTxt.setText('Score: ' + score);
// Check for level up
if (score >= level * levelThreshold) {
levelUp();
@@ -320,16 +320,16 @@
// Game over if helicopter shoots a civilian boat
gameActive = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
- storage.score = 0;
+ storage.set('score', 0);
}
updateScore();
// Check for win condition
if (score >= 50) {
gameActive = false;
LK.showYouWin();
- storage.score = 0;
+ storage.set('score', 0);
}
break;
}
}
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