Ending The Game

Started by Wonko The Sane, Wed 17/05/2006 23:15:21

Previous topic - Next topic

Wonko The Sane

Is there any way to end the game? Besides the player quitting i mean
...that is when I figured out that the world had gone insane, so I built an asylum for it. Poor thing, I hope it gets better.
-Wonko The Sane

Ishmael

Returning to the title menu?
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Barbarian

Do you mean making an ending sequence? You just add it in like you would the rest of your game.

But if you mean an actual command to quit out of the game and have the game close itself, you might be looking for the QuitGame command. From the AGS manual:

QuitGame
QuitGame(int ask_first)

Exits the game and returns to the operating system.
If ASK_FIRST is zero, it will exit immediately. If ASK_FIRST is not zero, it will first display a message box asking the user if they are sure they want to quit.

Example:

QuitGame(0);

will quit the game without asking the player to confirm.
Conan: "To crush your enemies, see them driven before you, and to hear the lamentation of the women!"
Mongol General: "That is good."

Blade of Rage: www.BladeOfRage.com

Ashen


Read the BFAQ
(although the code sample is out of date).

Beyond that: you're really going to have to be less vague about what you want, if you expect answers.

I know what you're thinking ... Don't think that.

Wonko The Sane

#4
Ooo! I like what Barbarian said. Thanks. To the rest who answered, nice try at answering my riddle (sorry)  ;D


Edit: Actualy it didn't work. I wanted the gme to exit to DOS/Windows. I looked it up in the manual and it said to use AbortGame("string"..." ) but that didn't work either. I have just set it up simply. I have a room where the player is non-visible and is just "THE END" I want to have the player be able to click and it will exit to windows.
...that is when I figured out that the world had gone insane, so I built an asylum for it. Poor thing, I hope it gets better.
-Wonko The Sane

Barbarian

#5
The QuitGame(0); command should work for you then.

You need to put it in a script to to make it work.

So, let's say you have the ending room where you might have your "THE END" message displayed.

From the room editor, click on the big "i" button at top.
From the choices, Right-Click on "Player enters room (after fadein)"

Then select "New Action".

Then select from the drop-down choices "Run script". Click on the "Edit Script" button.Ã,  In the script add commands such as the following example:

Code: ags
 Wait(150); QuitGame(0); 


Then from script editor choose "File" and "Exit and save changes", and that should do it.

The Wait(150); commands will wait a few moments before exiting the game, so the player has a chance to read your "THE END" message or whatever you want to put up there. Of course you can adjust the 150 number to shorter or longer as you like.Ã,  Anyways, that should work for you as you were looking for.  Except that way the game will automatically exit after the Wait command finishes.

If you want the player to "Click" to exit. Then from the room editor, make a big "Hotspot", then on the Hotspot interaction you can add the QuiteGame(0); command in a script.
Conan: "To crush your enemies, see them driven before you, and to hear the lamentation of the women!"
Mongol General: "That is good."

Blade of Rage: www.BladeOfRage.com

Wonko The Sane

That is what I have done. I have one massive hotspot. But the QuitGame(0); script does not work for some reason.
...that is when I figured out that the world had gone insane, so I built an asylum for it. Poor thing, I hope it gets better.
-Wonko The Sane

Barbarian

#7
Seems like something is being overlooked or the command is being placed in a way that it's not getting activated.Ã,  Maybe on the Hotspot, put the code on the "On any click" part (I'm going my memory here as my AGS editor is not open at the moment).

If you still can't get it to work, post up your exact code here for us to see... or if that still fails to help, perhaps you can upload a zip copy of your project and someone here can take a look at it to see what might be wrong.

Good luck.
Conan: "To crush your enemies, see them driven before you, and to hear the lamentation of the women!"
Mongol General: "That is good."

Blade of Rage: www.BladeOfRage.com

A�rendyll (formerly Yurina)

Babarians code should work, but myself... I had problems with the "On any click" part... maybe there's a bug?

This doesn't really add, but I thought it might be helpful for Wonko...

~Yurina
Yuna: Give me a Y!
Rikku: Give me an R!
Paine: Give me a break...
~Final Fantasy X-2

I've been

Ashen

Slighty off topic (or maybe not), but:
'Any click on ...' doesn't count 'Walk to' (cursor mode 0), unless you've altered settings to make it. Could this be the problem? Try setting the mode to something else in 'Player enters room (after fadein)' - and possibly disabling 'Walk to', so the player can't go back by accident.

As an alternative, you could give the room it's own on_mouse_click, e.g.:
Code: ags

//Room script

function on_mouse_click(MouseButton button) {
  QuitGame(0);
  ClaimEvent();
}


This'll make any mouse click in the room quit the game. (You could also edit the global on_mouse_click to check the room, and quit if needed.)

If nothing else works, as Barbarian said, post your code for us to take a look at.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk