from tkinter import *
from tkinter import font
from random import *
window=Tk()
window.title("아이디 패스워드로 로그인하여 간단한 게임")
window.geometry("200x160")
window.resizable(False, False)
font1 = font.Font(family="문체부 쓰기 정체", size=15)
font2 = font.Font(family="Bahnschrift SemiLight SemiConde", size=10)
font3 = font.Font(family="휴먼모음T",size=20)
font4 = font.Font(family="휴먼모음T",size=15)
font5 = font.Font(family="문체부 쓰기 정체", size=10)
#======================================================================
id_list={"naruto":123456, "sauske":1234567, "sakura":12345678}
class profile:
def __init__(self, picture, name, age, sex):
self.name=name
self.age=age
self.picture=PhotoImage(file=picture)
self.sex=sex
naruto=profile('naruto.gif','나루토',15,'男')
sauske=profile('sauske.gif','사스케',15,'男')
sakura=profile('sakura.gif','사쿠라',14,'女')
class Gnk:
def __init__(self,title,geometry,font1_size,font2_size,font3_size):
self.title=title
self.geometry=window.geometry(geometry)
font1 = font.Font(family="문체부 쓰기 정체", size=font1_size)
font2 = font.Font(family="Bahnschrift SemiLight SemiConde", size=font2_size)
font3 = font.Font(family="휴먼모음T",size=font3_size)
#========================================================================
def login():
if empty1.get() in id_list and int(empty2.get())==id_list[empty1.get()] :
title_label.place_forget()
id_label.place_forget()
ps_label.place_forget()
empty1.place_forget()
empty2.place_forget()
login_button.place_forget()
cancel_button.place_forget()
return minigame_choice()
else:
print("아이디 혹은 번호를 다시 확인해주십시오")
def minigame_choice():
global title2_label
global image_label
global profile_label
global r1
global r2
global r3
window.geometry("400x400")
font1 = font.Font(family="문체부 쓰기 정체", size=15)
font2 = font.Font(family="Bahnschrift SemiLight SemiConde", size=10)
font3 = font.Font(family="휴먼모음T",size=20)
font4 = font.Font(family="휴먼모음T",size=15)
if str(empty1.get())=="naruto":
title2_label=Label(window,text="미니게임 선택",font=font1)
title2_label.place(x=130,y=20)
image_label=Label(window, text="이미지",image=naruto.picture)
image_label.place(x=15,y=60)
profile_label=Label(window, text=naruto.name+" "+str(naruto.age)+"세", font=font1)
profile_label.place(x=90, y=60)
elif str(empty1.get())=="sakura":
title2_label=Label(window,text="미니게임 선택",font=font1)
title2_label.place(x=130,y=20)
image_label=Label(window, text="이미지",image=sakura.picture)
image_label.place(x=15,y=60)
profile_label=Label(window, text=sakura.name+" "+str(sakura.age)+"세", font=font1)
profile_label.place(x=90, y=60)
elif str(empty1.get())=="sauske":
title2_label=Label(window,text="미니게임 선택",font=font1)
title2_label.place(x=130,y=20)
image_label=Label(window, text="이미지",image=sauske.picture)
image_label.place(x=15,y=60)
profile_label=Label(window, text=sauske.name+" "+str(sauske.age)+"세", font=font1)
profile_label.place(x=90, y=60)
global select
select = IntVar()
r1=Radiobutton(window, text="승부차기", variable=select, value=1, font=font4)
r1.place(x=15,y=200)
r2=Radiobutton(window, text="미니게임2", variable=select, value=2, font=font4)
r2.place(x=145,y=200)
r3=Radiobutton(window, text="미니게임3", variable=select, value=3, font=font4)
r3.place(x=275,y=200)
Button(window, text="NEXT", font=font3, command = NEXT).place(x=300, y=330)
def NEXT():
if select.get()==1:
title2_label.place_forget()
image_label.place_forget()
profile_label.place_forget()
r1.place_forget()
r2.place_forget()
r3.place_forget()
return minigame1_1()
elif select.get()==2:
title2_label.place_forget()
image_label.place_forget()
profile_label.place_forget()
r1.place_forget()
r2.place_forget()
r3.place_forget()
return minigame2_1()
elif select.get()==3:
title2_label.place_forget()
image_label.place_forget()
profile_label.place_forget()
r1.place_forget()
r2.place_forget()
r3.place_forget()
return minigame3_1()
def minigame1_1():
global game_image1
global game_image2
global game_image3
global shooting_image1
global shooting_image2
global shooting_image3
global shooting_image4
global font1
global font2
global font3
global font4
global font5
window.geometry("1000x800+100+100")
font1 = font.Font(family="문체부 쓰기 정체", size=20)
font2 = font.Font(family="Bahnschrift SemiLight SemiConde", size=20)
font3 = font.Font(family="휴먼모음T",size=20)
font4 = font.Font(family="휴먼모음T",size=15)
font5 = font.Font(family="문체부 쓰기 정체", size=10)
title_label=Label(window,text="미니게임1 프리뷰",font=font1)
title_label.place(x=400,y=20)
game_image1=PhotoImage(file="shooting1.gif")
game_image2=PhotoImage(file="shooting2.gif")
game_image3=PhotoImage(file="shooting3.gif")
shooting_image1=PhotoImage(file="shooting_result1.gif")
shooting_image2=PhotoImage(file="shooting_result2.gif")
shooting_image3=PhotoImage(file="shooting_result3.gif")
shooting_image4=PhotoImage(file="shooting_result4.gif")
game_image1_label=Label(window, text="이미지",image=game_image1)
game_image1_label.place(x=150,y=80)
Label(window,text="1. 승부차기 게임입니다.",font=font1).place(x=150,y=700)
Button(window,text='NEXT',font=font2, command=minigame1_2).place(x=800,y=700)
def minigame1_2():
game_image2_label=Label(window, text="이미지",image=game_image2)
game_image2_label.place(x=150,y=80)
Label(window,text="2. 1이나 2를 입력하면 원하는 방향으로 슈팅합니다",font=font1).place(x=150,y=700)
Button(window,text='NEXT',font=font2, command=minigame1_3).place(x=800,y=700)
def minigame1_3():
game_image3_label=Label(window, text="이미지",image=game_image3)
game_image3_label.place(x=150,y=80)
Label(window,text="3. 총 5번을 슈팅하여 넣은 횟수가 많으면 승리입니다.",font=font1).place(x=150,y=700)
Button(window,text='NEXT',font=font2, command=minigame1_4).place(x=800,y=700)
def minigame1_4():
global empty3
global shootingcount
global wincount
global losecount
shootingcount=0
wincount=0
losecount=0
Label(window, text="두근두근 승부차기", font=font1).place(x=400,y=20)
game_image4_label=Label(window, text="이미지",image=game_image2)
game_image4_label.place(x=150,y=80)
Label(window,text="4. 1번이나 2번을 입력하세요 :",font=font1).place(x=150,y=700)
Button(window,text='NEXT',font=font2, command=shooting_game).place(x=800,y=700)
empty3 = Entry(window,width=23,font=font1)
empty3.place(x=514,y=700)
def shooting_game():
global shootingcount
global wincount
global losecount
shootingcount+=1
a=randint(1,2)
if int(empty3.get())==a:
if a==1:
game_image5_label=Label(window, text="이미지",image=shooting_image2)
game_image5_label.place(x=150,y=80)
print("막혔습니다")
losecount+=1
if shootingcount==5:
return shooting_result()
elif a==2:
game_image6_label=Label(window, text="이미지",image=shooting_image4)
game_image6_label.place(x=150,y=80)
print("막혔습니다.")
losecount+=1
if shootingcount==5:
return shooting_result()
else:
if int(empty3.get())==1:
game_image5_label=Label(window, text="이미지",image=shooting_image1)
game_image5_label.place(x=150,y=80)
print("골입니다")
wincount+=1
if shootingcount==5:
return shooting_result()
elif int(empty3.get())==2:
game_image5_label=Label(window, text="이미지",image=shooting_image1)
game_image5_label.place(x=150,y=80)
print("골입니다")
wincount+=1
print(shootingcount)
if shootingcount==5:
return shooting_result()
def shooting_result():
global shootingcount
global wincount
global losecount
if wincount<losecount:
print("패배입니다.")
else:
print("승리입니다.")
def minigame2():
print(2)
def minigame3():
print(3)
#=====================================================================
# 초기 실행부
title_label=Label(window,text="두근두근 미니게임",font=font1)
title_label.place(x=15,y=20)
for i in range (3):
Label(window, text="").grid(row=i+1)
id_label=Label(window, text="ID",font=font2)
id_label.place(x=30,y=60)
ps_label=Label(window, text="PASSWORD",font=font2)
ps_label.place(x=10,y=80)
empty1 = Entry(window,width=15)
empty1.place(x=80, y=60)
empty2 = Entry(window,width=15)
empty2.place(x=80, y=80)
login_button=Button(window, text='LOGIN', command=login, font=font2)
login_button.place(x=97, y=115)
cancel_button=Button(window, text='CANCEL', command=quit, font=font2)
cancel_button.place(x=140, y=115)
#=======================================================================
window.mainloop()
어케 짧게 만들까요 ㅠㅠ
뭐 이걸 다 읽으라고? 양심이 시발 있니없니
왜그래요 ㅠㅠ
1234 이지랄 하지말라고 배열쓰는거임
배열이 for i 이런건가요?
그리고 지금단계는 그냥 넘어가고 나중에 리팩토링 배우고 고치든가
용어숙지도 안됬으면 그냥 기본기나 다지는게 좋겠지?
파이썬은 리스트구나
ㄴ네네 ㅠㅠ
나루토 이친구 또왔네. 보나마나 과제같은데 더 잘해도 점수 안나온다. 지금은 되는대로 제출해라.. 클래스 쓰는법 공부해 - dc App
알게씁니다 ㅠㅠ
완벽해서 고칠게 없네요 훌륭합니다!
이게 스크립트냐
중복 코드가 너무 많아
클래스 딕셔너리 리스트 튜플 많이 쓰셈
파일 분리좀 하면 안돼나