Building Snake Water Gun Game from scratch in Python - Free Source Code
💓✋✋✋✋✋ 💓
Hello, my dear ones!
You can copy-paste the following code into your IDE and start playing the Snake Water Gun game instantly.
Snake Water Gun Game Source Code
import re
def swg_game(computer, You):
if computer == You:
return None
elif computer == "s":
if You == "g":
return True
if You == "w":
return False
elif computer == "w":
if You == "s":
return True
if You == "g":
return False
elif computer == "g":
if You == "w":
return True
if You == "s":
return False
import random
from tkinter.messagebox import NO
rNum = random.randint(1, 3)
if rNum == 1:
computer = "s"
elif rNum == 2:
computer = "w"
elif rNum == 3:
computer = "g"
print("Computer: Choose Snake(s), or Water(w), or Gun(g)? ")
You = input("You: Choose Snake(s), or Water(w), or Gun(g)? ")
if not re.match("^[w, s, g]*$", You):
print("Wrong input! Choose b/w (s) or (w) or (g) only.")
print("The computer chose the option", computer)
print("You chose the option", You)
gameFunc = swg_game(computer, You)
if gameFunc == None:
print("None Wins! The game is a DRAW.")
elif gameFunc:
print("Congrats! You WON the Game.")
else:
print("You LOST the Game!")
This is how the game looks when played in an IDE.
Snake Water Gun Game in Play Mode
Enjoy! 💓👍
Comments
Post a Comment
Write something to CodeWithAbdur!