我有一个 pygame 程序,旨在用 Grass.png 填充 pygame 窗口:
import pygame, sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode([600, 500])
def DrawBackground(background, xpos, ypos):
screen.blit(background, [xpos, ypos])
background = pygame.image.load('Grass.png')
xpos = 0
ypos = 0
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
while ypos >= -500:
while xpos <= 600:
DrawBackground(background, xpos, ypos)
xpos += 100
ypos -= 100
pygame.display.flip()
唯一的问题是,它只用图像填充前 100 像素行。代码有什么问题?谢谢。