Graphics, Characters, Text & Rooms: Difference between revisions

Line 91: Line 91:


==How to end your game (win/lose/die) or kill off your character==
==How to end your game (win/lose/die) or kill off your character==
''How can I kill off my character, or end the game? Can't have a game without dying and an ending, you know...''
Indeed. These are very easy. While there isn't a built-in function to die or endgame (and how could there be? people want to do it different ways), you could ''easily'' do this yourself.
For a death scene, simply create a new room and go there every time the player does something to kill him/herself off, and do whatever you want there. For example, have three hotspots with "Restore/Restart/Quit" on it, and put the code inside accordingly (see the manual for these). Of course, don't forget to add a '''SetRestartPoint()''' at the exact place where you want the player to restart from. For example, if you want your player to restart at Room #3, then in that room's "'''Player enters screen (after/before fade-in)'''" interaction, create a script and enter '''SetRestartPoint()'''. This will mark that section of the script as the exact place that the game will start from when the player restarts the game.
For a proper ending, you might want to have an ending cutscene, some credits, and a "Restore/Restart/Quit" option at the end as well. It is best to switch to a new room and make sure there is no way to return to any other room in the game by accident...unless you want to, of course.
And if you don't know how to quit the game, you can either choose the "'''Quit game'''" interaction command, or use the '''QuitGame()''' scripting command. Look up the '''QuitGame()''' command in the manual, however, because you can make your game prompt the user, or you could have it quit immediately if making your own Quit GUI.
Finally, if you want the game to end once a certan amount of points were obtained (altough it doesn't make any sense to do it that way), you could place the following anywhere in your global script, provided it is outside all other functions:
  function on_event (int event, int data) {
    if (event == GOT_SCORE) { // Called whenever score changes
      if (game.score >= game.total_score ) { // fairly self-explainatory
        Display ("Congratulations, you've won.");
        QuitGame(0);
        // Or whatever you want to happen here
      }
    }
  }
If you already have code in your '''on-event''' function (if it exists yet), then adjust the code to add it in. Thanks go to Ashen for the above code.
Above I mentioned that it doesn't make any sense to end a game once a certain score had been obtained. This is because a game usually ends when a certain point in the story has been reached -- usually the ending. Then, the score is displayed and the player is usually told how many points he missed, or if he got all the scores. I suppose this would work for non-adventure games or some unorthodox types of adventure games. But hey, it's your game; do whatever you want! ;)
==Standard sizes for your main character sprites==
==Standard sizes for your main character sprites==
==Character pops up in weird place or not on walkable area from room to room==
==Character pops up in weird place or not on walkable area from room to room==