From cb4a51ed96dcb5d9fb08e1cdd568580e6ed46f70 Mon Sep 17 00:00:00 2001 From: master <3574579877@qq.com> Date: Sun, 2 Jun 2024 13:48:05 +0800 Subject: [PATCH] Levels.py --- __pycache__/main.cpython-311.pyc | Bin 11582 -> 11585 bytes login.py | 23 ++++------------------- main.py | 3 --- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/__pycache__/main.cpython-311.pyc b/__pycache__/main.cpython-311.pyc index d48058ca186ba003c74b6ecef7e9284290f5d57a..31fd494fbbda06197f7a6835a6b844a36bca3181 100644 GIT binary patch delta 215 zcmdlNbufx|IWI340}%9m4ogef$oq$d=>hlTxvF-XJz3)!S(nvv*Kki}log*`AS1x9 zR>BBU3ISQdlNYLsu`n`}Xm0+`_MM4!MGfNu`N@rJBAfZSZnH5uOnxo!h>xYPG_&Lu zb8%(yEtb@Z&9?<-GAe7OSj9LN7iXsD<)-G9#1vGPWaQ`RCTC=(YwJ(ZyIWI340}yl>Tcovb@6N0L5)5wJ`FyT^AwdfPZhbq#VrSPMv**-P}p1`|Bj1MZgafW GBPIYl!9j!o diff --git a/login.py b/login.py index 2cad680..60a96bd 100644 --- a/login.py +++ b/login.py @@ -1,28 +1,23 @@ -import tkinter as tk #标准GUI库 +import tkinter as tk #标准GUI库 from tkinter import messagebox #显示消息框 -from PIL import ImageTk #显示图像 +from PIL import ImageTk #显示图像 -# 存储注册成功用户名及密码 +# 存注册用户名及密码 success = [] - -# 主窗口 window = tk.Tk() window.title("Please Log In") window.geometry("900x660") -# 背景画布 canvas = tk.Canvas(window,width=900,height=500) image_file = ImageTk.PhotoImage(file="resources/title2.jpg") image = canvas.create_image(0,0,anchor="nw",image=image_file) canvas.pack() -# 用户名,用户密码文本 name_lable = tk.Label(window,text="UserName:",font=(15)) password_lable = tk.Label(window,text="Password:",font=(15)) name_lable.place(x=300,y=510) password_lable.place(x=300,y=550) -# 用户名,用户密码输入框 nameval = tk.StringVar() passwordval = tk.StringVar() name_entry = tk.Entry(window,textvariable=nameval,font=(12)) @@ -30,7 +25,6 @@ password_entry = tk.Entry(window,textvariable=passwordval,show="*",font=(12)) name_entry.place(x=400,y=515) password_entry.place(x=400,y=555) -# 登录按钮触发函数 def sign_in_f(): user_si_name = name_entry.get() user_si_pass = password_entry.get() @@ -46,7 +40,7 @@ def sign_in_f(): sign_up_f() else: pass - + def start_game(): # 导入游戏主界面 import main @@ -55,9 +49,7 @@ def start_game(): # 显示游戏主界面 main.login() -# 注册按钮触发函数 def sign_up_f(): - # 用户注册界面 singn_up_w = tk.Tk() singn_up_w.title("用户注册") singn_up_w.geometry("600x400") @@ -69,8 +61,6 @@ def sign_up_f(): su_name_lable.place(x=95,y=50) su_pass_lable.place(x=95,y=150) su_cpass_lable.place(x=95,y=250) - - # 用户注册 用户名,密码,确认密码输入框 su_name_val = tk.StringVar() su_pass_val = tk.StringVar() su_cpass_val = tk.StringVar() @@ -81,7 +71,6 @@ def sign_up_f(): su_pass_entry.place(x=270,y=150) su_cpass_entry.place(x=270,y=250) - # 用户在注册页面点击注册按钮触发的函数 def su_conf_b(): su_username = su_name_entry.get() su_userpass = su_pass_entry.get() @@ -94,7 +83,6 @@ def sign_up_f(): else: tk.messagebox.showinfo(title="注册提示",message="两次输入的密码不同,请重新输入") - # 用户在注册页面点击取消按钮触发的函数 def su_cancel_b(): result = tk.messagebox.askquestion(title="放弃注册",message="你真的要放弃注册吗?") if result == "yes": @@ -102,17 +90,14 @@ def sign_up_f(): else: pass - # 用户注册 注册,取消按钮 su_confirm_button = tk.Button(singn_up_w,text="Confirm",command=su_conf_b) su_cancle_button = tk.Button(singn_up_w,text="Cancel",command=su_cancel_b) su_confirm_button.place(x=170,y=330) su_cancle_button.place(x=370,y=330) -# 登录,注册按钮 sign_in_button = tk.Button(window,text="吃豆启动!",command=sign_in_f) sign_up_button = tk.Button(window,text="注册",command=sign_up_f) sign_in_button.place(x=350,y=600) sign_up_button.place(x=470,y=600) - window.mainloop() diff --git a/main.py b/main.py index ff14fb2..b688ee8 100644 --- a/main.py +++ b/main.py @@ -24,7 +24,6 @@ ClydePATH = os.path.join(os.getcwd(), 'resources/images/Clyde.png') InkyPATH = os.path.join(os.getcwd(), 'resources/images/Inky.png') PinkyPATH = os.path.join(os.getcwd(), 'resources/images/Pinky.png') -'''开始某一关游戏''' def startLevelGame(level, screen, font): clock = pygame.time.Clock() SCORE = 0 @@ -113,7 +112,6 @@ def startLevelGame(level, screen, font): clock.tick(10) return is_clearance -'''显示文字''' def showText(screen, font, is_clearance, flag=False): clock = pygame.time.Clock() msg = 'Game Over!' if not is_clearance else 'Congratulations, you won!' @@ -147,7 +145,6 @@ def showText(screen, font, is_clearance, flag=False): pygame.display.flip() clock.tick(10) -'''初始化''' def initialize(): pygame.init() icon_image = pygame.image.load(ICONPATH)