User prompt
Make the minions as a asset
User prompt
Give the hero two minions that help him but ai has to do double damage that hero does to kill
User prompt
Allow boss to shoot
User prompt
Boss counts as two kills
User prompt
Make a bar that shows amount of kills you did
User prompt
Enemy boss can only go left and right
User prompt
Add health bar to boss
User prompt
Let boss shoot
User prompt
Spawn boss at start of game
User prompt
Fix Bug: 'ReferenceError: Can't find variable: EnemyBoss' in or related to this line: 'var enemyBoss = new EnemyBoss();' Line Number: 312
User prompt
Make a new enemy class that doesn’t shoot
User prompt
Fix Bug: 'ReferenceError: Can't find variable: Enemy' in or related to this line: 'var enemy = new Enemy();' Line Number: 267
User prompt
Add two more enemy classes
User prompt
Check for collisions between hero bullets and enemy bullets, and make them not explode if they intersect.
User prompt
Do not explode or make bullets disapear
User prompt
Explosion should disappear after half a second
User prompt
Make explosions 3times bigger
User prompt
Make explosions 2times bigger
User prompt
Explosion disappear after two seconds
User prompt
If explosion happens it has to disappear in 2seconds als show explosion when enemy and hero bullets interact
User prompt
Add a exploding animation when hero bullet and enemies
User prompt
If hero bullet hits enemy bullet enemy bullet and hero bullet will explode
User prompt
Boss shoots two bullets at a time
User prompt
Add health bar to boss
User prompt
Introduce a enemy boss class that spawns every six minutes, and only dies if shot four times
/**** * Classes ****/ var Minion = Container.expand(function () { var self = Container.call(this); var minionGraphics = self.attachAsset('minion', { anchorX: 0.5, anchorY: 0.5 }); self.shoot = function () { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y - self.height / 2; game.addChild(bullet); heroBullets.push(bullet); }; }); var EnemyBoss = Container.expand(function () { var self = Container.call(this); var enemyBossGraphics = self.attachAsset('Enemyboss', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.health = 10; self.shootTick = 120; // Set shootTick for boss to shoot every 2 seconds // Create a health bar self.healthBar = LK.getAsset('healthBar', { width: self.width, height: 10, anchorX: 0.5, anchorY: 0 }); self.addChild(self.healthBar); self.healthBar.y = -self.height / 2; self.move = function () { self.x += Math.cos(LK.ticks / 60) * 5; if (self.x < 0) { self.x = 0; } if (self.x > 2048 - self.width) { self.x = 2048 - self.width; } }; self.shoot = function () { var bullet = new EnemyBullet(); bullet.x = self.x; bullet.y = self.y + self.height / 2; game.addChild(bullet); enemyBullets.push(bullet); }; }); var EnemyType3 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.health = 2; // Create a health bar self.healthBar = LK.getAsset('healthBar', { width: self.width, height: 10, anchorX: 0.5, anchorY: 0 }); self.addChild(self.healthBar); self.healthBar.y = -self.height / 2; self.move = function () { self.y += Math.sin(LK.ticks / 60) * 5; self.x += Math.cos(LK.ticks / 60) * 5; if (self.y > 2732 - self.height) { self.y = 2732 - self.height; } if (self.y < 0) { self.y = 0; } if (self.x < 0) { self.x = 0; } if (self.x > 2048 - self.width) { self.x = 2048 - self.width; } }; }); var Explosion = Container.expand(function () { var self = Container.call(this); self.frames = 30; // 0.5 seconds at 60FPS self.update = function () { if (self.frames > 0) { self.alpha = self.frames / 120; self.scaleX += 0.6; self.scaleY += 0.6; self.frames--; } else { self.destroy(); } }; // After 2 seconds, destroy the explosion LK.setTimeout(function () { self.destroy(); }, 500); self.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); }); var GoldenBadge = Container.expand(function () { var self = Container.call(this); self.on('down', function (obj) { self.destroy(); LK.resumeGame(); }); self.attachAsset('goldenBadge', { anchorX: 0.5, anchorY: 0.5 }); }); // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.minions = [new Minion(), new Minion()]; self.minions[0].x = self.x - 100; self.minions[0].y = self.y; self.minions[1].x = self.x + 100; self.minions[1].y = self.y; game.addChild(self.minions[0]); game.addChild(self.minions[1]); self.shoot = function () { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y - self.height / 2; game.addChild(bullet); heroBullets.push(bullet); self.minions.forEach(function (minion) { minion.shoot(); }); }; }); // EnemyType1 class var EnemyType1 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.health = 2; // Create a health bar self.healthBar = LK.getAsset('healthBar', { width: self.width, height: 10, anchorX: 0.5, anchorY: 0 }); self.addChild(self.healthBar); self.healthBar.y = -self.height / 2; self.move = function () { self.y += Math.sin(LK.ticks / 60) * 5; self.x += Math.cos(LK.ticks / 60) * 5; if (self.y > 2732 - self.height) { self.y = 2732 - self.height; } if (self.y < 0) { self.y = 0; } if (self.x < 0) { self.x = 0; } if (self.x > 2048 - self.width) { self.x = 2048 - self.width; } }; self.shoot = function () { var bullet = new EnemyBullet(); bullet.x = self.x; bullet.y = self.y + self.height / 2; game.addChild(bullet); enemyBullets.push(bullet); }; }); // EnemyType2 class var EnemyType2 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5, scaleX: 4, scaleY: 4 }); self.health = 4; // Create a health bar self.healthBar = LK.getAsset('healthBar', { width: self.width, height: 10, anchorX: 0.5, anchorY: 0 }); self.addChild(self.healthBar); self.healthBar.y = -self.height / 2; // Create a health bar self.healthBar = LK.getAsset('healthBar', { width: self.width, height: 10, anchorX: 0.5, anchorY: 0 }); self.addChild(self.healthBar); self.healthBar.y = -self.height / 2; self.move = function () { self.y += Math.sin(LK.ticks / 60) * 5; self.x += Math.cos(LK.ticks / 60) * 5; if (self.y > 2732 - self.height) { self.y = 2732 - self.height; } if (self.y < 0) { self.y = 0; } if (self.x < 0) { self.x = 0; } if (self.x > 2048 - self.width) { self.x = 2048 - self.width; } }; self.shoot = function () { var bullet1 = new EnemyBullet(); bullet1.x = self.x - self.width / 4; bullet1.y = self.y + self.height / 2; game.addChild(bullet1); enemyBullets.push(bullet1); var bullet2 = new EnemyBullet(); bullet2.x = self.x + self.width / 4; bullet2.y = self.y + self.height / 2; game.addChild(bullet2); enemyBullets.push(bullet2); }; }); // HeroBullet class var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('heroBullet', { anchorX: 0.5, anchorY: 0.5 }); self.move = function () { self.y -= 10; if (self.y < -self.height) { self.destroy(); heroBullets.splice(heroBullets.indexOf(self), 1); } }; }); // EnemyBullet class var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5 }); self.move = function () { self.y += 5; if (self.y > 2732 + self.height) { self.destroy(); enemyBullets.splice(enemyBullets.indexOf(self), 1); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundImage: 'space' // Init game with space background }); /**** * Game Code ****/ // Define the assets for the hero, enemy robots, and bullets // Initialize hero var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 100; // Initialize enemy and bullet arrays var enemies = []; var heroBullets = []; var enemyBullets = []; // Spawn boss at start of game var enemyBoss = new EnemyBoss(); enemyBoss.x = 2048 / 2; enemyBoss.y = 2732 / 2; game.addChild(enemyBoss); enemies.push(enemyBoss); // Handle shooting and moving the hero game.on('down', function (obj) { hero.shoot(); }); // Handle swipe game.on('move', function (obj) { var event = obj.event; var pos = event.getLocalPosition(game); hero.x = pos.x; hero.y = pos.y; }); // Initialize 20 minutes timer and kill count var timer = 20 * 60; var killCount = 0; // Create a timer text object var timerTxt = new Text2('20:00', { size: 100, fill: '#ffffff' }); // Attach the timer text object to the top right corner of the screen LK.gui.topRight.addChild(timerTxt); // Create a kill count text object var killCountTxt = new Text2('Kills: 0', { size: 100, fill: '#ffffff' }); // Attach the kill count text object to the top left corner of the screen LK.gui.topLeft.addChild(killCountTxt); // Game tick event LK.on('tick', function () { // Update timer every second if (LK.ticks % 60 == 0) { timer--; // Update timer text var minutes = Math.floor(timer / 60); var seconds = timer % 60; timerTxt.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); } // Move hero bullets for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].move(); } // Move enemy bullets for (var j = enemyBullets.length - 1; j >= 0; j--) { enemyBullets[j].move(); } // Move enemies and randomly shoot for (var k = enemies.length - 1; k >= 0; k--) { enemies[k].move(); // Update the health bar if (enemies[k] && enemies[k].healthBar) { enemies[k].healthBar.width = enemies[k].health / 2 * enemies[k].width; } // Enemies shoot based on their unique shootTick value if (enemies[k].shootTick && LK.ticks % enemies[k].shootTick == 0) { enemies[k].shoot(); } } // Spawn enemies if (LK.ticks % 120 == 0) { var enemy = new EnemyType1(); enemy.x = Math.random() * (2048 - enemy.width) + enemy.width / 2; enemy.y = -enemy.height; // Assign a unique shootTick value to each enemy enemy.shootTick = 120 + Math.floor(Math.random() * 60); game.addChild(enemy); enemies.push(enemy); } // Spawn enemy boss every six minutes if (LK.ticks % (60 * 60 * 6) == 0) { var enemyBoss = new EnemyBoss(); enemyBoss.x = Math.random() * (2048 - enemyBoss.width) + enemyBoss.width / 2; enemyBoss.y = -enemyBoss.height; // Assign a unique shootTick value to each enemy boss enemyBoss.shootTick = 120 + Math.floor(Math.random() * 60); game.addChild(enemyBoss); enemies.push(enemyBoss); } if (LK.ticks % 72000 == 0 && enemies.length == 0) { var goldenBadge = new GoldenBadge(); goldenBadge.x = 2048 / 2; goldenBadge.y = 2732 / 2; game.addChild(goldenBadge); LK.pauseGame(); } // Check for collisions between hero bullets and enemies for (var h = heroBullets.length - 1; h >= 0; h--) { for (var e = enemies.length - 1; e >= 0; e--) { if (heroBullets[h].intersects(enemies[e])) { var explosion = new Explosion(); explosion.x = enemies[e].x; explosion.y = enemies[e].y; game.addChild(explosion); heroBullets[h].destroy(); heroBullets.splice(h, 1); enemies[e].health -= 2; if (enemies[e].health <= 0) { enemies[e].destroy(); enemies.splice(e, 1); // Increment kill count by 2 if enemy is EnemyBoss, otherwise by 1 var killIncrement = enemies[e] instanceof EnemyBoss ? 2 : 1; killCount += killIncrement; killCountTxt.setText('Kills: ' + killCount); } break; } } } // Check for collisions between enemy bullets and hero for (var eb = enemyBullets.length - 1; eb >= 0; eb--) { if (enemyBullets[eb].intersects(hero)) { // Flash screen red for 1 second (1000ms) to show damage taken LK.effects.flashScreen(0xff0000, 1000); // Show game over LK.showGameOver(); break; } } });
===================================================================
--- original.js
+++ change.js
@@ -2,9 +2,9 @@
* Classes
****/
var Minion = Container.expand(function () {
var self = Container.call(this);
- var minionGraphics = self.attachAsset('hero', {
+ var minionGraphics = self.attachAsset('minion', {
anchorX: 0.5,
anchorY: 0.5
});
self.shoot = function () {
Blue,laser like. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Golden badge shaped. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Red ufo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Big version of enemy and only dies after shot four times rest of features are from original enemies. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Red bullet facing towards the bottom of the game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Like a big animated explosion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Looks exactly like a realistic rocket. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Imagined cosmic planet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A golden glowing ball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.