From 5d18321602a9422704a76c74e74129fdffb25ed3 Mon Sep 17 00:00:00 2001 From: Souvik Kumar Pramanik <123581988+souvikpramanikgit@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:25:37 +0530 Subject: [PATCH 1/3] Create main.py --- .../Word Games with lives/main.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Game_Development/Word Games with lives/main.py diff --git a/Game_Development/Word Games with lives/main.py b/Game_Development/Word Games with lives/main.py new file mode 100644 index 0000000000..ea8165106f --- /dev/null +++ b/Game_Development/Word Games with lives/main.py @@ -0,0 +1,37 @@ +import random +lives = 3 + +words = ['pizza', 'fairy', 'teeth', 'shirt', 'otter', 'plane'] +secret_word = random.choice(words) + +clue = list('?????') +heart_symbol = u'\u2764' + +guessed_word_correctly = False + +def update_clue(guessed_letter, secret_word, clue): + index = 0 + while index < len(secret_word): + if guessed_letter == secret_word[index]: + clue[index] = guessed_letter + index = index + 1 + +while lives > 0: + print(clue) + print('Lives left: ' + heart_symbol * lives) + guess = input('Guess a letter or the whole word: ') + + if guess == secret_word: + guessed_word_correctly = True + break + + if guess in secret_word: + update_clue(guess, secret_word, clue) + else: + print('Incorrect. You lose a life') + lives = lives - 1 + +if guessed_word_correctly: + print('You won! The secret word was ' + secret_word) +else: + print('You lost! The secret word was ' + secret_word) From 7dfa11917089d354f52bace1d5c29fb36d8ec0db Mon Sep 17 00:00:00 2001 From: Souvik Kumar Pramanik <123581988+souvikpramanikgit@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:26:14 +0530 Subject: [PATCH 2/3] Create Readme.md --- .../Word Games with lives/Readme.md | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Game_Development/Word Games with lives/Readme.md diff --git a/Game_Development/Word Games with lives/Readme.md b/Game_Development/Word Games with lives/Readme.md new file mode 100644 index 0000000000..c0ca7bc842 --- /dev/null +++ b/Game_Development/Word Games with lives/Readme.md @@ -0,0 +1,49 @@ +# Word Games with Lives 🎮 + +## 🎯 Objective + +This **Word Game** is a fun and challenging word guessing game created using Python. In this game, you try to guess a secret word one letter at a time or by guessing the whole word. You have a limited number of lives, represented by hearts, and each incorrect guess costs you a life. The goal is to guess the word before you run out of lives! + +--- + +**Prerequisite**: Install `Python` + + +Before running the code, make sure you have Python installed on your system. + + +## 🚀 How to Play: + +1. The game selects a random secret word from a predefined list. +2. You will be given a clue, with each letter of the word represented by a `?`. +3. You can either: + - **Guess one letter** at a time. + - **Guess the whole word**. +4. Each correct guess reveals the corresponding letter(s) in the secret word. +5. Each incorrect guess results in losing one of your lives (represented by ♥). +6. The game ends when you either: + - **Guess the word correctly** and win. + - **Run out of lives** and lose. +7. Enjoy the challenge! + +--- + + +## 📝 Features: + +- **Lives System**: You start with 3 lives, and each incorrect guess removes one life. +- **Clue System**: Clue is displayed as `?` to show how many letters the word contains. +- **Simple Controls**: Just input your guesses either as a letter or the whole word. +- **Random Word Selection**: Each time you play, the game selects a random word to guess. + + +--- + +## 💻 Running the Game: + +1. **Download or clone** the game code to your local machine. +2. **Run the game** using the command: + ```bash + python main.py + ``` +3.Start guessing letters or the whole word and try to win before you lose all your lives! From 2d215d28ce32c466d9c8bd589fd9bea9e8162436 Mon Sep 17 00:00:00 2001 From: souvikpramanikgit Date: Mon, 28 Oct 2024 06:56:56 +0000 Subject: [PATCH 3/3] updating Project-Structure.md --- Project-Structure.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Project-Structure.md b/Project-Structure.md index c3bfdc3883..a7f2758688 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -527,6 +527,8 @@ * [Turtle Collection Game](Game_Development/Turtle%20Collection%20Game/Turtle%20Collection%20Game.py) * Visual Novel Code * [Novel](Game_Development/Visual_novel%20_code/Novel.py) + * Word Games With Lives + * [Main](Game_Development/Word%20Games%20with%20lives/main.py) * Word Ladder Puzzle Game * [Main](Game_Development/Word%20Ladder%20Puzzle%20Game/main.py)