Repository navigation
Expand file tree
/
Copy pathtemporario.py
More file actions
109 lines (70 loc) · 2.66 KB
/
Copy pathtemporario.py
File metadata and controls
109 lines (70 loc) · 2.66 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#from graph.weighted_human_maze import labirinth as maze
import pygame,time,random
from graph.color import *
from graph.Create_Graph.Maze_islands_maker.randomHumanizedweightMaze import assign_weights
COLS = 80
ROWS = 80
rect_size = 8
maze = assign_weights(list(list( White for _ in range(COLS) ) for _ in range(ROWS)),rect_size = rect_size, end_animation = True,N_loops = 300)
pygame.init()
screen_height = 700
screen_width = 1250
screen = pygame.display.set_mode((screen_width,screen_height))
screen.fill( Black ) # background color
weights = [
royal_blue,
brown,
Black,
]
for i in range(ROWS):
for j in range(COLS):
if maze[i][j] in weights:
if i > ROWS/2 and j < COLS/2:
maze[i][j] = royal_blue
elif j > ROWS/2 and i < COLS/2:
maze[i][j] = brown
else: maze[i][j] = Black
def display_maze():
N = len(maze)
print(N)
for x in range(N):
time.sleep(0.01)
for y in range(N):
pygame.draw.rect(screen , maze[x][y] , ( 50 + rect_size*x , 50 + rect_size*y , rect_size , rect_size ) )
pygame.display.update()
maze[0][1] = maze[1][1] = weights[0]
time.sleep(1)
font = pygame.font.Font('freesansbold.ttf',20)
text = font.render("Entry (Entrada).",True, Dark_yellow)
screen.blit(text,text.get_rect(center = (100,30)))
font = pygame.font.Font('freesansbold.ttf',20)
text = font.render("Exit (Saida)" ,True, Green)
screen.blit(text,text.get_rect(center = (560,570)))
font = pygame.font.Font('freesansbold.ttf',40)
text = font.render("in Heap",True, Blue)
screen.blit(text,text.get_rect(center = (800,250)))
font = pygame.font.Font('freesansbold.ttf',40)
text = font.render("seen",True, Dark_yellow)
screen.blit(text,text.get_rect(center = (800,350)))
pygame.display.update()
display_maze()
with open("temp.txt","w") as f:
f.write("labirinth = [")
for line in maze:
f.write(str(line)+ ',\n')
f.write("]")
print("labirinth = ",maze)
pause = True
running = True
while running :
# pygame stuff:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit() #exit pygame,
running = False #exit() program
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE: #press breakspace to pause or play
pause = not pause
time.sleep(0.2)
if pause:
continue