Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

How to pause a while loop in python

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 K1NNY   Members   

163
Like
0Likes
Like

Posted 05 October 2012 - 11:28 AM

I would like to know how to pause a while loop in python. Right now i am using :
[source lang="python"]raw_input("-->")[/source]
This method works, but this requires them to hit enter in the command prompt window that is open with the program. I was wanting them to just be able to hit enter and cycle through the loop with the game window selected. After several searches on google i came here because the only help with this issue was using the raw_input() functions.

Heres my while loop currently:
[source lang="python"]#Game loopwhile game: x = random.randint(1, 10) DISPLAY.blit(gbg, (0, 0))#the pplrty determiner if x == 1: p += 2 if x == 2: p -= 2 if x == 3: p += 3 if x == 4: p -= 3 if x == 5: p += 5 if x == 6: p -= 5 if x == 7: p += 3 if x == 8: p -= 5 if x == 9: p += 0 if x == 10: p += 0 if p >= 50 and p < 60: DISPLAY.blit(pplrty_decent, (225, 400)) elif p >= 60 and p < 85: DISPLAY.blit(pplrty_good, (255, 400)) elif p >= 85 and p < 100: DISPLAY.blit(pplrty_great, (255, 400)) elif p >= 25 and p < 50: DISPLAY.blit(pplrty_bad, (225, 400)) elif p < 25: DISPLAY.blit(pplrty_awful, (225, 400)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() raw_input('-->') pygame.display.update()[/source]

#2 markr   Members   

1692
Like
0Likes
Like

Posted 05 October 2012 - 07:57 PM

You'll need to use the pygame keyboard functions to wait for a keypress instead of using raw_input. raw_input is only for the terminal, which you may not have, or may not use, when you have a Pygame window open.

Alternatively, you can keep your game loop spinning and just not update any objects. You might want to consider writing some functions.

#3 markr   Members   

1692
Like
0Likes
Like

Posted 05 October 2012 - 07:58 PM

You'll need to use the pygame keyboard functions to wait for a keypress instead of using raw_input. raw_input is only for the terminal, which you may not have, or may not use, when you have a Pygame window open.

Alternatively, you can keep your game loop spinning and just not update any objects. You might want to consider writing some functions.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.