Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🪢 Hangman Game

A classic single-player console game built in C++. Guess the hidden word letter by letter before you run out of attempts!

📋 Description

Hangman is a word-guessing game. The program randomly selects a word from a built-in list — your goal is to reveal it by guessing one letter at a time. You have only 6 incorrect guesses before you lose.

Already tried a wrong letter? No penalty — the game reminds you and lets you try again.

🎯 Gameplay Rules

  • The program picks a random word from the word list
  • Each turn, you guess one letter
  • Correct guess — the letter is revealed in the word
  • Wrong guess — you lose one of your 6 attempts
  • Repeating a previously failed letter — no penalty, just a reminder
  • Guess the full word before attempts run out to win

🛠️ Technologies

  • C++11
  • OOP: Game class with encapsulated state
  • <random>: std::mt19937 + std::uniform_int_distribution for fair random word selection
  • <set>: std::set for tracking already used wrong letters
  • Input validation: std::cin.fail() handling with recovery via cin.clear() / cin.ignore()

🚀 How to Run

Compilation (GCC/Clang):

g++ -std=c++11 Hangman-game.cpp -o Hangman-game
./Hangman-game

Compilation (Visual Studio):

  1. Open the project in Visual Studio
  2. Press F5 (Run)

📂 Project Structure

Hangman-game/
└── Hangman-game.cpp    # Full game logic

📋 Example Usage

Welcome to the game Hangman!
Word - _ _ _ _ _ _ _ _ _ _ _
Enter letter: S
Word - _ _ _ _ _ _ S _ _ _ _
Enter letter: F
Fail! No letter found. You have only 5 to incorrectly put letter.
Word - _ _ _ _ _ _ S _ _ _ _
Enter letter: F
This letter was already tried and not in the word, try another!
...
You won, congrats!
The true word - I N T E R E S T I N G

🔧 Future Improvements

  • Draw the actual hangman ASCII art step by step
  • Categories for words (animals, cities, tech terms)
  • Difficulty levels (easy / medium / hard word length)
  • Score tracking across multiple rounds
  • Load words from an external file

👤 Author

Oleksandr Kopii
GitHub: @SamuraiSanch


⭐ If you enjoyed this project, feel free to leave a star!

About

A simple terminal-based Hangman game written in C++ implementing random word selection, letter guessing logic, and a limited attempts system.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages