- 新增 jiyi.py 文件,实现字母翻牌记忆游戏功能 - 添加 youxijiemian.py 文件,创建游戏开始界面 - 使用 turtle 和 tkinter 模块分别实现游戏和界面 - 支持选择不同难度的游戏模式
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
# start_menu.py
|
||
import tkinter as tk
|
||
import jiyi # 你的游戏模块(包含 start_game)
|
||
|
||
def show_start_window():
|
||
def start_game(rows, cols):
|
||
print(f"游戏启动:{rows}行 x {cols}列")
|
||
root.destroy()
|
||
jiyi.start_game(rows, cols)
|
||
|
||
root = tk.Tk()
|
||
root.title("字母翻牌游戏 - 开始界面")
|
||
root.geometry("600x500")
|
||
|
||
tk.Label(root, text="请选择游戏难度", font=("Arial", 18)).pack(pady=20)
|
||
|
||
difficulty = tk.StringVar(value="8x8")
|
||
for option in ["6x6", "8x8", "10x10"]:
|
||
tk.Radiobutton(root, text=option, variable=difficulty, value=option,
|
||
font=("Arial", 16)).pack(anchor="w", padx=60, pady=8)
|
||
|
||
def on_start_click():
|
||
diff = difficulty.get()
|
||
rows, cols = map(int, diff.split("x"))
|
||
start_game(rows, cols)
|
||
|
||
tk.Button(root, text="开始游戏", font=("Arial", 20), bg="lightgreen",
|
||
command=on_start_click).pack(pady=30, ipadx=20, ipady=10)
|
||
|
||
root.mainloop()
|
||
|
||
# 程序入口
|
||
if __name__ == "__main__":
|
||
show_start_window()
|