python-3.x PyGame“blit”不工作,但没有错误消息[重复]

icnyk63a  于 2023-04-22  发布在  Python
关注(0)|答案(1)|浏览(98)

此问题已在此处有答案

Pygame window not responding after a few seconds(3个答案)
6天前关闭。
由于某种原因,PyGame的“blit”命令对我不起作用。每当我运行代码时,屏幕上什么也没有出现,但控制台中没有错误消息。

import pygame

pygame.init()
screen = pygame.display.set_mode((1920, 1080))
clock = pygame.time.Clock()

def loadImages():
    global ground
    ground = pygame.image.load("assets/ground/tile.png")

loadImages()

# Game Loop
while True: 
    screen.blit(ground, (0, 0))
    pygame.display.update()
    clock.tick(30)
c9qzyr3d

c9qzyr3d1#

import pygame,sys

pygame.init()
screen = pygame.display.set_mode((1920, 1080))
clock = pygame.time.Clock()

def loadImages():
    global ground
    ground = pygame.image.load("assets/ground/tile.png").convert_alpha()

loadImages()

# Game Loop
while True: 
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    screen.blit(ground, (0, 0))
    pygame.display.update()
    clock.tick(30)

试试这个

相关问题