-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtile.py
52 lines (39 loc) · 1.18 KB
/
tile.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
import pygame
import pascal
import time
TRIANGLE_SIZE = 600
GRANULARITY = 3
triangle_rows = pascal.Pascal(TRIANGLE_SIZE).getTriangle()
HEIGHT, WIDTH = 600, 600
FPS = 20
surface = pygame.display.set_mode((WIDTH,HEIGHT))
pygame.display.set_caption("pascal")
def draw(GRANULARITY):
y = GRANULARITY
for row in triangle_rows:
x = GRANULARITY
for tile in row:
# print(x, y)
# print(tile.drawTile(), end = ', ')
actual_val_color = tile.drawTile()
r, g, b = 0, 0, 0
rectangle = pygame.Rect(x, y, GRANULARITY, GRANULARITY)
# rectangle_inv = pygame.Rect(600-x, 600-y, 1, 1)
pygame.draw.rect(surface, tile.drawTile(), rectangle)
# pygame.draw.rect(surface, tile.drawTile(), rectangle_inv)
# rectangle.move(x + 69, y + 69)
x += GRANULARITY
# print()
y += GRANULARITY
pygame.display.update()
clock = pygame.time.Clock()
run = True
while True:
clock.tick(FPS)
draw(GRANULARITY)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if not run:
pygame.quit()
quit()