How nawalkavi/hangman works
This is a Pygame Hangman game with two modes: the player guesses a randomly selected word, or the AI guesses a player-chosen word. The main loop in main.py owns screen navigation, input handling, and coordination of game state and rendering. User.py and Question.py implement the two guessing models; Text.py and Hangman.py support presentation. The README documents both modes, while the sampled excerpts do not show all setup, asset-loading, or result-screen wiring.
Main entry points: main.py Game loop · Text.py Text buttons · Hangman.py Hangman display · User.py Player guessing
Components 10
Game flow
- Game loop
main.py
Guessing logic
- Player guessing
User.py - AI guessing
Question.py
Presentation and assets
- Text buttons
Text.py - Hangman display
Hangman.py - Word list
Assets/Word Dictionary/words.txt - Hangman images
Assets/Images/Hangman - Sound effects
Assets/Music
Other components
- Player
- Pygame
Connections 13
- Player → Game loop: provides input
- Game loop → Player guessing: calls guessing
- Game loop → AI guessing: calls guessing
- Game loop → Text buttons: renders controls
- Game loop → Hangman display: renders stages
- Game loop → Player guessing: reads game state
- Game loop → AI guessing: reads game state
- Text buttons → Pygame: uses UI
- Game loop → Pygame: handles events
- Hangman display → Pygame: draws image
- Text buttons → Sound effects: plays hover sound
- Game loop → Hangman images: asset setup
- Game loop → Word list: word setup