forked from gidden/flabbybird
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhw2.py
36 lines (31 loc) · 1023 Bytes
/
hw2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pygame, sys, pygame.locals
pygame.init()
winsize = (800, 450)
window=pygame.display.set_mode(winsize, 0, 32)
pygame.display.set_caption("Flabbybird")
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
tree = pygame.image.load('pyne_icon_small.png').convert()
tree = pygame.transform.scale(tree, (90, 77))
#tree = pygame.transform.threshold(tree, tree, BLACK, threshold = (0,0,0,0), diff_color = (0,0,0,0), change_return = 2)
rects={'tree': tree.get_rect()}
while True:
dy = 0
for event in pygame.event.get():
if event.type==pygame.locals.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
dy = 10
for rect in rects:
rects[rect].right += 2
rects[rect].top += 1 - dy
if rects[rect].right > winsize[0]:
rects[rect].topleft=(0, 0)
window.fill(WHITE)
window.blit(tree, rects['tree'])
pygame.time.Clock().tick(60)
pygame.display.update()