Pausing the game

Started by Ginny, Sun 10/08/2003 00:20:40

Previous topic - Next topic

Ginny

I have a problem pausing the game using the space bar.
In the on_key_press function I put this:

if ((keycode==32) && (IsGamePaused==0)) {
PauseGame;
}
else if ((keycode==32) && (IsGamePaused==1)) {
UnPauseGame;
}

But when I save the game an error message appears saying:
Error(line 40): expected '('

Line 40 is the line the code I just wrote here starts on, but I've looked through it and there doesn't seem to be a '(' missing.

Before this I also tried putting this code in repetedly_execute, only I used IsKeyPressed(32)==1 instead of keycode==32.
The same error occured.

What am I doing wrong?

(OT: Do you think the Spacebar is a good choice for a pause key? I noticed it's used sometimes in AGS games.)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

scotch

#1
The missing () are where you put IsGamePaused instead of IsGamePaused() I think.


if ((keycode==32) && (IsGamePaused()==0)) {
PauseGame();
}
else if ((keycode==32) && (IsGamePaused()==1)) {
UnPauseGame();
}

when using functions to get values you still need to put the () in even if there are no values to pass.

edit: And yes I think spacebar is a good pause key.

Ginny

#2
Thanks! I had a feeling it was something simple like this.
Once again, thanks, works like a charm. :)

When I tried it at first it wouldn't unpause, but I found the problem quickly, the funtion was not responding to keypresses when paused.

edit: To make it clearer to the player that the game is paused, I was thinking of tinting the screen in a pale gree-blue colour. However, since tinting slows the game down, this might be a bad idea. Of course, I'm still just experimenting on a test game, but I think it would be a better idea to display the word Paused onscreen. Do I need to import a sprite to do this? I.e. a sprite of the word paused in a certain color, and then use it in a GUI?
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

TerranRich

Either a sprite of the word "Paused", or just the text in an imported font on a GUI. Either way, use a GUI for the best effect and easiest manipulation. :)
Status: Trying to come up with some ideas...

Ginny

Thanks :)
I think I'll use a sprite because it allows me to use any font without importing it to AGS. I still need to work on fonts, hehe. I plan on creating my own font in SCI, but not just yet.
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

SMF spam blocked by CleanTalk