我有是指具有Grass.png填補pygame的窗口pygame的程序: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個像素行。代碼有什麼問題?謝謝。