Ask coding questions

← Back to all posts
how to load image
MagnusFrid

i want to load a png-file into my pygame and also a background.

Answered by lynnlo [earned 5 cycles]
View Answer
Voters
MagnusFrid
Comments
hotnewtop
lynnlo

To load the image use image = pygame.image.load("Julstrumpa.png")
To display it on the screen use screen.blit(image,(0,0)) inside a loop.

RookiesNCreamN

import pygame

clock = pygame.time.Clock()

from pygame.locals import *
pygame.init()

pygame.display.set_caption('Pygame Window')

Window_Size = (400, 400)

screen = pygame.display.set_mode(Window_Size, 0, 32)

player_image = pygame.image.load('download (1).png')

while True:

pygame.display.update()
clock.tick(60)