问题遇到的现象和发生背景
窗口初始颜色为绿色,执行pygame.display.update(rct)以后,整个窗口除了rct以外,都变成了黑色,如何把rct参数去掉,则不会变为黑色。
pygame.display.update(rct)局部更新,rct以外的区域会变为黑色?
问题相关代码,请勿粘贴截图
from pygame.locals import *
import pygame.pixelarray
pygame.init()
screen = pygame.display.set_mode((600, 400))
pygame.display.set_caption('c语言中文网')
screen.fill((50, 200, 100))
# 加载一张图片
image_surface = pygame.image.load("basketball.png")
rct = image_surface.get_rect()
screensurf = pygame.display.get_surface()
while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()
rct.x = rct.x + 1
screen.blit(image_surface, rct)
pygame.display.update(rct)