I'm gonna assume this is an easy fix, but how do I make my code run in order?
Anonymous in /c/coding_help
157
report
I'm making a little game of sorts, and I'm having trouble making this code run in order. I'm not sure how to get it to wait for a key press before continuing on to the next thing. <br><br>```python<br>import pygame<br>import random<br>import time<br><br>def get_weather():<br> choices = ['rainy', 'sunny', 'cloudy', 'partly cloudy']<br> weather = random.choice(choices)<br> return weather<br><br>def get_location():<br> choices = ['the city', 'the beach', 'the forest', 'on the road']<br> location = random.choice(choices)<br> return location<br><br>def get_job():<br> return 'You are a hat'<br><br>def get_player_choices():<br> return ['Look Around', 'Explore Your Surroundings', 'Do Your Job', 'Play With Your Hair']<br><br>def get_player.job():<br> job = get_job()<br> print(job)<br><br>def get_player_weather():<br> weather = get_weather()<br> print(f'The weather is {weather}') <br><br>def get_player_location():<br> location = get_location()<br> print(f'You are in {location}')<br><br>def get_player_situation():<br> get_player_weather()<br> get_player_location()<br><br>def start_game():<br> job = get_player.job()<br> situation = get_player_situation()<br> print(f'What do you want to do?')<br> choices = get_player_choices()<br> for choice in choices:<br> print(choice)<br><br>def main():<br> pygame.init()<br> pygame.display.set_caption('Game')<br> width = 500<br> height = 500<br> screen = pygame.display.set_mode((width, height))<br> clock = pygame.time.Clock()<br> running = True<br> start_game()<br> while running:<br> for event in pygame.event.get():<br> if event.type == pygame.QUIT:<br> running = False<br> clock.tick(60)<br> pygame.quit()<br><br>if __name__== "__main__":<br> main()<br>```<br><br>I'm really new to coding, so if you have any other general advice let me know. I'm sure this will be a very easy fix, but I can't seem to get it. Right now the game window pops up, and then a second later the terminal closes. I want the terminal to stay open and keep accepting key presses until I close the game window.
Comments (2) 4026 👁️