Player vs Computer
This commit is contained in:
parent
17947f8432
commit
f24b1ad65c
9
Menü.py
9
Menü.py
@ -5,8 +5,11 @@ root.geometry("900x500")
|
||||
def vs():
|
||||
subprocess.call("GUI.py", shell=True)
|
||||
|
||||
Label(root, text="Schere, Stein, Papier", font=("times",30)).grid(column=3)
|
||||
Label(root, text="Menü", font=("times", 30)).grid(row=1, column=3)
|
||||
Button(root, text="1 VS 1", command=vs, font=("times", 30)).grid()
|
||||
def vscom():
|
||||
subprocess.call("stp.py", shell=True)
|
||||
|
||||
Label(root, text="Schere, Stein, Papier", font=("times",30)).grid(column=1)
|
||||
Label(root, text="Menü", font=("times", 30)).grid(row=1, column=1)
|
||||
Button(root, text="Player vs Player", command=vs, font=("times", 25)).grid(row=2)
|
||||
Button(root, text="Player vs Com", command=vscom, font=("times", 25)).grid(row=2, column=2)
|
||||
root.mainloop()
|
69
stp.py
69
stp.py
@ -1,22 +1,59 @@
|
||||
import getpass
|
||||
from tkinter import *
|
||||
import random
|
||||
|
||||
punkte1 = 0
|
||||
|
||||
root = Tk()
|
||||
root.geometry("900x500")
|
||||
stp = ["s", "r", "p"]
|
||||
punkte1 = 0
|
||||
punkte2 = 0
|
||||
while punkte1 or punkte2 < 3:
|
||||
|
||||
print ("S = Schere, R = Stein, P = Papier ")
|
||||
s1 = getpass.getpass( "Spieler 1 Wähle: ")
|
||||
s2 = getpass.getpass( "Spieler 2 Wähle: ")
|
||||
|
||||
if s1 == "s" and s2 == "p" or s1 == "p" and s2 == "r" or s1 == "r" and s2 == "s":
|
||||
print("Spieler 1 hat gewonnen")
|
||||
def ok():
|
||||
s1 = s1_wert.get()
|
||||
com = (random.choice(stp))
|
||||
|
||||
if s1 == com:
|
||||
Label(root, text=" Unentschieden ",font=("times",25)).grid(row=6, column=1)
|
||||
|
||||
elif s1 == "s" and com == "p" or s1 == "p" and com == "r" or s1 == "r" and com == "s":
|
||||
global punkte1
|
||||
punkte1 += 1
|
||||
print("Spieler 1 hat :", punkte1, "Punkte")
|
||||
if punkte1 == 3:
|
||||
break
|
||||
Label(root, text=" Spieler 1 Gewinnt ", font=("times",25)).grid(row=6, column=1)
|
||||
Label(root, text="Punkte: ", font=("times",25)).grid(row=8)
|
||||
Label(root, text=punkte1, font=("times",25)).grid(row=9)
|
||||
if s1 == "s" and com == "p":
|
||||
Label(root,text=" wählt Schere ", bg="green", font=("times", 25)).grid(row=6)
|
||||
Label(root,text=" wählt Papier ", bg="red", font=("times", 25)).grid(row=6, column=2)
|
||||
elif s1 == "p" and com == "r":
|
||||
Label(root,text=" wählt Papier ", bg="green", font=("times", 25)).grid(row=6)
|
||||
Label(root,text=" wählt Stein ", bg="red", font=("times", 25)).grid(row=6, column=2)
|
||||
elif s1 == "r" and com == "s":
|
||||
Label(root,text=" wählt Stein ", bg="green", font=("times", 25)).grid(row=6)
|
||||
Label(root,text=" wählt Schere ", bg="red", font=("times", 25)).grid(row=6, column=2)
|
||||
|
||||
else:
|
||||
print("Spieler 2 hat gewonnen")
|
||||
global punkte2
|
||||
punkte2 += 1
|
||||
print("Spieler 2 hat:", punkte2, "Punkte")
|
||||
if punkte2 == 3:
|
||||
break
|
||||
Label(root, text="Computer Gewinnt", font=("times", 25)).grid(row=6, column=1)
|
||||
Label(root, text="Punkte:", font=("times",25)).grid(row=8, column=2)
|
||||
Label(root, text=punkte2, font=("times",25)).grid(row=9, column=2)
|
||||
if com == "r" and s1 == "s":
|
||||
Label(root,text=" wählt Schere ", bg="red", font=("times", 25)).grid(row=6)
|
||||
Label(root,text=" wählt Stein ", bg="green", font=("times", 25)).grid(row=6, column=2)
|
||||
elif com == "s" and s1 == "p":
|
||||
Label(root,text=" wählt Papier ", bg="red", font=("times", 25)).grid(row=6)
|
||||
Label(root,text=" wählt Schere ", bg="green", font=("times", 25)).grid(row=6, column=2)
|
||||
elif com == "p" and s1 == "r":
|
||||
Label(root,text=" wählt Stein ", bg="red", font=("times", 25)).grid(row=6)
|
||||
Label(root,text=" wählt Papier ", bg="green", font=("times", 25)).grid(row=6, column=2)
|
||||
|
||||
|
||||
Label(root, text="S = Schere, R = Stein, P = Papier ", font=("times",25,)).grid(column=1)
|
||||
Label(root, text="Spieler 1", font=("times", 25)).grid(row=1)
|
||||
Label(root, text="Computer", font=("times", 25)).grid(row=1, column=2)
|
||||
|
||||
s1_wert = Entry(root,font=(28))
|
||||
s1_wert.grid(row=3)
|
||||
|
||||
Button(root, text="Wählen", command=ok, font=("times", 30)).grid(row=2, column=1)
|
||||
root.mainloop()
|
Loading…
x
Reference in New Issue
Block a user