User prompt
reduce lag
User prompt
sceen bug agian need fixedblack c
User prompt
bullet speed caps at 120 kills
User prompt
you stop gaining extra bullets at 120 kills and zombines stop speeding up at 120 kills and bullets have no cap in the number
User prompt
max bulets can be fires at 120 kills and that is also max zombites spawn that kill too
User prompt
fix bugs teh scenn is black
User prompt
addd lag reducing
User prompt
bullets desapwn when they go out of teh sceen
User prompt
every 10 kills you gain 1 etraa bullet per fire
User prompt
and when you right click you can have it so your gun spins and itgoes back your next righ tlcik
User prompt
and after 20 kills your bullets have auto aim going to the closest zomibe to you
User prompt
add an upgrate to your gun every 5 kills
User prompt
player should be in teh middle
User prompt
add a online score borad
Code edit (1 edits merged)
Please save this source code
User prompt
Zombie Aim: Shooter Survival
Initial prompt
a shooter game wher you aim a gun at zombines and kill them you aim with your mouse and fires by clicking and it shows where the bullet will go
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Aiming line class var AimLine = Container.expand(function () { var self = Container.call(this); // Attach aim line asset, anchor at left (0,0.5) var lineGfx = self.attachAsset('aimLine', { anchorX: 0, anchorY: 0.5 }); // Set default scale lineGfx.scaleY = 0.2; // Thin line // Set color, etc. if needed return self; }); // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); // Attach bullet asset, center anchor var bulletGfx = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); // Direction vector (set on spawn) self.dx = 0; self.dy = 0; self.speed = 40; // px per frame self.update = function () { self.x += self.dx * self.speed; self.y += self.dy * self.speed; }; return self; }); // Gun/player class var Gun = Container.expand(function () { var self = Container.call(this); // Attach gun asset, center anchor var gunGfx = self.attachAsset('gun', { anchorX: 0.5, anchorY: 0.5 }); // For possible future use: gunGfx return self; }); // Zombie class var Zombie = Container.expand(function () { var self = Container.call(this); // Attach zombie asset, center anchor var zombieGfx = self.attachAsset('zombie', { anchorX: 0.5, anchorY: 0.5 }); // Target position (player center) self.targetX = 0; self.targetY = 0; self.speed = 4 + Math.random() * 2; // Slight speed variation self.update = function () { // Move toward target var dx = self.targetX - self.x; var dy = self.targetY - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 0) { self.x += dx / dist * self.speed; self.y += dy / dist * self.speed; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181818 }); /**** * Game Code ****/ // Aiming line: thin yellow box (will be scaled) // Zombie asset: greenish box // Bullet asset: small ellipse // Gun (player) asset: a box, centered // Game constants var GAME_W = 2048; var GAME_H = 2732; var PLAYER_X = GAME_W / 2; var PLAYER_Y = GAME_H - 350; // Near bottom, but not at edge // Game state var bullets = []; var zombies = []; var score = 0; var isGameOver = false; // Create gun/player var gun = new Gun(); gun.x = PLAYER_X; gun.y = PLAYER_Y; game.addChild(gun); // Create aiming line var aimLine = new AimLine(); aimLine.x = gun.x; aimLine.y = gun.y; game.addChild(aimLine); // Score text var scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Helper: clamp function clamp(val, min, max) { return Math.max(min, Math.min(max, val)); } // Helper: spawn zombie at random edge, aiming at player function spawnZombie() { var z = new Zombie(); // Pick random edge: 0=top, 1=bottom, 2=left, 3=right var edge = Math.floor(Math.random() * 4); var x, y; if (edge === 0) { // top x = 200 + Math.random() * (GAME_W - 400); y = -80; } else if (edge === 1) { // bottom x = 200 + Math.random() * (GAME_W - 400); y = GAME_H + 80; } else if (edge === 2) { // left x = -80; y = 300 + Math.random() * (GAME_H - 600); } else { // right x = GAME_W + 80; y = 300 + Math.random() * (GAME_H - 600); } z.x = x; z.y = y; z.targetX = gun.x; z.targetY = gun.y; zombies.push(z); game.addChild(z); } // Helper: fire bullet toward (tx,ty) function fireBullet(tx, ty) { // Direction vector from gun to (tx,ty) var dx = tx - gun.x; var dy = ty - gun.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 10) return; // Don't fire if too close dx /= dist; dy /= dist; var b = new Bullet(); b.x = gun.x + dx * 80; // Start a bit ahead of gun b.y = gun.y + dy * 80; b.dx = dx; b.dy = dy; bullets.push(b); game.addChild(b); } // Update aiming line to point from gun to (aimX, aimY) function updateAimLine(aimX, aimY) { var dx = aimX - gun.x; var dy = aimY - gun.y; var dist = Math.sqrt(dx * dx + dy * dy); // Clamp min/max length var minLen = 120, maxLen = 700; var len = clamp(dist, minLen, maxLen); // Set scaleX of line aimLine.scale.x = len / 20; // asset width is 20 // Set rotation aimLine.rotation = Math.atan2(dy, dx); } // Initial aim position: straight up var aimX = gun.x; var aimY = gun.y - 400; updateAimLine(aimX, aimY); // Touch/mouse move: update aim game.move = function (x, y, obj) { // Clamp aim point to inside game area aimX = clamp(x, 100, GAME_W - 100); aimY = clamp(y, 100, GAME_H - 100); updateAimLine(aimX, aimY); }; // Touch/mouse down: fire bullet game.down = function (x, y, obj) { if (isGameOver) return; fireBullet(x, y); }; // No drag, so up is not needed // Game update loop game.update = function () { if (isGameOver) return; // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { var b = bullets[i]; b.update(); // Remove if out of bounds if (b.x < -100 || b.x > GAME_W + 100 || b.y < -100 || b.y > GAME_H + 100) { b.destroy(); bullets.splice(i, 1); continue; } // Check collision with zombies for (var j = zombies.length - 1; j >= 0; j--) { var z = zombies[j]; if (b.intersects(z)) { // Hit! z.destroy(); zombies.splice(j, 1); b.destroy(); bullets.splice(i, 1); // Score up score += 1; scoreTxt.setText(score); // Flash zombie green LK.effects.flashObject(gun, 0x00ff00, 200); break; } } } // Update zombies for (var k = zombies.length - 1; k >= 0; k--) { var z = zombies[k]; z.update(); // Check if zombie reached player (gun) if (z.intersects(gun)) { // Game over isGameOver = true; LK.effects.flashScreen(0xff0000, 1000); // Show game over and then leaderboard LK.showGameOver(function () { LK.showLeaderboard({ score: score }); }); return; } } // Spawn zombies at intervals if (LK.ticks % 60 === 0) { // Every 1s // Increase spawn rate as score increases var toSpawn = 1 + Math.floor(score / 10); for (var s = 0; s < toSpawn; s++) { spawnZombie(); } } }; // Reset state on game restart game.on('reset', function () { // Remove all bullets/zombies for (var i = 0; i < bullets.length; i++) bullets[i].destroy(); for (var j = 0; j < zombies.length; j++) zombies[j].destroy(); bullets = []; zombies = []; score = 0; isGameOver = false; scoreTxt.setText(score); // Reset aim aimX = gun.x; aimY = gun.y - 400; updateAimLine(aimX, aimY); // Add leaderboard button to GUI (top right) if (!game.leaderboardBtn) { var leaderboardBtn = new Text2("🏆", { size: 100, fill: 0xFFE066 }); leaderboardBtn.anchor.set(1, 0); leaderboardBtn.interactive = true; leaderboardBtn.buttonMode = true; leaderboardBtn.x = -40; leaderboardBtn.y = 20; leaderboardBtn.down = function () { LK.showLeaderboard({ score: score }); }; LK.gui.topRight.addChild(leaderboardBtn); game.leaderboardBtn = leaderboardBtn; } });
===================================================================
--- original.js
+++ change.js
@@ -235,9 +235,14 @@
if (z.intersects(gun)) {
// Game over
isGameOver = true;
LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
+ // Show game over and then leaderboard
+ LK.showGameOver(function () {
+ LK.showLeaderboard({
+ score: score
+ });
+ });
return;
}
}
// Spawn zombies at intervals
@@ -263,5 +268,24 @@
// Reset aim
aimX = gun.x;
aimY = gun.y - 400;
updateAimLine(aimX, aimY);
+ // Add leaderboard button to GUI (top right)
+ if (!game.leaderboardBtn) {
+ var leaderboardBtn = new Text2("🏆", {
+ size: 100,
+ fill: 0xFFE066
+ });
+ leaderboardBtn.anchor.set(1, 0);
+ leaderboardBtn.interactive = true;
+ leaderboardBtn.buttonMode = true;
+ leaderboardBtn.x = -40;
+ leaderboardBtn.y = 20;
+ leaderboardBtn.down = function () {
+ LK.showLeaderboard({
+ score: score
+ });
+ };
+ LK.gui.topRight.addChild(leaderboardBtn);
+ game.leaderboardBtn = leaderboardBtn;
+ }
});
\ No newline at end of file