0

My pygame program does not seems to load images. I tried image.load() by directly entering the image path as well by joining directories. I tried the code on Sublime Text as well as IDLE. File Source: C:\Users\Aich\Documents\PythonProjects\Trial Image Source: C:\Users\Aich\Desktop\Sprite1.png (I've currently kept image and file in different locations but keeping them at same location did not yield anything)

I am using Windows 8.1.

import pygame
pygame.init()
white = (255, 255, 255)

x = 500
y = 400

display_surface = pygame.display.set_mode((x,y))

pygame.display.set_caption('Image')

image = pygame.image.load(r'C:\Users\Aich\Desktop\Sprite1.png').convert()

while True:
    display_surface.fill(white)
    display_surface.blit(image , (0,0))

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()

    pygame.display.update()

0 Answers0