Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

While Loop problem

Question posted by: PythonNotSoGuru (Newbie) on July 2nd, 2008 04:44 PM
Hi everyone. I am using a while loop in a game and during the game loop i want the user to be able to give input without the program stopping at a certain point and asking for the input. In other words i want the user to be able to input something at any time that will then be used in the program. I am using Python 2.5, English, Im on Windows XP Service Pack 2.
Thanks for any help you could give.
dshimer's Avatar
dshimer
Expert
132 Posts
July 8th, 2008
11:37 AM
#2

Re: While Loop problem
I'm not 100% sure I follow, but it sounds like you are looking for something similar to a C getch().
Check this out and see if there is anything useful.
http://aspn.activestate.com/ASPN/Co...n/Recipe/134892

Reply
jlm699's Avatar
jlm699
Needs Regular Fix
313 Posts
July 8th, 2008
12:26 PM
#3

Re: While Loop problem
I think what he's asking is that he wants his program to simply run constantly. If a user were to press a key he wants it to act like an interrupt so that processing can switch to handle this new event before continuing with what it was doing before.

I would be interested to see if Python can do something like this myself. As far as that link that was provided it is basically like asking for a raw_input in the sense that it waits for the user to enter something before continuing with the next line of code.

Reply
kudos's Avatar
kudos
Expert
76 Posts
July 19th, 2008
10:33 PM
#4

Re: While Loop problem
What kind of gui toolkit/lib do you use for your game? I did write a breakout game that uses Tkinter (that comes with python) ages ago and you can see how its done there:

http://bytes.com/forum/thread625365-kudos.html

-kudos

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,847 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Python Forum Contributors