# 1 - Import library
import time
import pygame
from pygame.locals import *
# 2 - Initialize the game
pygame.init()
width, height = 640, 480
screen = pygame.display.set_mode((width, height))
background = pygame.image.load("resources/images/forest.png")
while True:
# 5 - clear the screen before drawing it again
screen.fill(0)
# 6 - draw the basic screen elements
screen.blit(background,(0,0))
# 8 - update the screen
pygame.display.update()
time.sleep(0.5)
当我运行这个时,我得到了Process,退出代码为139(被信号11:SIGSEGV中断)。
这与没有足够的RAM有关吗?或者也许是32位版本的python?
同样完全删除循环会产生相同的退出代码。
# 1 - Import library
import time
import pygame
from pygame.locals import *
# 2 - Initialize the game
pygame.init()
width, height = 640, 480
screen = pygame.display.set_mode((width, height))
background = pygame.image.load("resources/images/forest.png")
# 5 - clear the screen before drawing it again
screen.fill(0)
# 6 - draw the basic screen elements
screen.blit(background,(0,0))
# 8 - update the screen
pygame.display.update()
time.sleep(0.5)