Do something vaguely interesting when the game ends
This commit is contained in:
parent
e64a553365
commit
bfacde7525
23
js/main.js
23
js/main.js
@ -484,10 +484,16 @@ class Player extends PrimaryView {
|
|||||||
}
|
}
|
||||||
else if (this.state === 'stopped') {
|
else if (this.state === 'stopped') {
|
||||||
if (this.level.state === 'success') {
|
if (this.level.state === 'success') {
|
||||||
// Advance to the next level
|
// Advance to the next level, if any
|
||||||
// TODO game ending?
|
if (this.conductor.level_index < this.conductor.stored_game.level_metadata.length - 1) {
|
||||||
this.conductor.change_level(this.conductor.level_index + 1);
|
this.conductor.change_level(this.conductor.level_index + 1);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// TODO for CCLs, by default, this is also at level 144
|
||||||
|
this.set_state('ended');
|
||||||
|
this.update_ui();
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Restart
|
// Restart
|
||||||
if (!this.current_keys.has(ev.key)) {
|
if (!this.current_keys.has(ev.key)) {
|
||||||
@ -1473,6 +1479,7 @@ class Player extends PrimaryView {
|
|||||||
// paused: um, paused
|
// paused: um, paused
|
||||||
// rewinding: playing backwards
|
// rewinding: playing backwards
|
||||||
// stopped: level has ended one way or another
|
// stopped: level has ended one way or another
|
||||||
|
// ended: final level has been completed
|
||||||
set_state(new_state) {
|
set_state(new_state) {
|
||||||
// Keep going even if we're doing waiting -> waiting, because the overlay contains the level
|
// Keep going even if we're doing waiting -> waiting, because the overlay contains the level
|
||||||
// name and author which may have changed
|
// name and author which may have changed
|
||||||
@ -1653,6 +1660,18 @@ class Player extends PrimaryView {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (this.state === 'ended') {
|
||||||
|
// TODO spruce this up considerably! animate? what's in the background? this text is
|
||||||
|
// long and clunky? final score is not interesting. could show other stats, total
|
||||||
|
// time, say something if you skipped levels...
|
||||||
|
// TODO disable most of the ui here? probably??
|
||||||
|
overlay_reason = 'ended';
|
||||||
|
overlay_top = "The End";
|
||||||
|
overlay_middle = "You did it! You completed a full set of funny little escape rooms. Nothing to do now but bask in glory... then either try to improve your score, or try out a new pack!";
|
||||||
|
let savefile = this.conductor.current_pack_savefile;
|
||||||
|
overlay_bottom = `FINAL SCORE: ${savefile.total_score.toLocaleString()}`;
|
||||||
|
// TODO press spacebar to... restart from level 1?? or what
|
||||||
|
}
|
||||||
this.overlay_message_el.setAttribute('data-reason', overlay_reason);
|
this.overlay_message_el.setAttribute('data-reason', overlay_reason);
|
||||||
this.overlay_message_el.querySelector('.-top').textContent = overlay_top;
|
this.overlay_message_el.querySelector('.-top').textContent = overlay_top;
|
||||||
this.overlay_message_el.querySelector('.-bottom').textContent = overlay_bottom;
|
this.overlay_message_el.querySelector('.-bottom').textContent = overlay_bottom;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user