User prompt
make the enemy hide in a place around a home make sure we spawn in the living room make it have a limit of bullets and reload it if the gun is out of ammo and when the enemy finds you it will chase you only i can shoot if i hold left click
User prompt
can you make the cubes realistic people and make me move left right up and down
User prompt
can you not make a square and can you swap the cubes with people and make the person killing the enemys have a gun
User prompt
can u make a point count at the top right right corner at can you make it more realistic
Code edit (1 edits merged)
Please save this source code
User prompt
Enemy Shooter
Initial prompt
hello may create a shooter game but every time you destroy a enemy you get points
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
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.update = function () {
self.y -= self.speed;
};
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;
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2400;
var bullets = [];
var enemies = [];
var gameActive = true;
var spawnRate = 60;
var difficultyMultiplier = 1;
var scoreTxt = new Text2('0', {
size: 80,
fill: '#ffffff'
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
var difficultyTxt = new Text2('Wave: 1', {
size: 80,
fill: '#ffffff'
});
difficultyTxt.anchor.set(0, 0);
LK.gui.bottom.addChild(difficultyTxt);
function spawnEnemy() {
var enemy = game.addChild(new Enemy());
enemy.x = Math.random() * 1800 + 100;
enemy.y = -60;
enemy.speed = 2 + difficultyMultiplier * 0.5;
enemy.lastY = enemy.y;
enemies.push(enemy);
}
function updateScore() {
scoreTxt.setText('Score: ' + LK.getScore());
var wave = Math.floor(LK.getScore() / 10) + 1;
difficultyTxt.setText('Wave: ' + wave);
difficultyMultiplier = 1 + (wave - 1) * 0.3;
spawnRate = Math.max(20, 60 - (wave - 1) * 3);
}
var dragNode = null;
function handleMove(x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
if (dragNode.x < 40) dragNode.x = 40;
if (dragNode.x > 2048 - 40) dragNode.x = 2048 - 40;
if (dragNode.y < 2400) dragNode.y = 2400;
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
dragNode = player;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
game.update = function () {
if (!gameActive) return;
// Spawn enemies
if (LK.ticks % spawnRate === 0) {
spawnEnemy();
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.lastY === undefined) {
bullet.lastY = bullet.y;
}
// Check if bullet is off-screen
if (bullet.lastY >= -20 && bullet.y < -20) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check bullet-enemy collisions
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
LK.getSound('hit').play();
LK.setScore(LK.getScore() + 1);
updateScore();
bullet.destroy();
bullets.splice(i, 1);
enemy.destroy();
enemies.splice(j, 1);
break;
}
}
bullet.lastY = bullet.y;
}
// Update enemies
for (var k = enemies.length - 1; k >= 0; k--) {
var enemy = enemies[k];
if (enemy.lastY === undefined) {
enemy.lastY = enemy.y;
enemy.lastIntersecting = false;
}
// Check if enemy is off-screen (bottom)
if (enemy.lastY <= 2732 + 60 && enemy.y > 2732 + 60) {
enemy.destroy();
enemies.splice(k, 1);
continue;
}
// Check player-enemy collision
var currentIntersecting = enemy.intersects(player);
if (!enemy.lastIntersecting && currentIntersecting) {
gameActive = false;
LK.effects.flashScreen(0xff0000, 500);
LK.showGameOver();
return;
}
enemy.lastY = enemy.y;
enemy.lastIntersecting = currentIntersecting;
}
// Fire bullets
if (LK.ticks % 15 === 0) {
var newBullet = game.addChild(new Bullet());
newBullet.x = player.x;
newBullet.y = player.y - 40;
newBullet.lastY = newBullet.y;
bullets.push(newBullet);
LK.getSound('shoot').play();
}
};
LK.playMusic('bgmusic', {
loop: true
}); ===================================================================
--- original.js
+++ change.js
@@ -57,13 +57,13 @@
var enemies = [];
var gameActive = true;
var spawnRate = 60;
var difficultyMultiplier = 1;
-var scoreTxt = new Text2('Score: 0', {
- size: 120,
+var scoreTxt = new Text2('0', {
+ size: 80,
fill: '#ffffff'
});
-scoreTxt.anchor.set(0, 0);
+scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
var difficultyTxt = new Text2('Wave: 1', {
size: 80,
fill: '#ffffff'
can you make it a real life bullet. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
can you make the enemy a real life human. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
make it a real life gun. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
make him a guard covering his body to only see his eyes. In-Game asset. 2d. High contrast. No shadows