-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (31 loc) · 1.25 KB
/
main.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
# 28/02/2021
# Pathfinder
# TODO Create Destination and entry node
# TODO Add diagonal movements
# TODO Force quit / exit search
# TODO Mouse drag
import pygame
import sys
import constants
from functions import *
def main():
list_of_block_location_lists = draw_grid()
logic_table = generate_logic_table()
src_dst_node_state = [False, False]
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
mouse_x, mouse_y = pygame.mouse.get_pos()
position, cell_logic, cell_index = did_player_clicked_on_block(list_of_block_location_lists, logic_table, mouse_x, mouse_y)
if position != INVALID_BLOCK_SELECTED_FLAG:
logic_table, src_dst_node_state = draw_block(position, cell_logic, cell_index, logic_table, src_dst_node_state)
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
src_node_state = src_dst_node_state[0]
dst_node_state = src_dst_node_state[0]
if src_node_state and dst_node_state:
path_find(logic_table)
if __name__ == "__main__":
main()