简体   繁体   中英

“Python has stopped working” - PyGame on Windows

Having trouble getting my basic game to start up - maybe 1 in 5 games start up - the others end immediately with "Python has stopped working".

import pygame, sys
from pygame.locals import *

pygame.init()
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Hello World!')
while True: # main game loop
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
    pygame.display.update()

Try using an older version on python as suggested by furas. When I run your code on my laptop it starts up fine, I am using python 2.7

If you are using python 3.4.x pygame will not work, its latest version only runs on 3.3.x.

I have run your program multiple times and it runs every time with a box that has the caption "Hello World".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM