Skip to content

fix: make pygame dependency optional in Snake Game (#635) - #784

Merged
steam-bell-92 merged 2 commits into
steam-bell-92:mainfrom
dhruvpatel16120:fix-snakegame
May 26, 2026
Merged

fix: make pygame dependency optional in Snake Game (#635)#784
steam-bell-92 merged 2 commits into
steam-bell-92:mainfrom
dhruvpatel16120:fix-snakegame

Conversation

@dhruvpatel16120

Copy link
Copy Markdown
Contributor

📝 Description

This PR resolves Issue #635 by making the pygame dependency optional in the Snake Game project.

Previously, the game crashed on systems where pygame was not installed due to direct imports for sound handling:
ModuleNotFoundError: No module named 'pygame'

Changes Made

  • Wrapped pygame imports inside try-except ImportError blocks.
  • Added fallback execution when pygame is unavailable.
  • Disabled sound effects gracefully instead of terminating the game.
  • Added informative console warnings to guide users for optional pygame installation.
  • Preserved compatibility with the repository’s lightweight and zero-dependency-friendly structure.

This improves usability and allows the game to run successfully on fresh Python setups without requiring additional packages.

🔗 Linked Issue

Closes #635


📋 Contribution Checklist

  • My code strictly adheres to the project guidelines (Standard library only, procedural code, clean spacing).
  • I have verified that my files are placed in the correct directory.
  • I have tested my changes thoroughly on my local machine.
  • I have included interactive emojis and clean console/UI outputs.
  • GSSoC 2026: I have been formally assigned to Issue 🐛 fix(snake): make pygame import optional to prevent startup crash #635 and noted it above.

@vercel

vercel Bot commented May 26, 2026

Copy link
Copy Markdown

@dhruvpatel16120 is attempting to deploy a commit to the Anuj's projects Team on Vercel.

A member of the Team first needs to authorize it.

@dhruvpatel16120

Copy link
Copy Markdown
Contributor Author

hello @steam-bell-92,please check the PR merge it if everything is perfect or let me know if any changes i have to made in !

@dhruvpatel16120

Copy link
Copy Markdown
Contributor Author

if you have time then please approve my issue : #636 and #637 under gssoc !

@steam-bell-92 steam-bell-92 added type:bug Something isn't working level:beginner gssoc:approved GSSoC 2026 approving tag mentor:steam-bell-92 labels May 26, 2026
@steam-bell-92
steam-bell-92 merged commit 5e5b6d7 into steam-bell-92:main May 26, 2026
6 of 10 checks passed
@dhruvpatel16120
dhruvpatel16120 deleted the fix-snakegame branch May 26, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC 2026 approving tag level:beginner type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 fix(snake): make pygame import optional to prevent startup crash

2 participants