2
votes

I am just on my first steps using pygame on python 3.5 on mac osx 10.11.1. I think i have properly installed pygame because when i run

     import pygame 

it accepts it. I am running some tests on basic pygame use and i have a problem with pygame.display.set_mode This is the code:

    import pygame

    pygame.init()

    screen = pygame.display

    screen.set_mode((720,480))

it runs ok without any bugs but the pygame screen that opens (different from the IDLE screen) it freezes. The cursor becomes this spinning rainbow thing.

Excuse me if this is a really dumb question but i'm really new at this and i have been searching all day and can't find something similar.

Thank you for your time

1

1 Answers

2
votes

What you need to write is an event loop and a quit event, as the user cannot close the window. For the event loop I would do something like:

running = True
while running: # This would start the event loop
    for event in pygame.event.get():
        if event.type == pygame.QUIT: # This would be a quit event.
            running = False # So the user can close the program
    screen.fill(0,0,0) # This fills the screen with black colour.
    pygame.display.flip() # This "flips" the display so that it shows something
pygame.quit()

I hope this helps! The event loop is just something that keeps the program running, without it the code would look quite confusing so it's best to have one.