import pygame
pygame.init()
black = [0, 0, 0]
white = [255,255,255]
red = [255, 0, 0]
rect_x = 0
sizeX = 400
sizeY = 500
#define window sizeX, sizeY in values
size = [sizeX, sizeY]
#by values
rectWidth = 50
#define width of a rect
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Denkybrain Loves Graphics")
done = False
look = 0
clock = pygame.time.Clock()
while done == False:
for event in pygame.event.get() :
if event.type == pygame.QUIT :
done = True
screen.fill(white)
if look == 0 :
rect_x = rect_x + 0.1
if rect_x > sizeX-rectWidth :
look = 1
else :
if rect_x < 0 :
look = 0
rect_x = rect_x - 0.1
pygame.draw.rect(screen, black, [rect_x,50,50,50])
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 |
falling snows (0) | 2016.07.27 |
A rect that goes left and right (0) | 2016.07.27 |
Graphics - rect and text (0) | 2016.07.26 |
댓글