How to program a game to crash on command.

I want a bad ending where if the player deliberately continues to disobey a character, the game would just close and destroy all scores and progress. How can I achieve this?


Erasing the player's progress in the game isn't too hard. You could do something like:

        if (squiffy.ui.settings.persist && window.localStorage) {
            var keys = Object.keys(localStorage);
            jQuery.each(keys, function (idx, key) {
                if (startsWith(key, squiffy.story.id)) {
                    localStorage.removeItem(key);
                }
            });
        }
        else {
            squiffy.storageFallback = {};
        }

If you want to close the game, you could add one (or both) of:

  • squiffy.ui.output.empty(); - clears the output so far from the screen
  • window.close(); - close the tab - although this may not always work depending on the player's settings

Thanks. Just because I'm a novice programmer, where would I put this? I'm still working on the online version but plan to download all of the html and javascript stuff once I'm done. Can I put this in a [[section]]: ? Or is it something I put into the html or javascript?


Yeah, put it in a [[section]]:

Cool idea, broadwaydude.

Thanks, mrangel.


Then again... Do you just mean you want "Game Over" if you make repeated wrong choices?

[[Dilemma]]:

"Obey me!" says the character.

*   [Yes]
*   [No]

[No]:
@inc no
"I saaaiiid, 'Obey me!'" repeats the character{if no>1: yet again}.

*   [Yes]
*   {if no>1: [[No]](Game Over) } {else:[No]}

[Yes]:
Good!

[[Game Over]]:
@clear
<center><big><big>Game Over

@clear with no links means the player cannot possibly make progress. They have no choice but to restart.


Thanks, IFForClassroom for clearing up. I was also intending the first idea you had. If you'd like to take a look at the game that it's for, I'll post the link right here! It would be an honor for you to playtest it, given that you've been answering a lot of forum posts lately that have been helping me bunches.

http://textadventures.co.uk/games/view/pnmno4m7guu6zyjropbleg/the-world-ends-today-i-think


Noticed that you gave it a play. Thanks for checking it out!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums