无法屏蔽任何内容。为什么不?

cannot blit anything to screen. why not?

所以我正在尝试 blit tonk 但它不起作用。你能帮我吗?它显示的都是黑色

import pygame,pynput
pygame.init()

width = 700
height = 700
screen = pygame.display.set_mode((width,height))
pygame.display.set_caption('generic shooter pew pew')
Tonk = pygame.image.load("TONK.png")
screen.blit(Tonk,(0,0))

run = True
while run:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
            exit()

    clock = pygame.time.Clock()
    clock.tick(60)

您需要在 while 循环中进行 blit 并添加显示更新:

import pygame,pynput
pygame.init()

width = 700
height = 700
screen = pygame.display.set_mode((width,height))
pygame.display.set_caption('generic shooter pew pew')
Tonk = pygame.image.load("TONK.png")
clock = pygame.time.Clock()

run = True
while run:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
            exit()
    screen.blit(Tonk,(0,0))
    pygame.display.flip()

    clock.tick(60)