User prompt
LK.showGameOver(); add this to to enemies length please
User prompt
remove the custom game over screen and keep the other one
User prompt
is there a way to make the gameover screen look better
User prompt
var Explosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.createAsset('explosion', 'Explosion', .5, .5); self.isActive = false; self.start = function () { self.isActive = true; LK.setTimeout(function () { self.isActive = false; self.destroy(); }, 1000); }; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero spaceship', .5, .5); self.move = function (x) { self.x = x; }; self.shoot = function () { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y; LK.setTimeout(function () { bullet.destroy(); }, 3000); return bullet; }; }); var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('heroBullet', 'Hero bullet', .5, .5); self.isActive = true; self.move = function () { self.y -= 15; }; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy', 'Enemy spaceship', .5, .5); self.move = function () { self.y += 2; self.x += Math.sin(self.y / 50) * 5; }; self.shoot = function () {}; }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('enemyBullet', 'Enemy bullet', .5, .5); self.move = function () {}; }); var Asteroid = Container.expand(function () { var self = Container.call(this); var asteroidGraphics = self.createAsset('asteroid', 'Asteroid', .5, .5); self.direction = Math.random() * 2 - 1; self.move = function () { self.y += 5; self.x += self.direction; }; }); replace above var game with this please
User prompt
var Explosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.createAsset('explosion', 'Explosion', .5, .5); self.isActive = false; self.start = function () { self.isActive = true; LK.setTimeout(function () { self.isActive = false; self.destroy(); }, 1000); }; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero spaceship', .5, .5); self.move = function (x) { self.x = x; }; self.shoot = function () { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y; LK.setTimeout(function () { bullet.destroy(); }, 3000); return bullet; }; }); var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('heroBullet', 'Hero bullet', .5, .5); self.isActive = true; self.move = function () { self.y -= 15; }; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy', 'Enemy spaceship', .5, .5); self.move = function () { self.y += 2; self.x += Math.sin(self.y / 50) * 5; }; self.shoot = function () {}; }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('enemyBullet', 'Enemy bullet', .5, .5); self.move = function () {}; }); var Asteroid = Container.expand(function () { var self = Container.call(this); var asteroidGraphics = self.createAsset('asteroid', 'Asteroid', .5, .5); self.direction = Math.random() * 2 - 1; self.move = function () { self.y += 5; self.x += self.direction; }; }); var Game = Container.expand(function () { var self = Container.call(this); var fpsCounter = new Text2('FPS: 0', { size: 50, fill: '#ffffff', font: 'Arial Bold' }); LK.gui.topLeft.addChild(fpsCounter); var frameCount = 0; var lastTime = Date.now(); LK.on('tick', function () { frameCount++; var currentTime = Date.now(); var deltaTime = currentTime - lastTime; if (deltaTime >= 1000) { var fps = Math.round(frameCount / deltaTime * 1000); fpsCounter.setText('FPS: ' + fps); frameCount = 0; lastTime = currentTime; } }); var heroes = []; var heroBullets = []; var enemies = []; var enemyBullets = []; var asteroids = []; var hero = self.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 200; heroes.push(hero); var dragNode = null; stage.on('down', function (obj) { dragNode = hero; var bullet = hero.shoot(); self.addChild(bullet); heroBullets.push(bullet); }); stage.on('move', function (obj) { if (dragNode) { var event = obj.event; var pos = event.getLocalPosition(self); dragNode.move(pos.x); } }); stage.on('up', function (obj) { dragNode = null; }); var enemySpawnTimer = 0; var asteroidSpawnTimer = 0; LK.on('tick', function () { if (enemySpawnTimer++ % 100 == 0) { for (var i = 0; i < 10; i++) { var enemy = self.addChild(new Enemy()); enemy.x = i * 180 + 150; enemy.y = 0; enemies.push(enemy); } } if (asteroidSpawnTimer++ % 50 == 0) { var asteroid = self.addChild(new Asteroid()); asteroid.x = Math.random() * 2048; asteroid.y = 0; asteroids.push(asteroid); } for (var i = 0; i < enemies.length; i++) { enemies[i].move(); if (enemies[i].y >= hero.y) { LK.showGameOver(); } } for (var i = asteroids.length - 1; i >= 0; i--) { asteroids[i].move(); if (asteroids[i].y > 2732) { asteroids[i].destroy(); asteroids.splice(i, 1); } else if (hero.intersects(asteroids[i])) { LK.showGameOver(); } } for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].move(); if (heroBullets[i].y < 0) { heroBullets[i].destroy(); heroBullets.splice(i, 1); } else { for (var n = 0; n < enemies.length; n++) { if (enemies[n].length > 0 && heroBullets[i].intersects(enemies[n][0])) { for (var j = 0; j < enemies[n].length; j++) { if (heroBullets[i].intersects(enemies[n][j])) { var explosion = new Explosion(); explosion.x = enemies[n][j].x; explosion.y = enemies[n][j].y; self.addChild(explosion); explosion.start(); enemies[n][j].destroy(); enemies[n].splice(j, 1); heroBullets[i].destroy(); heroBullets.splice(i, 1); break; } } } } } } for (var i = 0; i < enemyBullets.length; i++) { enemyBullets[i].move(); } }); }); please revert to this change but just replace from var game down below keep above that the same
User prompt
Fix Bug: 'Cannot read properties of undefined (reading 'getBullet')' in this line: 'var bullet = bulletPool.getBullet();' Line Number: 6
User prompt
Fix Bug: 'Uncaught TypeError: HeroBullet is not a constructor' in this line: 'var bullet = new HeroBullet();' Line Number: 6
User prompt
Fix Bug: 'Uncaught TypeError: HeroBullet is not a constructor' in this line: 'var bullet = new HeroBullet();' Line Number: 6
User prompt
Fix Bug: 'Uncaught TypeError: HeroBullet is not a constructor' in this line: 'var bullet = new HeroBullet();' Line Number: 6
User prompt
could you make an asset for explosion and link it to the enemy so it triggers an explosion when they are collided with
User prompt
set it back to 50 size please
User prompt
can you make the text on the fps counter look more high quality
User prompt
can you add a more accurate method of counting frames per second
User prompt
it shows infinity on the counter please make it show actual frames per second
User prompt
i need a frames per second counter please make it better
User prompt
can you move the fps counter to the left a bit more i can't see it
User prompt
remove enemy height and width from console log, add an fps counter at the top right in game that shows realtime fps
User prompt
can you remove logging of enemy height and tell me the default height and width of the enemy or at least the property it has inside in console logs
User prompt
how can i see the height of the enemy in some way
User prompt
for (var n = 0; n < enemies.length; n++) { if(enemies[n].length > 0 && heroBullets[i].intersects(enemies[n][0])) { for (var j = 0; j < enemies[n].length; j++) { if (heroBullets[i].intersects(enemies[n][j])) { enemies[n][j].destroy(); enemies[n].splice(j, 1); heroBullets[i].destroy(); heroBullets.splice(i, 1); break; } } } } replace it with this for var bulletrow section
User prompt
add checking collision between bullets and enemies by height with each row and if it meets the collision then check the collision by x with each enemy in this row
User prompt
make the asteroid choose a direction when they spawn and slowly constantly move towards that direction while they are falling
User prompt
add collision with asteroids for the player if it collides with the player make it game over
User prompt
make the bullets disappear after colliding with an enemy
User prompt
nvm now the bullets can't reach enemies and it is much laggier
===================================================================
--- original.js
+++ change.js
@@ -122,9 +122,11 @@
asteroids.push(asteroid);
}
for (var i = 0; i < enemies.length; i++) {
enemies[i].move();
- if (enemies[i].y >= hero.y) {}
+ if (enemies[i].y >= hero.y) {
+ LK.showGameOver();
+ }
}
for (var i = asteroids.length - 1; i >= 0; i--) {
asteroids[i].move();
if (asteroids[i].y > 2732) {
enemy space ship Single Game Texture. In-Game asset. 2d. Transparent background. High contrast. No shadows.
asteroid Single Game Texture. In-Game asset. 2d. Transparent background. High contrast. No shadows.
plasma ball Single Game Texture. In-Game asset. 2d. Transparent background. High contrast. No shadows.
explosion particle Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
space ship facing upwards Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.