User prompt
If lander intersects platform and speed y is bigger than 1 then its game over
User prompt
If lander interscets with platfor and y speed is more than one then show crash asset and game over after 1 second
User prompt
Reduce fuel and y speed font size in half
User prompt
Move y speed text 50 pixels below fuel
User prompt
Below fuel show the y speed of the lander
User prompt
Show fuel quantity in the top right corner
User prompt
On click, lander will burst its thruster reduce its descensce speed
Initial prompt
Lander 1990
===================================================================
--- original.js
+++ change.js
@@ -36,9 +36,16 @@
var Platform = Container.expand(function () {
var self = Container.call(this);
var platformGraphics = self.createAsset('platform', 'Landing Platform', 0.5, 0.5);
self.checkLanding = function (lander) {
- return lander.intersects(self) && lander.speedY < 1;
+ if (lander.intersects(self)) {
+ if (lander.speedY < 1) {
+ return 'success';
+ } else {
+ return 'crash';
+ }
+ }
+ return 'none';
};
});
/****
@@ -100,10 +107,11 @@
LK.on('tick', function () {
if (!isGameOver) {
lander.update();
- // Check for landing
- if (platform.checkLanding(lander)) {
+ // Check for landing or crash
+ var landingStatus = platform.checkLanding(lander);
+ if (landingStatus === 'success') {
lander.land();
score += 1;
scoreTxt.setText(score.toString());
lander.refuel();
@@ -111,8 +119,18 @@
lander.x = 1024;
lander.y = 100;
lander.speedY = 0;
lander.isLanding = false;
+ } else if (landingStatus === 'crash') {
+ // Show crash asset
+ var crashAsset = game.addChild(LK.getAsset('crash', 'Crash Asset', 0.5, 0.5));
+ crashAsset.x = lander.x;
+ crashAsset.y = lander.y;
+ // Trigger game over after 1 second
+ LK.setTimeout(function () {
+ isGameOver = true;
+ LK.showGameOver();
+ }, 1000);
}
// Check for game over conditions
if (lander.y > 2732 || lander.fuel <= 0) {