Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 pausing the game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Insectoid




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: 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
Insectoid




PostPosted: 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.
Saad




PostPosted: 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
Insectoid




PostPosted: 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')
[Gandalf]




PostPosted: 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
HeavenAgain




PostPosted: 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
Insectoid




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Aziz




PostPosted: 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'.
Insectoid




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: