Pygame image wont show up until I close the window
-
I am creating a game with pygame and an image won't show up until the window is loading to be closed. This is my code so far:
import pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))pygame.display.set_caption("ALix")
icon = pygame.image.load("nater.jpg")
pygame.display.set_icon(icon)playerImg = pygame.image.load('nater.jpg')
playerX = 400
playerY = 300def player():
screen.blit(playerImg, (playerX, playerY))running = True
while running:
screen.fill((255, 255, 255))for event in pygame.event.get(): if event.type == pygame.QUIT: running = False
player()
pygame.display.update()
-
I am creating a game with pygame and an image won't show up until the window is loading to be closed. This is my code so far:
import pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))pygame.display.set_caption("ALix")
icon = pygame.image.load("nater.jpg")
pygame.display.set_icon(icon)playerImg = pygame.image.load('nater.jpg')
playerX = 400
playerY = 300def player():
screen.blit(playerImg, (playerX, playerY))running = True
while running:
screen.fill((255, 255, 255))for event in pygame.event.get(): if event.type == pygame.QUIT: running = False
player()
pygame.display.update()
-
I do not know pygame but I notice that you do not call
pygame.display.update()
until the end of the program. In most GUI applications you need to call update during normal running in order to keep it current.