본문 바로가기

falling snows

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


stars = [] # list for coordinates of star objects


for i in range(50):

    x = random.randrange(0, 400)

    y = random.randrange(0, 500)

    stars.append([x,y]) # append x,y coordinates into 'stars' list


###

while done == False:

    for event in pygame.event.get() :

        if event.type == pygame.QUIT :

            done = True

    screen.fill(black)

    

    for i in range(len(stars)):

        pygame.draw.circle(screen, white, stars[i], 2)

        stars[i][1] = stars[i][1] + 1

        if stars[i][1] >  sizeY :

            stars[i][1] = -1

    clock.tick(20)

    pygame.display.flip()

pygame.quit()



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

moving circle every 2 secs (using class)  (0) 2016.07.28
load image and set transparency  (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
Graphics - rect and text  (0) 2016.07.26

댓글

최신글 전체

이미지
제목
글쓴이
등록일