-
Notifications
You must be signed in to change notification settings - Fork 8
/
scroller.py
67 lines (44 loc) · 1.31 KB
/
scroller.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import pygame
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="A scroller to scroll through the image")
parser.add_argument('-f', dest='file', type=str, default=None,
help='Set image path')
args = parser.parse_args()
pygame.init()
display_width = 800
display_height = 600
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('Scroller')
black = (0,0,0)
white = (255,255,255)
clock = pygame.time.Clock()
exit = False
mazeImg = pygame.image.load(args.file)
size = mazeImg.get_rect().size
new_size = (size[0]*4,size[1]*4)
mazeImg = pygame.transform.scale(mazeImg, new_size)
def maze(x,y):
gameDisplay.blit(mazeImg, (int(x),int(y)))
x = 0
y = 0
speed = 0.75
down = True
while not exit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit = True
gameDisplay.fill(black)
maze(x,y)
if down:
y-=speed
else:
y+=speed
if y < (-new_size[1]+display_height):
down = False
elif y > 0:
down = True
pygame.display.update()
clock.tick(60)
pygame.quit()
quit()