From f7fe6529460c2e572e2a137ec995ba8af811077f Mon Sep 17 00:00:00 2001 From: NoeDimitri <141983245+Duckpotatoe@users.noreply.github.com> Date: Sun, 15 Feb 2026 01:38:24 -0500 Subject: [PATCH 1/2] Added start menu --- src/freegames/snake.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/freegames/snake.py b/src/freegames/snake.py index f1f2599f..bd0ad9f1 100644 --- a/src/freegames/snake.py +++ b/src/freegames/snake.py @@ -10,13 +10,33 @@ from random import randrange from turtle import * - from freegames import square, vector food = vector(0, 0) snake = [vector(10, 0)] aim = vector(0, -10) - +game_started = False + +def start_game(): + #Clear the screen and start the game loop. + global game_started + if game_started: + return + game_started = True + clear() + move() + +def draw_start_screen(): + #Draws the initial menu text. + clear() + up() + goto(0, 50) + color('black') + write("SNAKE", align="center", font=("Courier", 30, "bold")) + + goto(0, -50) + write("Press SPACE to Start", align="center", font=("Courier", 16, "normal")) + update() def change(x, y): """Change snake direction.""" @@ -66,5 +86,7 @@ def move(): onkey(lambda: change(-10, 0), 'Left') onkey(lambda: change(0, 10), 'Up') onkey(lambda: change(0, -10), 'Down') -move() +#Sets up start menu +onkey(start_game, 'space') +draw_start_screen() done() From dce2752e43ccf33b8eaeaea949a7aff02029834e Mon Sep 17 00:00:00 2001 From: NoeDimitri <141983245+Duckpotatoe@users.noreply.github.com> Date: Mon, 16 Feb 2026 16:15:26 -0500 Subject: [PATCH 2/2] Updated syntax issues --- src/freegames/snake.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/freegames/snake.py b/src/freegames/snake.py index bd0ad9f1..baffb167 100644 --- a/src/freegames/snake.py +++ b/src/freegames/snake.py @@ -6,19 +6,21 @@ 2. How can you make the snake go around the edges? 3. How would you move the food? 4. Change the snake to respond to mouse clicks. +5. How can you change the design of the start menu? +6. How would you change the button required to start the game? """ from random import randrange from turtle import * from freegames import square, vector - food = vector(0, 0) snake = [vector(10, 0)] aim = vector(0, -10) -game_started = False +game_started = False +"""Variable to determine game state, needed to prevent infinite loop""" def start_game(): - #Clear the screen and start the game loop. + """Clear the screen and start the game loop.""" global game_started if game_started: return @@ -27,7 +29,7 @@ def start_game(): move() def draw_start_screen(): - #Draws the initial menu text. + """Draws the initial menu text.""" clear() up() goto(0, 50) @@ -86,7 +88,7 @@ def move(): onkey(lambda: change(-10, 0), 'Left') onkey(lambda: change(0, 10), 'Up') onkey(lambda: change(0, -10), 'Down') -#Sets up start menu +"""Sets up start menu""" onkey(start_game, 'space') draw_start_screen() done()