[英]Why my background image is not appearing in the window in pygame?
Why my background image is not appearing in the window in pygame?为什么我的背景图片没有出现在 pygame 的 window 中?
import pygame
pygame.init()
screen = pygame.display.set_mode ((1000,437))
background = pygame.image.load("background.jpg")
running = True
while running:
screen.fill((255,255,255))
screen.blit(background,(0,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
You just need to update the display with this command: pygame.display.update()
Place the command at the end of your while running: loop.您只需要使用以下命令更新显示:
pygame.display.update()
将命令放在运行结束时:循环。
pygame.init()
screen = pygame.display.set_mode ((1000,437))
background = pygame.image.load("background.jpg")
running = True
while running:
screen.fill((255,255,255))
screen.blit(background,(0,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.update()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.