Somebody asked a similar question here, but it didn't get answered.
I have Python 2.7.11, OSX 10.11, and pygame 1.9.1. Every time I run the program, the window appears, and then closes with the error "Segmentation fault: 11". I got this from the pygame tutorials, and then modified it slightly to prevent an infinite loop. (the same error occurs even if I use the "while 1" loop used in the tutorial.)
Why is this happening and how can I fix it? Thanks!
import sys, pygame
pygame.init()
size = width,height = 320,240
speed = [2,2]
black = 0,0,0
screen = pygame.display.set_mode(size)
ball = pygame.image.load("ball.gif")
ballrect = ball.get_rect()
for i in range(100):
ballrect = ballrect.move(speed)
if ballrect.left < 1 or ballrect.right > width - 1:
speed[0] = -speed[0]
if ballrect.top < 1 or ballrect.bottom > height - 1:
speed[1] = -speed[1]
screen.fill(black)
screen.blit(ball,ballrect)
pygame.display.flip()