A React-based word-guessing game where players attempt to uncover hidden words by guessing letters.
Hangman is an engaging word-guessing game that tests players' vocabulary and deduction skills. Players select a category and attempt to guess a randomly chosen word by inputting letters. Incorrect guesses reduce health, and the game ends either when the word is correctly guessed or the player runs out of health.
- Multiple categories to choose from: Movies, TV Shows, Countries, and Capital Cities
- Random word generation based on the selected category
- Visual feedback on correct and incorrect guesses
- Health tracking with a maximum of 10 incorrect guesses
- Pause menu with options to continue, pick a new category, or quit
- Fully responsive design using Tailwind CSS
- Keyboard navigation for accessibility
- React
- Vite
- Tailwind CSS
- JavaScript (ES6+)
-
src/components/HowToPlayButton.jsx: Button component that shows instructions on how to play.Intro.jsx: Handles the game's introduction screen.Paused.jsx: Pause menu with options to continue, restart, or quit the game.PlayButton.jsx: Start game button component.ReturnButton.jsx: Button for returning to the main menu.YouLose.jsx: Screen displayed when the player loses.YouWin.jsx: Screen displayed when the player wins.
-
src/data/letters.js: Contains the alphabet data used for the guessing logic.
-
src/pages/Categories.jsx: Renders the category selection screen.GamePage.jsx: Core gameplay logic and rendering.Homepage.jsx: Main homepage of the game.HowToPlayPage.jsx: Displays instructions on how to play the game.
-
App.jsx: Main application logic and routing setup. -
index.css: Global styling.
To run this project locally:
- Clone the repository
- Install dependencies with
npm install - Start the development server with
npm run dev
- Generates a random word from the selected category
- Tracks guessed letters and updates the word display accordingly
- Reduces health for each incorrect guess, with a maximum of 10 wrong guesses
- Displays a "Game Over" screen when health reaches zero or the word is guessed
- React
useStateis used for:- Tracking guessed letters
- Current word and category
- Player's remaining health
- Game state (ongoing, paused, or over)
- Supports keyboard input for all interactions
- Focus and hover effects for interactive elements
- Responsive layout optimized for both mobile and desktop screens
- Select a category to start the game.
- Guess letters by typing on your keyboard.
- Correct guesses reveal the letters in the word.
- Incorrect guesses reduce health by one.
- Win the game by guessing the word before health reaches zero.
- Lose the game if all health is lost before guessing the word.
- Add more categories and word collections.
- Include multiplayer mode with a timer for competitive play.
- Add animations for incorrect guesses and word reveals.
- Improve visual accessibility with customizable themes.
This project was inspired by the classic Hangman game and built to practice React, Tailwind CSS, and game logic design.
