0

I have a MacOS Catalina 10.15.4 and Python 3.8.1. I finally got pygame 1.9.6 to install through the terminal with homebrew,xcode,and xquartz downloaded and imported it in my program. I'm a student and following instructions for a project so all the code has already been provided to me and says that a pygame window should show up. When I run the Python icon on my dock bounces up and down and it prints in the shell "Game console initialized pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html". I've tried to read and mess around with what versions work with what but I'm pretty lost to what else I should be doing. Thanks for the help! Here is my code:

print("Game console initialized")

import pygame

pygame.init()

screenSize = width,height = 240,180
display = pygame.display.set_mode(screenSize)

starImage = pygame.image.load("star.gif")
starBox = starImage.get_rect()

speed = [3,5]

keepPlaying = True
while keepPlaying:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            keepPlaying = False


    starBox = starBox.move(speed)

    if starBox.left<0 or starBox.right > width:
        speed[0] = - speed[0]


    if starBox.top <0 or starBox.bottom > height:
        speed[1] = - speed[1]

    black = 0,0,0
    display.fill(black)

    display.blit(starImage, starBox)
    pygame.display.flip()

    pygame.time.delay(100)
pygame.display.quit()
pygame.quit()
Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52

0 Answers0