A classic Hangman word game built with React, Vite, Tailwind CSS, and canvas-confetti. This game is responsive and features a custom loading screen for a fun user experience. It showcases the use of Context API, React hooks (useCallback, useMemo), and TypeScript.
Classic Hangman Gameplay: Guess the hidden word by suggesting letters.Responsive Design: The game adapts to various screen sizes.Loading Screen: A mimicked loading screen.Confetti Animation: Celebratory confetti effect using canvas-confetti.Keyboard Input: Players can guess letters using both the on-screen keyboard and their physical keyboard.
Loading Screen:- A mimicked loading screen is shown the first time a user visits the game, providing a brief, interactive experience before the game starts.
Game Initialization:- When the game starts, a random word is selected from a predefined list and displayed as underscores representing each letter.
User Interaction:- Players guess letters by clicking on the onscreen keyboard or pressing physical keys.
- Each guessed letter is checked against the hidden word. Correct guesses reveal letters in the word, while incorrect guesses increase the hangman’s "gallows."
State Management:- The game state, including the current word, guessed letters, and number of attempts remaining, is managed using React Context API for global state management.
React Hooks:- useCallback is used to memoize functions that handle user interactions, preventing unnecessary re-renders.
- useMemo is used to optimize performance.
Winning and Losing:- The game tracks the number of incorrect guesses and displays a win or loss message when appropriate.
- Confetti animation is triggered on a win using canvas-confetti.
Responsive Design:- Tailwind CSS is used to ensure the game is responsive and looks good on various devices.
ViteReact.jsTailwindCSSTypescriptcanvas-confetti
To run the project in your local environment, follow these steps:
- Clone the repository to your local machine.
- Navigate to the project directory and run
npm installoryarnto install the required dependencies. - Start the project with
npm run devoryarn dev. - Open http://localhost:5173 (or the address displayed in your console) in your web browser to view the application.
