Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: how to pause the game...  (Read 5844 times)

0 Members and 1 Guest are viewing this topic.

renno

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 6
  • I'm a llama!
    • View Profile
how to pause the game...
« on: June 20, 2003, 10:02:43 PM »

I want this:

When i push the space bar, the game pauses. If i push the space bar again, the game quits pause mode.
Logged

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re:how to pause the game...
« Reply #1 on: June 21, 2003, 03:42:41 AM »

Take a look at the default options menu (the one that shows up when pressing ESC). The game pauses. So, how could it be done? Just make a window with an static saying PAUSE or something like that, and load it in SystemExclusive mode when the space key is pressed, and unload it when it's pressed again. Just taking a look at the options menu code and the game.script you could do it pretty easily.
Logged

Click here to sign my sig!

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:how to pause the game...
« Reply #2 on: June 21, 2003, 09:34:23 AM »

Ok... I wanted to do that for my game too anyway, so I did it earlier that I have planned... :)
Here it is:

I am assuming that you have used the wme_Demo as a reference/template for your game

find in the game.script the code
Code: [Select]
on "Keypress"
{
.......
.......
}

And put inside that code the following code:
Code: [Select]
 // on  space, pause the game
  if(Keyboard.KeyCode==VK_SPACE || Keyboard.Printable==false)
  {
    WinCaption.Visible = false;
    var WinPause = Game.LoadWindow("interface\system\pause.window");
    WinPause.Center();
    //the GoSystemExclusive pauses everything except the loaded window
    WinPause.GoSystemExclusive();
    Game.UnloadObject(WinPause);
  }

OK... now all we need is to create the pause.window and ofcourse it's script, pause.script

Go to interface/system directory and create those two files:

pause.window
Code: [Select]
WINDOW
{
  WIDTH = 100
  HEIGHT = 100
  NAME = "pause"

  SCRIPT = "interface\system\pause.script"
}

pause.script
Code: [Select]
#include "scripts\base.inc"
#include "scripts\keys.inc"

////////////////////////////////////////////////////////////////////////////////
on "Keypress"
{
  if(Keyboard.KeyCode==VK_SPACE){
    self.Close();
  }
}

That's it! :) Ofcourse you could add more things to make it better. For example you could load an image in the window that says something "game is paused, press space to return" etc

EDIT: Ofcouse what I did was the same as McCoy suggested, but I think that a "ready" code might be simplier to understand :)
« Last Edit: June 21, 2003, 09:39:53 AM by odnorf »
Logged
fl*p

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re:how to pause the game...
« Reply #3 on: June 21, 2003, 10:41:35 AM »

Oh, no problem I'm not jealous or something like that... but remember... I WAS THE FIRST WHO SUGGESTED THE WAY OF DOING IT! MUAHAHAHAH   ;). I'm just kidding. Well, it was almost 5AM and I wasn't in the mood of coding anything  :P, so thanks for doing what I must have done at it's moment   ;).
Logged

Click here to sign my sig!

Luca Candela

  • Guest
Re:how to pause the game...
« Reply #4 on: September 04, 2003, 12:02:19 PM »

For me this method don't works... when I press the space bar the first time the game freezes and the second space bar stroke don't give back the focus to the game... something is wrong with this!
Logged

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:how to pause the game...
« Reply #5 on: September 04, 2003, 12:23:54 PM »

 ??? I have done that and it works fine.  ??? It's in my project now.

I can't test it right now but the code looks ok.
Althought there is a little not-important mistake

The line
  if(Keyboard.KeyCode==VK_SPACE || Keyboard.Printable==false)
should be
  if(Keyboard.KeyCode==VK_SPACE && Keyboard.Printable==false)

Are you using the latest version (1.1 build033) of wme?

Mnemonic, can you please take a look at it. It would be funny to find that I have done a mistake after 2,5 months.  ;D
Logged
fl*p

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:how to pause the game...
« Reply #6 on: September 04, 2003, 12:34:01 PM »

I can't test it right now, but the code seems to be ok. I'll test it in the evening (CET :-)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:how to pause the game...
« Reply #7 on: September 04, 2003, 12:37:13 PM »

I just installed WME here and put the pause code into the wme_demo project and it works just fine.
Logged
fl*p
 

Page created in 0.044 seconds with 20 queries.