User prompt
The scoring system: each missile shot down equals 50 points. Each Alien shot down, equals 150 points. Can you display the score at the top left.
User prompt
if the heromissile collides then it should also explode
User prompt
And if the jet fighter's missile hits an alien or an alien missile, then that alien or its missile should explode and disappear from the screen
User prompt
if the jet fight hits an alien or a missile from an alien, then there should be a crash and the game is over.
Code edit (1 edits merged)
Please save this source code
Initial prompt
Attack on Earth
===================================================================
--- original.js
+++ change.js
@@ -90,8 +90,18 @@
/****
* Game Code
****/
+// Initialize score
+var score = 0;
+// Initialize score text
+var scoreTxt = new Text2(score.toString(), {
+ size: 50,
+ fill: "#ffffff"
+});
+scoreTxt.x = 20;
+scoreTxt.y = 20;
+LK.gui.top.addChild(scoreTxt);
var fighterJet = game.addChild(new FighterJet());
fighterJet.x = 2048 / 2;
fighterJet.y = 2732 - 200;
var heroMissiles = [];
@@ -144,8 +154,11 @@
// Add explosion effect for heroMissile
LK.effects.flashObject(heroMissile, 0xff0000, 1000);
heroMissile.destroy();
heroMissiles.splice(heroMissiles.indexOf(heroMissile), 1);
+ // Update score
+ score += 150;
+ scoreTxt.setText(score.toString());
}
});
enemyMissiles.forEach(function (enemyMissile) {
if (heroMissile.intersects(enemyMissile)) {
@@ -155,8 +168,11 @@
// Add explosion effect for heroMissile
LK.effects.flashObject(heroMissile, 0xff0000, 1000);
heroMissile.destroy();
heroMissiles.splice(heroMissiles.indexOf(heroMissile), 1);
+ // Update score
+ score += 50;
+ scoreTxt.setText(score.toString());
}
});
});
// Spawn new aliens
It looks like a bright green space invader. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a While missile, with a red top that is pointing downwards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An f18 but vertical with the cockpit facing up. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.