Skip to content
This repository was archived by the owner on Aug 2, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Play it at https://replit.com/@UniqueOstrich18/CLI-Snake

### Controls:
- WASD to control the snake
- P to pause/resume
- X to quit game
- Arrow keys to navigate in menus
- C on title screen to access settings
Expand Down
1 change: 1 addition & 0 deletions extradata.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"save": false,
"default":
[" - WASD to move snake",
" - P to pause/resume",
" - X to quit game",
"",
"Tip: You can make the snake move faster by moving it",
Expand Down
8 changes: 8 additions & 0 deletions snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def resetGame(self):
self.extra_turn = False
self.extra_turn_active = False
self.inputQueue = []
self.paused = False
self.currentHighScore = 0
self.playSound = False
self.foodCount = 1
Expand Down Expand Up @@ -659,6 +660,10 @@ def getInput(self):
self.resetTimer = True
break

#toggle pause if key p is pressed
elif keyString == "p":
self.paused = not self.paused

#sleep for a bit so we don't waste cpu
time.sleep(0.01)

Expand Down Expand Up @@ -706,6 +711,9 @@ def main(self):
if self.stop == True:
break

if self.paused:
continue

if len(self.inputQueue) > 0:
self.direction = self.inputQueue.pop(0)

Expand Down