import tkinter as tk from character import Character def create_main_menu(root): def open_settings(): settings_window = tk.Toplevel(root) settings_window.title("设置") settings_window.geometry("300x200") tk.Label(settings_window, text="音量:").pack(pady=10) tk.Scale(settings_window, from_=0, to=100, orient=tk.HORIZONTAL).pack(pady=10) tk.Button(settings_window, text="控制映射", command=open_control_mapping).pack(pady=10) tk.Button(settings_window, text="图形设置").pack(pady=10) tk.Button(settings_window, text="返回主菜单", command=settings_window.destroy).pack(pady=10) def open_help(): help_window = tk.Toplevel(root) help_window.title("帮助") help_window.geometry("300x200") tk.Label(help_window, text="操作指南:\nW-前进 S-后退 A-左移 D-右移\n空格-跳跃").pack(pady=10) tk.Label(help_window, text="常见问题:\n1. 如何开始游戏?\n2. 如何保存游戏?").pack(pady=10) tk.Button(help_window, text="返回", command=help_window.destroy).pack(pady=10) def open_control_mapping(): mapping_window = tk.Toplevel(root) mapping_window.title("控制映射") mapping_window.geometry("300x300") tk.Label(mapping_window, text="键盘映射").pack(pady=5) tk.Label(mapping_window, text="前进: W").pack(pady=5) tk.Label(mapping_window, text="后退: S").pack(pady=5) tk.Label(mapping_window, text="左移: A").pack(pady=5) tk.Label(mapping_window, text="右移: D").pack(pady=5) tk.Label(mapping_window, text="跳跃: 空格").pack(pady=5) tk.Label(mapping_window, text="鼠标映射").pack(pady=5) tk.Label(mapping_window, text="射击: 左键").pack(pady=5) tk.Label(mapping_window, text="瞄准: 右键").pack(pady=5) tk.Label(mapping_window, text="游戏手柄映射").pack(pady=5) tk.Label(mapping_window, text="跳跃: A").pack(pady=5) tk.Label(mapping_window, text="射击: B").pack(pady=5) tk.Button(mapping_window, text="应用", command=mapping_window.destroy).pack(pady=10) tk.Button(mapping_window, text="返回", command=mapping_window.destroy).pack(pady=10) def start_game(): game_window = tk.Toplevel(root) game_window.title("游戏界面") game_window.geometry("800x600") # 状态栏 status_frame = tk.Frame(game_window) status_frame.pack(side=tk.TOP, fill=tk.X) tk.Label(status_frame, text="健康: 100").pack(side=tk.LEFT, padx=10) tk.Label(status_frame, text="能量: 50").pack(side=tk.LEFT, padx=10) tk.Label(status_frame, text="得分: 200").pack(side=tk.RIGHT, padx=10) tk.Label(status_frame, text="时间: 12:34").pack(side=tk.RIGHT, padx=10) # 游戏场景 game_canvas = tk.Canvas(game_window, bg="black") game_canvas.pack(expand=True, fill=tk.BOTH) # 控制提示 control_frame = tk.Frame(game_window) control_frame.pack(side=tk.BOTTOM, fill=tk.X) tk.Label(control_frame, text="提示: W-前进 S-后退 A-左移 D-右移 空格-跳跃").pack(pady=10) tk.Button(root, text="开始游戏", width=20, command=start_game).pack(pady=10) tk.Button(root, text="设置", width=20, command=open_settings).pack(pady=10) tk.Button(root, text="帮助", width=20, command=open_help).pack(pady=10) tk.Button(root, text="退出", width=20, command=root.quit).pack(pady=10)