User prompt
Enemy bullets should move downwards towards the player's hero plane. To correct the direction without altering the source code, the speed should be a positive value, and the `move` function should add the speed to the `y` position to move the bullet downwards.
User prompt
Enemy bullets shoot toward bottom of screee
User prompt
Reverse enemy bullet dirextion
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'self.parent.enemyBullets.push')' in this line: 'self.parent.enemyBullets.push(bullet);' Line Number: 104
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 104
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 104
User prompt
Implement suggestion above to fix enemy bullet
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 104
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 59
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 104
User prompt
Enemy bullets shoot from enemy position.
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 104
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 33
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 59
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 33
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 59
User prompt
Fix Bug: 'ReferenceError: Can't find variable: enemyBullets' in this line: 'enemyBullets.push(bullet);' Line Number: 33
User prompt
Implement suggestion above
User prompt
Spawn enemies who shoot bullets
User prompt
Create new enemy graphic
User prompt
Create code to spawn an enemy
User prompt
Reverse direction of enemies spawned
User prompt
Create new enemy class
User prompt
Spawn enemies from top of screen. Destroy when they reach the bottom off screen
User prompt
Ensure that the scrolling background is on the bottom layer and enemies and special items are visible in front of the background
var Enemy4 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy4', 'Enemy Plane 4', .5, .5); self.speed = -5; self.move = function () { self.y -= self.speed; }; self.fire = function () { var bullet = new EnemyBullet(); bullet.x = self.x; bullet.y = self.y; bullet.move = function () { bullet.y += bullet.speed; }; enemyBullets.push(bullet); self.parent.addChild(bullet); }; }); var Enemy3 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy3', 'Enemy Plane 3', .5, .5); self.speed = -4; self.move = function () { self.y -= self.speed; }; self.fire = function () { var bullet = new EnemyBullet(); bullet.x = self.x; bullet.y = self.y; bullet.move = function () { bullet.y += bullet.speed; }; enemyBullets.push(bullet); self.parent.addChild(bullet); }; }); var SpecialItem = Container.expand(function () { var self = Container.call(this); var itemGraphics = self.createAsset('specialItem', 'Special Item', .5, .5); self.speed = -2; self.move = function () { self.y += self.speed; }; }); var Enemy2 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy2', 'Enemy Plane 2', .5, .5); self.speed = -2; self.move = function () { self.y += self.speed; }; self.fire = function () { var bullet = new EnemyBullet(); bullet.x = self.x; bullet.y = self.y; bullet.move = function () { bullet.y += bullet.speed; }; enemyBullets.push(bullet); self.parent.addChild(bullet); }; }); var HealthDisplay = Container.expand(function () { var self = Container.call(this); var healthBar = self.createAsset('healthBar', 'Health Bar', 0, 1); healthBar.tint = 0xFF0000; healthBar.width = 2098; healthBar.height = 100; self.addChild(healthBar); self.updateHealth = function (health) { healthBar.width = health / 3 * 2048; }; }); var Hero = Container.expand(function () { var self = Container.call(this); self.health = 3; var heroGraphics = self.createAsset('hero', 'Hero Plane', .5, .5); self.speed = 5; self.bulletSpeed = 10; self.move = function () {}; self.fire = function () { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y; bullet.speed = self.bulletSpeed; heroBullets.push(bullet); self.parent.addChild(bullet); }; }); var Enemy1 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy1', 'Enemy Plane 1', .5, .5); self.speed = -3; self.move = function () { self.y -= self.speed; }; self.fire = function () { var bullet = new EnemyBullet(); bullet.x = self.x; bullet.y = self.y; bullet.move = function () { bullet.y += bullet.speed; }; enemyBullets.push(bullet); self.parent.addChild(bullet); }; }); var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('heroBullet', 'Hero Bullet', .5, .5); self.speed = 10; self.move = function () { self.y -= self.speed; }; }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('enemyBullet', 'Enemy Bullet', .5, .5); self.speed = -7; self.move = function () { self.y -= self.speed; }; }); var Game = Container.expand(function () { var self = Container.call(this); var bg = self.createAsset('background', 'Background Image', 0, 0); bg.width = 2048; bg.height = 2732; var bg2 = self.createAsset('background', 'Background Image', 0, 0); bg2.width = 2048; bg2.height = 2732; bg2.y = -2732; var hero = self.addChild(new Hero()); var healthDisplay = new HealthDisplay(); LK.gui.topLeft.addChild(healthDisplay); var enemies = []; var heroBullets = []; var enemyBullets = []; var specialItems = []; hero.x = 2048 / 2; hero.y = 2732 - 200; var spawnEnemy = function () { var enemyType = Math.floor(Math.random() * 3); var enemy; switch (enemyType) { case 0: enemy = new Enemy1(); break; case 1: enemy = new Enemy2(); break; case 2: enemy = new Enemy3(); break; } enemy.x = Math.random() * 2048; enemy.y = 0; enemies.push(enemy); self.addChild(enemy); }; var spawnHeroBullet = function () { var bullet = new HeroBullet(); bullet.x = hero.x; bullet.y = hero.y; bullet.move = function () { bullet.y -= bullet.speed; }; heroBullets.push(bullet); self.addChild(bullet); }; var spawnSpecialItem = function () { var item = new SpecialItem(); item.x = Math.random() * 2048; item.y = 0; specialItems.push(item); self.addChild(item); }; var spawnEnemyBullet = function (enemy) { var bullet = new EnemyBullet(); bullet.x = enemy.x; bullet.y = enemy.y; bullet.move = function () { bullet.y += bullet.speed; }; enemyBullets.push(bullet); self.addChild(bullet); }; var checkCollision = function () { specialItems.forEach(function (item, index) { if (hero.intersects(item)) { item.destroy(); specialItems.splice(index, 1); hero.bulletSpeed = 15; LK.setTimeout(function () { hero.bulletSpeed = 10; }, 4000); } }); }; var gameOver = function () {}; LK.on('tick', function () { bg.y += 2; bg2.y += 2; if (bg.y >= 2732) bg.y = -2732; if (bg2.y >= 2732) bg2.y = -2732; hero.move(); healthDisplay.updateHealth(hero.health); enemies.forEach(function (enemy, index) { enemy.move(); if (LK.ticks % 60 === 0) { enemy.fire(); spawnEnemyBullet(enemy); } if (enemy.y > 2732) { enemy.destroy(); enemies.splice(index, 1); } }); heroBullets.forEach(function (bullet, index) { bullet.move(); if (bullet.y < 0) { bullet.destroy(); heroBullets.splice(index, 1); } }); enemyBullets.forEach(function (bullet) { bullet.move(); }); specialItems.forEach(function (item, index) { item.move(); if (item.y > 2732) { item.destroy(); specialItems.splice(index, 1); } }); checkCollision(); }); LK.on('tick', function () { if (LK.ticks % 30 === 0) { spawnHeroBullet(); } if (LK.ticks % 600 === 0) { spawnSpecialItem(); } if (LK.ticks % 100 === 0) { spawnEnemy(); } }); var dragHero = null; stage.on('down', function (obj) { dragHero = hero; }); stage.on('move', function (obj) { if (dragHero) { var pos = obj.event.getLocalPosition(self); dragHero.x = pos.x; dragHero.y = pos.y; } }); stage.on('up', function (obj) { dragHero = null; }); });
===================================================================
--- original.js
+++ change.js
@@ -241,8 +241,11 @@
}
if (LK.ticks % 600 === 0) {
spawnSpecialItem();
}
+ if (LK.ticks % 100 === 0) {
+ spawnEnemy();
+ }
});
var dragHero = null;
stage.on('down', function (obj) {
dragHero = hero;
Futuristic fighter plane, chrono trigger, top down view, behind Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Special item shooting game pixel art, shiny Single Game Texture. In-Game asset. 2d. Blank background.
Top down shooter, alien space enemy craft, retro pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Bright yellow blast pixel art shooter game Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
65604d9e9017209915d71b35: Top down shooter, alien space enemy craft, retro pixel art, red flying space alien, giant eye ball Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
65604d9e9017209915d71b35: Top down shooter, alien space craft enemy craft, retro pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art bullet blue and white shining orb of energy retro Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art top down aerial view barren desert, sand dunes, retro shooter Single Game Texture. In-Game asset. 2d. Blank background. Low contrast. No shadows.
hit point heart pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art explosion, retro Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.