User prompt
make it so if the player touches the homing bullet, the player dies.
User prompt
make the homing bullet dissapear after 10 seconds
User prompt
make the homing bullet go towards the player and not stay still.
User prompt
the homing bullet should come from the enemy and the asset should rotate based on where it is heading. the homing bullet explodes and kills the player upon contact
User prompt
make it a higher chance every 3 seconds. every 3 seconds the chance of the homing bullet coming increases by 1 percent
User prompt
add a new kind of bullet with a VERY LOW CHANCE of spawning. this bullet follows the player for 10 seconds and then explodes
User prompt
fix the code. there arent any enemies on wave 1
User prompt
the first wave starts with 3 enemies
User prompt
make it a wave game. only a specific amount of enemies come each wave. when you complete a wave 2 more enemies spawn in the next.
User prompt
make everything 2x bigger
User prompt
make the explosion slowly dissapear after 2 seconds
User prompt
make it so when an enemy is killed 4 transparent orange blocks will shoot out from all sides very quickly
User prompt
make it so if the alien bullets touch the player the player will die. also reduce the firerate of the player and aliens to 1 bullet every 1 second
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var m = enemyBullets.length - 1; m >= 0; m--) {' Line Number: 106
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var m = enemyBullets.length - 1; m >= 0; m--) {' Line Number: 106
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var m = enemyBullets.length - 1; m >= 0; m--) {' Line Number: 106
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var m = enemyBullets.length - 1; m >= 0; m--) {' Line Number: 106
User prompt
make the enemies shoot bullets downwards and decrease the fire rate of the player
Initial prompt
Top down space shooter game
/**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy', 'Enemy Ship', 0.5, 0.5); self.speed = 2; self.move = function () { self.y += self.speed; }; self.isOffScreen = function () { return self.y > 2732 + self.height; }; }); // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero Ship', 0.5, 0.5); self.x = 2048 / 2; self.y = 2732 - 200; }); // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('bullet', 'Bullet', 0.5, 0.5); self.speed = -10; self.move = function () { self.y += self.speed; }; self.isOffScreen = function () { return self.y < -self.height; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize hero var hero = game.addChild(new Hero()); // Initialize enemy and bullet arrays var enemies = []; var heroBullets = []; // Game state var isGameOver = false; // Touch event handling var dragNode = null; function handleMove(obj) { var event = obj.event; var pos = event.getLocalPosition(game); if (dragNode) { dragNode.x = pos.x; dragNode.y = pos.y; } } game.on('down', function (obj) { dragNode = hero; handleMove(obj); }); game.on('move', handleMove); game.on('up', function (obj) { dragNode = null; }); // Game tick event LK.on('tick', function () { if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Move hero bullets for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].move(); if (heroBullets[i].isOffScreen()) { heroBullets[i].destroy(); heroBullets.splice(i, 1); } } // Move enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].move(); if (enemies[j].isOffScreen()) { enemies[j].destroy(); enemies.splice(j, 1); } } // Check for collisions for (var k = heroBullets.length - 1; k >= 0; k--) { for (var l = enemies.length - 1; l >= 0; l--) { if (heroBullets[k].intersects(enemies[l])) { heroBullets[k].destroy(); heroBullets.splice(k, 1); enemies[l].destroy(); enemies.splice(l, 1); break; } } } // Fire bullets if (LK.ticks % 15 == 0) { var bullet = new Bullet(); bullet.x = hero.x; bullet.y = hero.y; heroBullets.push(bullet); game.addChild(bullet); } // Spawn enemies if (LK.ticks % 120 == 0) { var enemy = new Enemy(); enemy.x = Math.random() * (2048 - enemy.width) + enemy.width / 2; enemy.y = -enemy.height; enemies.push(enemy); game.addChild(enemy); } });
/****
* Classes
****/
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('enemy', 'Enemy Ship', 0.5, 0.5);
self.speed = 2;
self.move = function () {
self.y += self.speed;
};
self.isOffScreen = function () {
return self.y > 2732 + self.height;
};
});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero Ship', 0.5, 0.5);
self.x = 2048 / 2;
self.y = 2732 - 200;
});
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('bullet', 'Bullet', 0.5, 0.5);
self.speed = -10;
self.move = function () {
self.y += self.speed;
};
self.isOffScreen = function () {
return self.y < -self.height;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize hero
var hero = game.addChild(new Hero());
// Initialize enemy and bullet arrays
var enemies = [];
var heroBullets = [];
// Game state
var isGameOver = false;
// Touch event handling
var dragNode = null;
function handleMove(obj) {
var event = obj.event;
var pos = event.getLocalPosition(game);
if (dragNode) {
dragNode.x = pos.x;
dragNode.y = pos.y;
}
}
game.on('down', function (obj) {
dragNode = hero;
handleMove(obj);
});
game.on('move', handleMove);
game.on('up', function (obj) {
dragNode = null;
});
// Game tick event
LK.on('tick', function () {
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Move hero bullets
for (var i = heroBullets.length - 1; i >= 0; i--) {
heroBullets[i].move();
if (heroBullets[i].isOffScreen()) {
heroBullets[i].destroy();
heroBullets.splice(i, 1);
}
}
// Move enemies
for (var j = enemies.length - 1; j >= 0; j--) {
enemies[j].move();
if (enemies[j].isOffScreen()) {
enemies[j].destroy();
enemies.splice(j, 1);
}
}
// Check for collisions
for (var k = heroBullets.length - 1; k >= 0; k--) {
for (var l = enemies.length - 1; l >= 0; l--) {
if (heroBullets[k].intersects(enemies[l])) {
heroBullets[k].destroy();
heroBullets.splice(k, 1);
enemies[l].destroy();
enemies.splice(l, 1);
break;
}
}
}
// Fire bullets
if (LK.ticks % 15 == 0) {
var bullet = new Bullet();
bullet.x = hero.x;
bullet.y = hero.y;
heroBullets.push(bullet);
game.addChild(bullet);
}
// Spawn enemies
if (LK.ticks % 120 == 0) {
var enemy = new Enemy();
enemy.x = Math.random() * (2048 - enemy.width) + enemy.width / 2;
enemy.y = -enemy.height;
enemies.push(enemy);
game.addChild(enemy);
}
});
Spaceship with 1 cannon facing upwards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Pixelated.
bullet launching upwards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Pixelated.
alien ship facing downwards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Pixelated.
slime ball being launched downwards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Pixelated.
giant space explosion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Pixelated.
space trap. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Pixelated.