Skip to content

Commit 6917de2

Browse files
committed
Make food round
1 parent a655b86 commit 6917de2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

main.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ def increment_score():
4646
score += 1
4747
score_var.set(f"Score: {score}")
4848

49-
def render_point(point, color):
49+
def render_point(point, color, square=True):
5050
coord_x, coord_y = point.x * TILE_WIDTH, point.y * TILE_WIDTH
51-
return canvas.create_rectangle(coord_x, coord_y,
52-
coord_x + TILE_WIDTH,
53-
coord_y + TILE_WIDTH,
54-
fill=color,
55-
outline='white')
51+
renderer = canvas.create_rectangle if square else canvas.create_oval
52+
return renderer(coord_x, coord_y,
53+
coord_x + TILE_WIDTH,
54+
coord_y + TILE_WIDTH,
55+
fill=color,
56+
outline='white')
5657

5758
def render_food(food):
58-
render_point(food, 'red')
59+
render_point(food, 'red', square=False)
5960

6061
def render_head(snake):
6162
if snake.next_position() == food or snake.head == food:

0 commit comments

Comments
 (0)