[Python] I’m having a problem in Pygame with displaying the sky [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 2, 2025.

  1. Stack

    Stack Membro Participativo

    I'm making a platformer game, and I'm trying to create the world but the sky.png file doesn't show up. I tried with other PNG files, and it still doesn't work.

    I inserted the location and coordinates, but instead of it appearing, it was just a black screen.

    Here's my code:

    import sys

    import pygame

    class Game:
    def __init__(self):
    pygame.init()

    pygame.display.set_caption('Shadow samurai')
    self.screen = pygame.display.set_mode((1200,800))

    self.clock = pygame.time.Clock()

    self.img = pygame.image.load('assets/sky.png')

    self.img_pos = (160, 260)
    self.movement = [False, False]

    def run(self):
    while True:
    self.screen.blit(self.img, self.img_pos)

    for event in pygame.event.get():
    if event.type == pygame.QUIT:
    pygame.quit()
    sys.exit()
    if event.type == pygame.KEYDOWN:
    if event.key == pygame.K_UP:
    self.movement[0] = True
    if event.key == pygame.K_DOWN:
    self.movement[1] = True
    pygame.display.update()
    self.clock.tick(60)

    Game().run()

    Continue reading...

Compartilhe esta Página