import pygame
#pygmme초기화
pygame.init()
#창 크기 설정
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 600
#창 설정
display_surface = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
pygame.display.set_caption("이미지 붙이기")
**#이미지 붙이고 설정
elephant_image = pygame.image.load("elephant.png")
elephant_rect = elephant_image.get_rect()
elephant_rect.topleft = (100,100)**
#게임이 동작하는 동안 이벤트
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
**display_surface.blit(elephant_image, elephant_rect)**
#디스플레이 업데이트
pygame.display.update()
pygame.quit()
아래는 실습에 사용한 코끼리 png 이미지 파일입니다.