๐๐ง๐ซ Building a Snake Water Gun Game in Python โ My First Console Game!
๐ฎ What Is Snake Water Gun?
Youโve heard of Rock Paper Scissors โ now meet its quirky cousin: Snake Water Gun! Itโs a fun little game where:
- ๐ Snake drinks water
- ๐ง Water drowns gun
- ๐ซ Gun shoots snake
Each player picks one of the three, and the winner is decided based on these rules.
๐ง How I Built It in Python
I wanted to create something simple, interactive, and beginner-friendly. Here's the core logic:
๐ฆ Step 1: Setup Choices
computer = random.choice([1, 0, -1])
youstr = input("Enter your choice : ")
youdict = {"s" : 1, "w" : -1, "g" : 0}
reversedict = {1 :"snake", 0 : "gun", -1 :"water"}
you = youdict[youstr]
- The computer randomly picks a move.
- The player enters s, w, or g.
- I use dictionaries to map choices to numbers and back.
โ๏ธ Step 2: Decide the Winner
if computer == -1 and you == 1:
print("Snake drinks water ๐๐ง")
print("You win....!")
I wrote clear if-elif
conditions for every possible matchup.
Emojis make the output more fun and readable!
๐ How to Play
Clone the repo:
bash
git clone https://github.com/bilal-dev-0x/Snake-water-gun-Game.git
Run the game:
bash
python snake_water_gun.py
Enter your move: s for snake, w for water, g for gun.
๐ก What I Learned
- How to use
random.choice()
for unpredictability. - Mapping inputs with dictionaries for clean code.
- Writing readable and fun console output.
๐ Try It Yourself!
Check out the full code on GitHub:
https://github.com/bilal-dev-0x/Snake-water-gun-Game.git
Top comments (0)