User prompt
add enemyDestroyed asset when enemy gets hit by player's bullet
User prompt
change the score text as Germs
User prompt
add sound when enemy gets collide by bullets
User prompt
add sound when enemy gets destroyed
User prompt
add sound effect when enemy gets destroyed
User prompt
when score reached value 50 create a new separate level
User prompt
remove make the score card dynamic and lively
User prompt
merge the game scoreboard with scoreCard asset and place it on top of the screen
User prompt
Please fix the bug: 'ReferenceError: scoreText is not defined' in or related to this line: 'scoreText.setText('Germs Quarantined: ' + LK.getScore());' Line Number: 149
User prompt
add these score card into an asset
User prompt
add sound when bullet is fired
User prompt
change the Germs Quarantined color to green
User prompt
make the score card dynamic and lively
User prompt
change the score text as Germs Quarantined
Code edit (2 edits merged)
Please save this source code
User prompt
create a scoreboard for the game
User prompt
create a scoreboard for the game and can be customized anytime
Code edit (4 edits merged)
Please save this source code
User prompt
fix the game performance
Code edit (1 edits merged)
Please save this source code
User prompt
increase the enemy spawn on the game
User prompt
increase the enemy spawn on the game
Code edit (2 edits merged)
Please save this source code
User prompt
add default left movement to enemy in game
User prompt
add default left movement to enemy in game
/**** * Classes ****/ var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0, anchorY: 0.6, scaleX: 4, scaleY: 4 }); self.speed = 10; self.update = function () { self.x += self.speed; if (self.x < 0) { self.destroy(); } }; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.speed = -15; self.update = function () { self.x += self.speed; if (self.x < 0) { self.destroy(); } }; }); var Ground = Container.expand(function () { var self = Container.call(this); var groundGraphics = self.attachAsset('ground', { anchorX: 0.5, anchorY: 0.5, scaleX: 3, // Scale horizontally by 1.2 scaleY: 3 // Scale vertically by 1.2 }); self.update = function () { // Ground moves from right to left self.x -= 5; if (self.x + self.width < 0) { self.x = 2048; } }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5, scaleX: 3, // Scale horizontally by 1.2 scaleY: 3 // Scale vertically by 1.2 }); self.speed = 5; self.update = function () { if (self.x < 0) { self.x = 0; } if (self.x > 300) { self.x = 300; } // Player only moves horizontally }; }); /**** * Initialize Game ****/ var game = new LK.Game(); /**** * Game Code ****/ var background1 = game.addChild(LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, width: 2048, height: 2732 })); var background2 = game.addChild(LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 3072, y: 1366, width: 2048, height: 2732 })); var ground = game.addChild(new Ground()); ground.x = 1024; ground.y = 2732 - 200; // Move the ground asset a little bit up from the bottom of the screen var player = game.addChild(new Player()); player.x = 1024; player.y = ground.y - player.height; var enemies = []; var bullets = []; var score = 0; var scoreText = new Text2(score.toString(), { size: 100, fill: 0xFFFFFF, x: 50, y: 50 }); game.addChild(scoreText); game.update = function () { background1.x -= 5; background2.x -= 5; if (background1.x <= -1024) { background1.x = background2.x + 2048; } if (background2.x <= -1024) { background2.x = background1.x + 2048; } if (LK.ticks % 25 == 0) { var enemy = game.addChild(new Enemy()); enemy.x = 2048; enemy.y = Math.random() * 2732; enemies.push(enemy); } for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; if (bullet.x > 2048) { bullet.destroy(); bullets.splice(i, 1); continue; } for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (bullet.intersects(enemy)) { bullet.destroy(); bullets.splice(i, 1); enemy.destroy(); enemies.splice(j, 1); score++; scoreText.setText(score.toString()); break; } } if (bullets.length < 1 || enemies.length < 1) { break; } } // Check if enemy goes past the player for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; if (enemy.x < player.x) { enemy.destroy(); enemies.splice(i, 1); // End the game if an enemy passes the player LK.showGameOver(); } } }; game.down = function (x, y, obj) { if (bullets.length < 10) { var bullet = game.addChild(new Bullet()); bullet.x = player.x; bullet.y = player.y; bullets.push(bullet); } }; game.move = function (x, y, obj) { player.y = y; };
===================================================================
--- original.js
+++ change.js
@@ -102,8 +102,16 @@
player.x = 1024;
player.y = ground.y - player.height;
var enemies = [];
var bullets = [];
+var score = 0;
+var scoreText = new Text2(score.toString(), {
+ size: 100,
+ fill: 0xFFFFFF,
+ x: 50,
+ y: 50
+});
+game.addChild(scoreText);
game.update = function () {
background1.x -= 5;
background2.x -= 5;
if (background1.x <= -1024) {
@@ -111,9 +119,9 @@
}
if (background2.x <= -1024) {
background2.x = background1.x + 2048;
}
- if (LK.ticks % 20 == 0) {
+ if (LK.ticks % 25 == 0) {
var enemy = game.addChild(new Enemy());
enemy.x = 2048;
enemy.y = Math.random() * 2732;
enemies.push(enemy);
@@ -131,8 +139,10 @@
bullet.destroy();
bullets.splice(i, 1);
enemy.destroy();
enemies.splice(j, 1);
+ score++;
+ scoreText.setText(score.toString());
break;
}
}
if (bullets.length < 1 || enemies.length < 1) {
sci fi bike with person riding facing right side Single Game Texture. In-Game asset. High contrast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
sci fi bike with person riding facing right side Single Game Texture. In-Game asset. High contrast.
asteroid falling diffrent colors Single Game Texture. In-Game asset. High contrast. No Background