main
master 1 year ago
parent 0b93b88cf7
commit cb4a51ed96

Binary file not shown.

@ -1,28 +1,23 @@
import tkinter as tk #标准GUI库 import tkinter as tk #标准GUI库
from tkinter import messagebox #显示消息框 from tkinter import messagebox #显示消息框
from PIL import ImageTk #显示图像 from PIL import ImageTk #显示图像
# 存注册成功用户名及密码 # 存注册用户名及密码
success = [] success = []
# 主窗口
window = tk.Tk() window = tk.Tk()
window.title("Please Log In") window.title("Please Log In")
window.geometry("900x660") window.geometry("900x660")
# 背景画布
canvas = tk.Canvas(window,width=900,height=500) canvas = tk.Canvas(window,width=900,height=500)
image_file = ImageTk.PhotoImage(file="resources/title2.jpg") image_file = ImageTk.PhotoImage(file="resources/title2.jpg")
image = canvas.create_image(0,0,anchor="nw",image=image_file) image = canvas.create_image(0,0,anchor="nw",image=image_file)
canvas.pack() canvas.pack()
# 用户名,用户密码文本
name_lable = tk.Label(window,text="UserName:",font=(15)) name_lable = tk.Label(window,text="UserName:",font=(15))
password_lable = tk.Label(window,text="Password:",font=(15)) password_lable = tk.Label(window,text="Password:",font=(15))
name_lable.place(x=300,y=510) name_lable.place(x=300,y=510)
password_lable.place(x=300,y=550) password_lable.place(x=300,y=550)
# 用户名,用户密码输入框
nameval = tk.StringVar() nameval = tk.StringVar()
passwordval = tk.StringVar() passwordval = tk.StringVar()
name_entry = tk.Entry(window,textvariable=nameval,font=(12)) 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) name_entry.place(x=400,y=515)
password_entry.place(x=400,y=555) password_entry.place(x=400,y=555)
# 登录按钮触发函数
def sign_in_f(): def sign_in_f():
user_si_name = name_entry.get() user_si_name = name_entry.get()
user_si_pass = password_entry.get() user_si_pass = password_entry.get()
@ -46,7 +40,7 @@ def sign_in_f():
sign_up_f() sign_up_f()
else: else:
pass pass
def start_game(): def start_game():
# 导入游戏主界面 # 导入游戏主界面
import main import main
@ -55,9 +49,7 @@ def start_game():
# 显示游戏主界面 # 显示游戏主界面
main.login() main.login()
# 注册按钮触发函数
def sign_up_f(): def sign_up_f():
# 用户注册界面
singn_up_w = tk.Tk() singn_up_w = tk.Tk()
singn_up_w.title("用户注册") singn_up_w.title("用户注册")
singn_up_w.geometry("600x400") singn_up_w.geometry("600x400")
@ -69,8 +61,6 @@ def sign_up_f():
su_name_lable.place(x=95,y=50) su_name_lable.place(x=95,y=50)
su_pass_lable.place(x=95,y=150) su_pass_lable.place(x=95,y=150)
su_cpass_lable.place(x=95,y=250) su_cpass_lable.place(x=95,y=250)
# 用户注册 用户名,密码,确认密码输入框
su_name_val = tk.StringVar() su_name_val = tk.StringVar()
su_pass_val = tk.StringVar() su_pass_val = tk.StringVar()
su_cpass_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_pass_entry.place(x=270,y=150)
su_cpass_entry.place(x=270,y=250) su_cpass_entry.place(x=270,y=250)
# 用户在注册页面点击注册按钮触发的函数
def su_conf_b(): def su_conf_b():
su_username = su_name_entry.get() su_username = su_name_entry.get()
su_userpass = su_pass_entry.get() su_userpass = su_pass_entry.get()
@ -94,7 +83,6 @@ def sign_up_f():
else: else:
tk.messagebox.showinfo(title="注册提示",message="两次输入的密码不同,请重新输入") tk.messagebox.showinfo(title="注册提示",message="两次输入的密码不同,请重新输入")
# 用户在注册页面点击取消按钮触发的函数
def su_cancel_b(): def su_cancel_b():
result = tk.messagebox.askquestion(title="放弃注册",message="你真的要放弃注册吗?") result = tk.messagebox.askquestion(title="放弃注册",message="你真的要放弃注册吗?")
if result == "yes": if result == "yes":
@ -102,17 +90,14 @@ def sign_up_f():
else: else:
pass pass
# 用户注册 注册,取消按钮
su_confirm_button = tk.Button(singn_up_w,text="Confirm",command=su_conf_b) 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_cancle_button = tk.Button(singn_up_w,text="Cancel",command=su_cancel_b)
su_confirm_button.place(x=170,y=330) su_confirm_button.place(x=170,y=330)
su_cancle_button.place(x=370,y=330) su_cancle_button.place(x=370,y=330)
# 登录,注册按钮
sign_in_button = tk.Button(window,text="吃豆启动!",command=sign_in_f) sign_in_button = tk.Button(window,text="吃豆启动!",command=sign_in_f)
sign_up_button = tk.Button(window,text="注册",command=sign_up_f) sign_up_button = tk.Button(window,text="注册",command=sign_up_f)
sign_in_button.place(x=350,y=600) sign_in_button.place(x=350,y=600)
sign_up_button.place(x=470,y=600) sign_up_button.place(x=470,y=600)
window.mainloop() window.mainloop()

@ -24,7 +24,6 @@ ClydePATH = os.path.join(os.getcwd(), 'resources/images/Clyde.png')
InkyPATH = os.path.join(os.getcwd(), 'resources/images/Inky.png') InkyPATH = os.path.join(os.getcwd(), 'resources/images/Inky.png')
PinkyPATH = os.path.join(os.getcwd(), 'resources/images/Pinky.png') PinkyPATH = os.path.join(os.getcwd(), 'resources/images/Pinky.png')
'''开始某一关游戏'''
def startLevelGame(level, screen, font): def startLevelGame(level, screen, font):
clock = pygame.time.Clock() clock = pygame.time.Clock()
SCORE = 0 SCORE = 0
@ -113,7 +112,6 @@ def startLevelGame(level, screen, font):
clock.tick(10) clock.tick(10)
return is_clearance return is_clearance
'''显示文字'''
def showText(screen, font, is_clearance, flag=False): def showText(screen, font, is_clearance, flag=False):
clock = pygame.time.Clock() clock = pygame.time.Clock()
msg = 'Game Over!' if not is_clearance else 'Congratulations, you won!' 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() pygame.display.flip()
clock.tick(10) clock.tick(10)
'''初始化'''
def initialize(): def initialize():
pygame.init() pygame.init()
icon_image = pygame.image.load(ICONPATH) icon_image = pygame.image.load(ICONPATH)

Loading…
Cancel
Save