Computer Science Canada

pausing the game

Author:  Insectoid [ Mon May 19, 2008 7:32 pm ]
Post subject:  pausing the game

Now this is proably vary simple, but I cannot get my game to pause when I want it to (if I want to go get a cookie or something...). I have made it work with Input.Pause, but I don't really like that. Right now, what I'm using is a loop. The program enters a loop when you hit the 'p' key and exits when you hit it again. Unfortunately, this doesn't work. Here is my current code for it:



Turing:

        if chars ('p') then
            delay (100) %so it doesn't unpause before you can take your finger off the button
            loop
                exit when chars ('p')
            end loop

Author:  Saad [ Mon May 19, 2008 7:41 pm ]
Post subject:  Re: pausing the game

insectoid wrote:

Now this is proably vary simple, but I cannot get my game to pause when I want it to (if I want to go get a cookie or something...). I have made it work with Input.Pause, but I don't really like that. Right now, what I'm using is a loop. The program enters a loop when you hit the 'p' key and exits when you hit it again. Unfortunately, this doesn't work. Here is my current code for it:



Turing:

        if chars ('p') then
            delay (100) %so it doesn't unpause before you can take your finger off the button
            loop
                exit when chars ('p')
            end loop



Look at
Turing:
exit when chars ('p')  %% Which chars is this refering to?. It hasn't been updated

Author:  Insectoid [ Mon May 19, 2008 8:23 pm ]
Post subject:  RE:pausing the game

What, so I have to ask for a new input?
put 'Input.KeyDown' in the loop? I have not had formal teaching in this area so do not know entirely how it works.

I tried putting Input.KeyDown in the loop. Now it pauses, but doesn't unpause.

Author:  Saad [ Mon May 19, 2008 8:27 pm ]
Post subject:  Re: RE:pausing the game

insectoid @ Mon May 19, 2008 8:23 pm wrote:
What, so I have to ask for a new input?
put 'Input.KeyDown' in the loop? I have not had formal teaching in this area so do not know entirely how it works.

I tried putting Input.KeyDown in the loop. Now it pauses, but doesn't unpause.


You want to add Input.KeyDown (chars) in the loop so that it updates the current keys pressed each time in the loop

Author:  Insectoid [ Mon May 19, 2008 8:35 pm ]
Post subject:  RE:pausing the game

I did that. It works if I make it exit when chars (KEY_ENTER) but not with ('p')

Author:  [Gandalf] [ Mon May 19, 2008 8:42 pm ]
Post subject:  RE:pausing the game

Try exit when chars(ord('p')), though it's been so long so I'm hardly sure that'll help. Smile

Author:  HeavenAgain [ Mon May 19, 2008 8:58 pm ]
Post subject:  Re: RE:pausing the game

insectoid @ Mon May 19, 2008 9:35 pm wrote:
I did that. It works if I make it exit when chars (KEY_ENTER) but not with ('p')
because your char array at index 'p' is true already from the first time pressing, so you better reset it back to false before entering that loop

Author:  Insectoid [ Tue May 20, 2008 7:45 am ]
Post subject:  RE:pausing the game

How would I do that? Once again, I am far from an expert on this. And what does ord do?

Author:  Aziz [ Tue May 20, 2008 7:52 am ]
Post subject:  RE:pausing the game

Type in ord and press F10 (or F9?). Or google it. It's the same in all languages.












Or I'll just spoil it. ord() takes a character as an argument and returns the ASCII (IIRC) code for it. For example, ord('a') returns 65. There's another function, chr() that takes an integer and returns it's ASCII code character. chr(65) returns 'a'.

Author:  Insectoid [ Tue May 20, 2008 4:46 pm ]
Post subject:  RE:pausing the game

right, how would that help me?

I noticed while screwing around with my program though that it will unpause if you prees 'p' and an arrow key at the same time.


: