A classic hangman game built with Elixir and Phoenix LiveView. This project demonstrates functional programming concepts and real-time web interactions without writing JavaScript.
- Interactive gameplay with real-time updates
- Multiple difficulty levels (Easy, Medium, Hard)
- Virtual keyboard for easy letter selection
- Sound effects for correct/incorrect guesses
- Animations for game interactions
- Responsive design for desktop and mobile
- Mute/unmute toggle for sound effects
- Extensive word list with over 200 words
- Elixir - Functional programming language
- Phoenix Framework - Web framework for Elixir
- Phoenix LiveView - Real-time server-rendered HTML
- Tailwind CSS - Utility-first CSS framework
- Select a difficulty level:
- Easy: 3-5 letter words
- Medium: 6-8 letter words
- Hard: 9+ letter words
- The game selects a random word based on the chosen difficulty
- Players guess one letter at a time
- Correct guesses reveal the letter in the word
- Incorrect guesses add to the hangman drawing
- Players win by guessing all letters before the hangman is complete
- Players lose if the hangman drawing is completed (6 incorrect guesses)
- Elixir 1.14 or later
- Phoenix 1.7.x
- Node.js & npm
- Clone the repository
git clone https://github.com/yourusername/elixir-hangman.git
cd elixir-hangman- Install dependencies
mix deps.get
cd assets && npm install && cd ..- Start the Phoenix server
mix phx.server- Visit
localhost:4000in your browser
lib/hangman/game.ex- Core game logic modulelib/hangman/games.ex- Game context modulelib/hangman/word_list.ex- Word management with difficulty levelslib/hangman_web/live/game/show.ex- LiveView controllerlib/hangman_web/live/game/show.html.heex- LiveView templateassets/js/hangman_hooks.js- JavaScript hooks for sound effectsassets/css/app.css- Custom CSS and animations
This project demonstrates several important aspects of Elixir and Phoenix:
- Functional programming with immutable data structures
- Pattern matching and recursion
- LiveView for interactive UIs without JavaScript
- Event handling and state management
- Animation and sound integration
- Dynamic difficulty levels
Run the test suite with:
mix testThe project includes tests for:
- Game logic
Some ideas for further development:
- Timer mode
- Two-player mode
- Word categories (Animals, Food, Technology, etc.)
- Leaderboard
- Hint system
- Custom word lists
This project is licensed under the MIT License - see the LICENSE file for details.
- Phoenix Framework team for the excellent LiveView library
- Tailwind CSS for the styling utilities
Feel free to contribute to this project by submitting pull requests or reporting issues. Happy coding!
