Question : load images pygame
Answered by : kirik-altekar
import pygame
from pygame.locals import*
img = pygame.image.load('clouds.bmp')
white = (255, 64, 64)
w = 640
h = 480
screen = pygame.display.set_mode((w, h))
screen.fill((white))
running = 1
while running: screen.fill((white)) screen.blit(img,(0,0)) pygame.display.flip()
Source : https://stackoverflow.com/questions/8767129/how-to-have-an-image-appear-in-python-pygame | Last Update : Fri, 11 Dec 20
Question : add image to pygame window
Answered by : the-devkid
import pygame, sys
from pygame.locals import *
pygame.init()
window = pygame.display.set_mode((600,400))
pygame.display.set_caption('Test')
img = pygame.image.load('yourimg.png') # if your image is in a folder type 'folder/yourimg.png'
imgX, imgY = 50, 50
while True: window.fill((0,0,0)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() window.blit(img, (imgX,imgY)) pygame.display.update()
Source : | Last Update : Wed, 11 May 22