-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathviewer.py
More file actions
83 lines (64 loc) · 1.68 KB
/
Copy pathviewer.py
File metadata and controls
83 lines (64 loc) · 1.68 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import pygame
# MINECRAFT COLORS
BLACK = (0, 0, 0)
GRAY = (96, 96, 96)
LGRAY = (192, 192, 192)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
WIDTH = 32
HEIGHT = 18
class Pixel():
def __init__(self, x, y, anim, size=10):
self.x = x
self.y = y
self.anim = anim
self.size = size
self.frame = 0
def draw(self):
""" Draws the current frame """
color_string = self.anim[self.frame]
color = RED
if color_string == "0":
color = BLACK
elif color_string == "7":
color = GRAY
elif color_string == "8":
color = LGRAY
elif color_string == "f":
color = WHITE
pygame.draw.rect(screen, color, [self.x * self.size, self.y * self.size, self.size, self.size])
self.frame += 1
# file setup
file = open("badapplePyTest.nut", "r")
all_animations = file.readlines()
all_animations = all_animations[::-1]
# pygame setup
pygame.init()
screen = pygame.display.set_mode((WIDTH * 10, HEIGHT * 10))
pygame.display.set_caption('Video Test')
clock = pygame.time.Clock()
pixel_list = []
current_x = 0
current_y = 0
for line in all_animations:
pixel_list.append(Pixel(current_x, current_y, line, 10))
current_x += 1
if current_x >= WIDTH:
current_x = 0
current_y += 1
done = False
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
# fill the screen with background color
screen.fill(WHITE)
# draw here:
for p in pixel_list:
p.draw()
# update the screen
pygame.display.update()
clock.tick(20)
pygame.quit()