Oyunlara bastıktan sonra nasıl başka butona tıklayınca oyunlar butonu silebilirim.
from tkinter import*
import time
import turtle
import random
import tkinter as tk
adlist = [“assdddsdsddddffffdffvvfvv123212”]
root = tk.Tk()
root.geometry(“300x200”)
def yılanoyunu():
delay = 0.1
# Score
score = 0
high_score = 0
# Set up the screen
wn = turtle.Screen()
wn.title('Snake Game')
wn.bgcolor("green")
wn.setup(width=600, height=600)
wn.tracer(0) # Turns off the screen updates
# Snake head
head = turtle.Turtle()
head.speed(0)
head.shape("square")
head.color("black")
head.penup()
head.goto(0, 0)
head.direction = "stop"
# Snake food
food = turtle.Turtle()
food.speed(0)
food.shape("circle")
food.color("red")
food.penup()
food.goto(0, 100)
segments = []
# Pen
pen = turtle.Turtle()
pen.speed(0)
pen.shape("square")
pen.color("white")
pen.penup()
pen.hideturtle()
pen.goto(0, 260)
pen.write("Score: 0 High Score: 0", align="center", font=("Courier", 24, "normal"))
# Functions
def go_up():
if head.direction != "down":
head.direction = "up"
def go_down():
if head.direction != "up":
head.direction = "down"
def go_left():
if head.direction != "right":
head.direction = "left"
def go_right():
if head.direction != "left":
head.direction = "right"
def move():
if head.direction == "up":
y = head.ycor()
head.sety(y + 20)
if head.direction == "down":
y = head.ycor()
head.sety(y - 20)
if head.direction == "left":
x = head.xcor()
head.setx(x - 20)
if head.direction == "right":
x = head.xcor()
head.setx(x + 20)
# Keyboard bindings
wn.listen()
wn.onkeypress(go_up, "w")
wn.onkeypress(go_down, "s")
wn.onkeypress(go_left, "a")
wn.onkeypress(go_right, "d")
# Main game loop
while True:
wn.update()
# Check for a collision with the border
if head.xcor() > 290 or head.xcor() < -290 or head.ycor() > 290 or head.ycor() < -290:
time.sleep(1)
head.goto(0, 0)
head.direction = "stop"
# Hide the segments
for segment in segments:
segment.goto(1000, 1000)
# Clear the segments list
segments.clear()
# Reset the score
score = 0
# Reset the delay
delay = 0.1
pen.clear()
pen.write("Score: {} High Score: {}".format(score, high_score), align="center",
font=("Courier", 24, "normal"))
# Check for a collision with the food
if head.distance(food) < 20:
# Move the food to a random spot
x = random.randint(-290, 290)
y = random.randint(-290, 290)
food.goto(x, y)
# Add a segment
new_segment = turtle.Turtle()
new_segment.speed(0)
new_segment.shape("square")
new_segment.color("grey")
new_segment.penup()
segments.append(new_segment)
# Shorten the delay
delay -= 0.001
# Increase the score
score += 10
if score > high_score:
high_score = score
pen.clear()
pen.write("Score: {} High Score: {}".format(score, high_score), align="center",
font=("Courier", 24, "normal"))
# Move the end segments first in reverse order
for index in range(len(segments) - 1, 0, -1):
x = segments[index - 1].xcor()
y = segments[index - 1].ycor()
segments[index].goto(x, y)
# Move segment 0 to where the head is
if len(segments) > 0:
x = head.xcor()
y = head.ycor()
segments[0].goto(x, y)
move()
# Check for head collision with the body segments
for segment in segments:
if segment.distance(head) < 20:
time.sleep(1)
head.goto(0, 0)
head.direction = "stop"
# Hide the segments
for segment in segments:
segment.goto(1000, 1000)
# Clear the segments list
segments.clear()
# Reset the score
score = 0
# Reset the delay
delay = 0.1
# Update the score display
pen.clear()
pen.write("Score: {} High Score: {}".format(score, high_score), align="center",
font=("Courier", 24, "normal"))
time.sleep(delay)
wn.mainloop()
def Buttonbas():
def kayit():
kayitisim = isimgiris.get()
kayitsifre = sifregiris.get()
adsoyad = (kayitisim + “,” + kayitsifre)
if adsoyad in adlist[0:]:
e2.config(text = “böyle bir hesap var.”)
else:
adlist.append(adsoyad)
print(adlist)
root2.destroy()
def cikis():
root2.destroy()
root2 = tk.Tk()
root2.geometry(“250x200”)
kaydolyazi = tk.Label(root2,text=“KAYDOL!”, font=“Arial 13 bold”)
kaydolyazi.pack()
isimyazisi = tk.Label(root2,text=“Bir kullanıcı ismi giriniz:”, font=“Arial 13 bold”)
isimyazisi.pack()
isimgiris = tk.Entry(root2,width=10)
isimgiris.pack()
sifreyazisi = tk.Label(root2, text=“Bir şifre giriniz:”, font=“Arial 13 bold”)
sifreyazisi.pack()
sifregiris = tk.Entry(root2, width=10)
sifregiris.pack()
girisbuton = tk.Button(root2, text=“OTURUM AÇ!”, bg = (“lightgreen”), fg = (“white”), font=“Arial 13 bold”, command=kayit)
girisbuton.place(x = 130 , y = 168)
geributon = tk.Button(root2, text=“Çıkış”, bg=(“lightgreen”), fg=(“white”), font=“Arial 13 bold”, command=cikis)
geributon.place(x = 0 , y = 168)
e2 = tk.Label(root2,text="--------", font=“Arial 12 bold”)
e2.pack()
def Buttonbas2():
def kayit():
kayitisim = isimgiris.get()
kayitsifre = sifregiris.get()
adsoyad = (kayitisim + “,” + kayitsifre)
if adsoyad in adlist[0:]:
e2.config(text=“hesaba giriş yapıldı.”)
time.sleep(5)
root3.destroy()
root.destroy()
root4 = Tk()
root4.geometry(‘1900x768’)
arayuz()
else:
e2.config(text="böyle bir hesap yok.")
def cikis():
root3.destroy()
root3 = tk.Tk()
root3.geometry("250x200")
girisyazi = tk.Label(root3,text="GİRİŞ!", font="Arial 13 bold")
girisyazi.pack()
isimyazisi = tk.Label(root3,text="kullanıcı isminizi giriniz:", font="Arial 13 bold")
isimyazisi.pack()
isimgiris = tk.Entry(root3,width=10)
isimgiris.pack()
sifreyazisi = tk.Label(root3, text="şifrenizi giriniz:", font="Arial 13 bold")
sifreyazisi.pack()
sifregiris = tk.Entry(root3, width=10)
sifregiris.pack()
girisbuton = tk.Button(root3, text="GİRİŞ!", bg = ("lightgreen"), fg = ("white"), font="Arial 13 bold", command=kayit)
girisbuton.place(x = 190 , y = 168)
geributon = tk.Button(root3, text="Çıkış", bg=("lightgreen"), fg=("white"), font="Arial 13 bold", command=cikis)
geributon.place(x = 0 , y = 168)
e2 = tk.Label(root3,text="--------", font="Arial 12 bold")
e2.pack()
def sayıbilmece():
root6 = Tk()
root6.geometry(“300x150”)
def asd():
root5 = Tk()
root5.geometry("300x250")
for i in range(1):
sayibilmece = (random.randint(0, 100))
print(sayibilmece)
def sayigir():
global sayac
global sayac1
if sayac1 == 0:
sayac = 0
sayac1 = sayac1 + 1
x = sayigirlankopek2.get()
if sayigirlankopek2.get().isdigit():
if 100 < int(x) or 0 > int(x):
e2.config(text="girdiğiniz sayı 100 den büyük yada 0 dan küçük.", font="Arial 8 bold")
e3.config(text="--------")
elif int(sayibilmece) < int(x):
e2.config(text="girdiğiniz sayı büyük.", font="Arial 8 bold")
sayac = sayac + 1
e3.config(text=str(sayac) + ". deneme")
elif int(sayibilmece) > int(x):
e2.config(text="girdiğiniz sayı küçük.", font="Arial 8 bold")
sayac = sayac + 1
e3.config(text=str(sayac) + ". deneme")
else:
e4.config(text="Helal be buldun sayıyı.", font="Arial 8 bold")
sayac1 = sayac1 - 1
sayac = sayac + 1
e5.config(text=str(sayac) + ". deneme")
root5.destroy()
else:
e2.config(text="sayı giriniz.")
e3.config(text="--------")
sayibilmeceyazi = Label(root5, text="Sayı Bilmece!", font="Arial 25 bold")
sayibilmeceyazi.pack()
sayigirlankopek = Label(root5, text="0 ile 100 arasında sayı gir!(0 ve 100 dahil)", font="Arial 10 bold")
sayigirlankopek.pack()
sayigirlankopek2 = Entry(root5, width=20)
sayigirlankopek2.pack()
sayigirlankopekbutton = Button(root5, text="şansını DENE!", bg=("lightgreen"), fg=("white"),
font="Arial 15 bold", command=sayigir)
sayigirlankopekbutton.place(x=75, y=200)
e2 = Label(root5, text="--------", font="Arial 12 bold")
e2.pack()
e3 = Label(root5, text="--------", font="Arial 12 bold")
e3.pack()
root5.mainloop()
sayac1 = 0
e4 = Label(root6, text="--------", font="Arial 12 bold")
e4.pack()
e5 = Label(root6, text="--------", font="Arial 12 bold")
e5.pack()
baslalankopekbutton = Button(root6, text="BAŞLA!", bg=("lightgreen"), fg=("white"), font="Arial 15 bold",
command=asd)
baslalankopekbutton.place(x=105, y=50)
root6.mainloop()
def anasayfa3():
anasayfa2 = tk.Label(text =‘Hoşgeldin!’,font=‘Arial 20 bold’)
anasayfa2.place(x=800, y=50)
def hakkımızda2():
hakkımızda3 = tk.Label(text=‘Eğlenceli mini gameler oynıya bildiğiniz bir oyun platformu’,font=‘Arial 20 bold’)
hakkımızda3.place(x=800, y=50)
def oyunlar2():
oyunlar3 = tk.Label(text=‘yılan oyunu’,font=‘Arial 20 bold’)
oyunlar3.place(x=800, y=50)
yılanoyunubaslat = tk.Button(text=‘Başlatmak için basınız’,bg=(“lightgreen”), fg=(“white”),font=“Arial 20 bold”,command=yılanoyunu)
yılanoyunubaslat.place(x=800, y=80)
sayıtahminiyazi = tk.Label(text=‘Sayı tahmini oyunu’,font=“Arial 20 bold”)
sayıtahminiyazi.place(x=800, y=200)
sayitahminibuton = tk.Button(text=‘Başlatmak için basınız’,font=‘Arial 20 bold’,command=sayıbilmece)
sayitahminibuton.place(x=800,y=230)
def iletişim2():
iletişim3 = tk.Label(text=‘Yardım,destek veya bug bildirimi için ykminigame@gmail.com adresine mail atabilirsiniz’,font=‘Arial 20 bold’)
letişim3.place(x=800, y=50)
def arayuz():
anasayfa = tk.Button(text=“Ana Sayfa”, bg=(“lightgreen”), fg=(“white”),font=“Arial 20 bold”,command=anasayfa3)
anasayfa.place(x=60, y=2)
oyunlar = tk.Button(text=“Oyunlar”, bg=(“lightgreen”), fg=(“white”),font=“Arial 20 bold”,command=oyunlar2)
oyunlar.place(x=200, y=2)
hakkimizda = tk.Button(text=“Hakkımızda”, bg=(“lightgreen”), fg=(“white”),font=“Arial 20 bold”,command=hakkımızda2)
hakkimizda.place(x=300, y=2)
iletisim = tk.Button(text=“İletişim”, bg=(“lightgreen”), fg=(“white”),font=“Arial 20 bold”,command=iletişim2)
iletisim.place(x=400, y=2)
anasayfa3()
girisselamlama = tk.Label(text=“Merhaba!”,font=“Arial 20 bold”)
girisselamlama.place(x = 90, y = 10)
kaydol = tk.Button(text=“Kaydol”,bg=(“lightgreen”),fg=(“white”),font=“Arial 20 bold”, command = Buttonbas )
kaydol.place(x=90, y=50)
giris = tk.Button(text=“Giriş”,bg=(“lightgreen”),fg=(“white”),font=“Arial 20 bold”, command = Buttonbas2 )
giris.place(x=103, y=110)
root.mainloop()