').text('.').addClass('star').css({
top: top,
left: left
}).appendTo(el);
$('
').text('.').addClass('star').css({
top: top,
left: left
}).appendTo(el2);
if(num < Space.NUM_STARS) {
Engine.setTimeout(function() { Space.drawStarAsync(el, el2, num + 1); }, 100);
}
},
crash: function() {
if(Space.done) return;
Engine.keyLock = true;
Space.done = true;
clearInterval(Space._timer);
clearInterval(Space._shipTimer);
clearInterval(Space._volumeTimer);
clearTimeout(Space._panelTimeout);
var body_color;
if (Engine.isLightsOff())
body_color = '#272823';
else
body_color = '#FFFFFF';
// Craaaaash!
$('body').removeClass('noMask').stop().animate({
backgroundColor: body_color
}, {
duration: 300,
progress: function() {
var cur = $('body').css('background-color');
var s = 'linear-gradient(rgba' + cur.substring(3, cur.length - 1) + ', 0) 0%, rgba' +
cur.substring(3, cur.length - 1) + ', 1) 100%)';
$('#notifyGradient').attr('style', 'background-color:'+cur+';background:-webkit-' + s + ';background:' + s);
},
complete: function() {
Space.stars.remove();
Space.starsBack.remove();
Space.stars = Space.starsBack = null;
$('#starsContainer').remove();
$('body').attr('style', '');
$('#notifyGradient').attr('style', '');
$('#spacePanel').attr('style', '');
}
});
$('.menu, select.menuBtn').animate({color: '#666'}, 300, 'linear');
$('#outerSlider').animate({top: '0px'}, 300, 'linear');
Engine.activeModule = Ship;
Ship.onArrival();
Button.cooldown($('#liftoffButton'));
Engine.event('progress', 'crash');
AudioEngine.playSound(AudioLibrary.CRASH);
},
endGame: function() {
if(Space.done) return;
Engine.event('progress', 'win');
Space.done = true;
clearInterval(Space._timer);
clearInterval(Space._shipTimer);
clearInterval(Space._volumeTimer);
clearTimeout(Engine._saveTimer);
clearTimeout(Outside._popTimeout);
clearTimeout(Engine._incomeTimeout);
clearTimeout(Events._eventTimeout);
clearTimeout(Room._fireTimer);
clearTimeout(Room._tempTimer);
for(var j in Room.Craftables) {
Room.Craftables[j].button = null;
}
for(var k in Room.TradeGoods) {
Room.TradeGoods[k].button = null;
}
delete Outside._popTimeout;
AudioEngine.playBackgroundMusic(AudioLibrary.MUSIC_ENDING);
$('#hullRemaining', Space.panel).animate({opacity: 0}, 500, 'linear');
Space.ship.animate({
top: '350px',
left: '240px'
}, 3000, 'linear', function() {
Engine.setTimeout(function() {
Space.ship.animate({
top: '-100px'
}, 200, 'linear', function() {
// Restart everything! Play FOREVER!
$('#outerSlider').css({'left': '0px', 'top': '0px'});
$('#locationSlider, #worldPanel, #spacePanel, #notifications').remove();
$('#header').empty();
Engine.setTimeout(function() {
$('body').stop();
var container_color;
if (Engine.isLightsOff())
container_color = '#EEE';
else
container_color = '#000';
$('#starsContainer').animate({
opacity: 0,
'background-color': container_color
}, {
duration: 2000,
progress: function() {
var cur = $('body').css('background-color');
var s = 'linear-gradient(rgba' + cur.substring(3, cur.length - 1) + ', 0) 0%, rgba' +
cur.substring(3, cur.length - 1) + ', 1) 100%)';
$('#notifyGradient').attr('style', 'background-color:'+cur+';background:-webkit-' + s + ';background:' + s);
},
complete: function() {
Engine.GAME_OVER = true;
Score.save();
Prestige.save();
$('#starsContainer').remove();
$('#content, #notifications').remove();
Space.showExpansionEnding().then(() => {
Space.showEndingOptions();
Engine.options = {};
Engine.deleteSave(true);
});
}
});
}, 2000);
});
}, 2000);
});
},
showExpansionEnding: () => {
return new Promise((resolve) => {
if (!$SM.get('stores["fleet beacon"]')) {
resolve();
return;
}
const c = $('
')
.addClass('outroContainer')
.appendTo('body');
setTimeout(() => {
$('
')
.addClass('outro')
.html('the beacon pulses gently as the ship glides through space.
coordinates are locked. nothing to do but wait.')
.appendTo(c)
.animate({ opacity: 1}, 500);
}, 2000);
setTimeout(() => {
$('
')
.addClass('outro')
.html('the beacon glows a solid blue, and then goes dim. the ship slows.
gradually, the vast wanderer homefleet comes into view.
massive worldships drift unnaturally through clouds of debris, scarred and dead.')
.appendTo(c)
.animate({ opacity: 1}, 500);
}, 7000);
setTimeout(() => {
$('
')
.addClass('outro')
.text('the air is running out.')
.appendTo(c)
.animate({ opacity: 1}, 500);
}, 14000);
setTimeout(() => {
$('
')
.addClass('outro')
.text('the capsule is cold.')
.appendTo(c)
.animate({ opacity: 1}, 500);
}, 17000);
setTimeout(() => {
Button.Button({
id: 'wait-btn',
text: _('wait'),
click: (btn) => {
btn.addClass('disabled');
c.animate({ opacity: 0 }, 5000, 'linear', () => {
c.remove();
setTimeout(resolve, 3000);
})
}
}).animate({ opacity: 1 }, 500).appendTo(c);
}, 19500)
});
},
showEndingOptions: () => {
$('
')
.addClass('centerCont')
.appendTo('body');
$('')
.addClass('endGame')
.text(_('score for this game: {0}', Score.calculateScore()))
.appendTo('.centerCont')
.animate({opacity:1},1500);
$('
')
.appendTo('.centerCont');
$('')
.addClass('endGame')
.text(_('total score: {0}', Prestige.get().score))
.appendTo('.centerCont')
.animate({opacity:1},1500);
$('
')
.appendTo('.centerCont');
$('
')
.appendTo('.centerCont');
$('')
.addClass('endGame endGameOption')
.text(_('restart.'))
.click(Engine.confirmDelete)
.appendTo('.centerCont')
.animate({opacity:1},1500);
$('
')
.appendTo('.centerCont');
$('
')
.appendTo('.centerCont');
$('')
.addClass('endGame')
.text(_('expanded story. alternate ending. behind the scenes commentary. get the app.'))
.appendTo('.centerCont')
.animate({opacity:1}, 1500);
$('
')
.appendTo('.centerCont');
$('
')
.appendTo('.centerCont');
$('')
.addClass('endGame endGameOption')
.text(_('iOS.'))
.click(function() { window.open('https://itunes.apple.com/app/apple-store/id736683061?pt=2073437&ct=gameover&mt=8'); })
.appendTo('.centerCont')
.animate({opacity:1},1500);
$('
')
.appendTo('.centerCont');
$('')
.addClass('endGame endGameOption')
.text(_('android.'))
.click(function() { window.open('https://play.google.com/store/apps/details?id=com.yourcompany.adarkroom'); })
.appendTo('.centerCont')
.animate({opacity:1},1500);
},
keyDown: function(event) {
switch(event.which) {
case 38: // Up
case 87:
Space.up = true;
Engine.log('up on');
break;
case 40: // Down
case 83:
Space.down = true;
Engine.log('down on');
break;
case 37: // Left
case 65:
Space.left = true;
Engine.log('left on');
break;
case 39: // Right
case 68:
Space.right = true;
Engine.log('right on');
break;
}
},
keyUp: function(event) {
switch(event.which) {
case 38: // Up
case 87:
Space.up = false;
Engine.log('up off');
break;
case 40: // Down
case 83:
Space.down = false;
Engine.log('down off');
break;
case 37: // Left
case 65:
Space.left = false;
Engine.log('left off');
break;
case 39: // Right
case 68:
Space.right = false;
Engine.log('right off');
break;
}
},
handleStateUpdates: function(e){
},
lowerVolume: function () {
if (Space.done) return;
// lower audio as ship gets further into space
var progress = Space.altitude / 60;
var newVolume = 1.0 - progress;
AudioEngine.setBackgroundMusicVolume(newVolume, 0.3);
}
};