From 9b3551e2a22742fe62c2d6a76925ac5f7a1ee530 Mon Sep 17 00:00:00 2001 From: Linxi Li Date: Sat, 22 Jan 2022 13:41:13 -0500 Subject: [PATCH] [+] A1 P2 Draw three nodes --- assignments/A1/a1_part2.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/assignments/A1/a1_part2.py b/assignments/A1/a1_part2.py index 6433f91..cc01a06 100644 --- a/assignments/A1/a1_part2.py +++ b/assignments/A1/a1_part2.py @@ -151,6 +151,11 @@ def draw_link(screen: pygame.Surface, start: Tuple[int, int], end: Tuple[int, in """ +def index_to_pos(i: int) -> Tuple[int, int]: + xi, yi = i % GRID_SIZE, i // GRID_SIZE + return xi * GRID_WIDTH, yi * GRID_WIDTH + + def draw_three_nodes(screen_size: Tuple[int, int]) -> None: """Draw three nodes on a pygame screen of the given size. @@ -170,7 +175,10 @@ def draw_three_nodes(screen_size: Tuple[int, int]) -> None: # TODO: Complete this function so that it draws the above three nodes and the # links between them and "None". Once you are done, remove this comment. - ... + draw_grid(screen) + draw_node(screen, node1, index_to_pos(0)) + draw_node(screen, node2, index_to_pos(1)) + draw_node(screen, node3, index_to_pos(2)) # Don't change the code below (it simply waits until you close the Pygame window) pygame.display.flip()