-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
89 lines (53 loc) · 1.82 KB
/
main.py
File metadata and controls
89 lines (53 loc) · 1.82 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
#Importações
import pygame
from config import largura_tela, altura_tela, mapa_coluna, mapa_linha, debug
from camera import cam_c, cam_l, cam_mov
from mapa import criar_mapa, desenhar_mapa, gerar_labirinto
from npc import campones
from ia import a_star, caminho_para_passos
#Execução do programa
def main():
#Parametrôs de inicialização
pygame.init()
pygame.display.set_caption("Labirinto Usando A* v0.1")
tela = pygame.display.set_mode((largura_tela, altura_tela))
clock = pygame.time.Clock()
mapa = criar_mapa(mapa_coluna, mapa_linha)
npc_campones = campones(1, 1)
cam_coluna = cam_c
cam_linha = cam_l
#Objetivo
altura = len(mapa)
largura = len(mapa[0])
objetivo_x = largura - 2
objetivo_y = altura - 2
#Npc
path = a_star(mapa, (npc_campones.x, npc_campones.y), (objetivo_x, objetivo_y))
if path:
npc_campones.set_path_from_positions(path)
#Objetivo recebendo valor/cor na grade
mapa[objetivo_y][objetivo_x] = 2
#Loop de Execução Global
loop = True
while loop:
#Checa os eventos
for eventos in pygame.event.get():
#Camera
teclas = pygame.key.get_pressed()
cam_coluna, cam_linha = cam_mov(teclas, cam_coluna, cam_linha)
#Fechando o Loop
if eventos.type == pygame.QUIT:
loop = False
#Mapa
desenhar_mapa(tela, mapa, cam_coluna, cam_linha, mapa_coluna, mapa_linha)
npc_campones.step(mapa)
npc_campones.desenhar(tela, cam_coluna, cam_linha)
#Fps
clock.tick(30)
#Executa o que foi processado
pygame.display.flip()
#Fechando o Aplicativo
pygame.quit()
#Iniciar Programa
if __name__ == "__main__":
main()