1. Surface란
- 모든 2D객체 (스크린, 배경 이미지, 게임 캐릭터 등)
- 색이나 이미지를 가지는 빈 시트
2. Surface 생성
size = (너비, 높이) = (32, 32)
empty_surface = pygame.Surface(size)
3. blitting (블릿팅)
- 특정 서피스의 픽셀값들을 다른 서피스로 복사하는 것
- 서피스들을 다른 서피스에 디스플레이 하기 위해서 필요
- 서피스에 블리팅된 모습 디스플레이:
pygame.display.filp()
pygame.display.update()
4. Surface를 blitting 하기
서피스객체.blit(src_surface,position)
size = (width, height) = (640, 480)
screen = pygame.display.set_mode(size)
p_pos = (x, y) = (20, 30)
penguin_img = pygame.image.load("penguin.png").convert()
screen.blit(penguin_img, p_pos)
pygame.display.flip()
5. Surface 주요 메서드
blit 메서드
blit(src, pos)
blit((src,pos), (src,pos), ...)
fill 메서드
fill((r,g,b))
convert() 메서드
- 디스플레이 서피스와 동일한 픽셀 형식의 서피스 복사본 반환해주는 메서드
pygame.image.load(image_path).convert()
pygame.image.load(image_path).convert_alpha()
get_rect 메서드
get_rect()
get_size 메서드
get_size()