Jun-08-2023, 11:34 AM
You should write programs in a file instead typing them in the Python interactive interpreter.
This is what you file would look like. I fixed and commented some errors/inconcistencies.
This is what you file would look like. I fixed and commented some errors/inconcistencies.
import pygame WIDTH, HEIGHT = 900, 500 WIN = pygame.display.set_mode((WIDTH, HEIGHT)) # Should have 1 or two blank lines before a function def main(): run = True while run: for event in pygame.event.get(): if event.type == pygame.QUIT: run = False # Should have 1 space before and after = pygame.quit() # You had an indentation error if __name__ == "__main__": # Double underscores. You had single main() # Function name is lower case. You called Main()If the file is named "mypygame.py" you run the file like this:
Output:python mypygame.py'
pygame 2.1.3.dev8 (SDL 2.0.22, Python 3.11.1)
Hello from the pygame community. https://www.pygame.org/contribute.html
Depending on what OS you are using, you might have to type "python3 mypygame,py"