MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / draw_board

Function draw_board

projects/Connect Four/main.py:84–124  ·  view source on GitHub ↗
(board)

Source from the content-addressed store, hash-verified

82
83
84def draw_board(board):
85 for c in range(COLUMN_COUNT):
86 for r in range(ROW_COUNT):
87 pygame.draw.rect(
88 screen,
89 BLUE,
90 (c * SQUARESIZE, r * SQUARESIZE + SQUARESIZE, SQUARESIZE, SQUARESIZE),
91 )
92 pygame.draw.circle(
93 screen,
94 BLACK,
95 (
96 int(c * SQUARESIZE + SQUARESIZE / 2),
97 int(r * SQUARESIZE + SQUARESIZE + SQUARESIZE / 2),
98 ),
99 RADIUS,
100 )
101
102 for c in range(COLUMN_COUNT):
103 for r in range(ROW_COUNT):
104 if board[r][c] == 1:
105 pygame.draw.circle(
106 screen,
107 RED,
108 (
109 int(c * SQUARESIZE + SQUARESIZE / 2),
110 height - int(r * SQUARESIZE + SQUARESIZE / 2),
111 ),
112 RADIUS,
113 )
114 elif board[r][c] == 2:
115 pygame.draw.circle(
116 screen,
117 YELLOW,
118 (
119 int(c * SQUARESIZE + SQUARESIZE / 2),
120 height - int(r * SQUARESIZE + SQUARESIZE / 2),
121 ),
122 RADIUS,
123 )
124 pygame.display.update()
125
126
127board = create_board()

Callers 1

main.pyFile · 0.85

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected