본문 바로가기

load image and set transparency

by 머니해커_개발자 2016. 7. 27.

import pygame

import random


pygame.init()


black = [0, 0, 0]

white = [255,255,255]


sizeX = 400

sizeY = 500

size = [sizeX, sizeY]


screen = pygame.display.set_mode(size)

pygame.display.set_caption("Denkybrain Loves Graphics")


done = False

clock = pygame.time.Clock()


## go type codes here


c = pygame.image.load("a.png").convert()

c.set_colorkey(black)

#make the black color transparent color



###

while done == False:

    clock.tick(20)

    for event in pygame.event.get() :

        if event.type == pygame.QUIT :

            done = True

    screen.fill(white)

    screen.blit(c, [100,100] )

    pygame.display.flip()

pygame.quit()




image from  https://s3.amazonaws.com/gameartpartnersimagehost/wp-content/uploads/edd/2015/09/Zombie-Army-Character-Royalty-Free-Game-Art.png

'Python > 학습' 카테고리의 다른 글

remove black blocks with mouse(sprite)  (0) 2016.07.28
moving circle every 2 secs (using class)  (0) 2016.07.28
falling snows  (0) 2016.07.27
fix the code moving a rect  (0) 2016.07.27
A rect that goes left and right  (0) 2016.07.27

댓글

최신글 전체

이미지
제목
글쓴이
등록일