import pygame from button import * import map_game import ai2048 import sound pygame.init() # 按键颜色设置 # buttonColorMap = [(203, 193, 182), # released (239, 229, 219), # hovor (242, 179, 122)] # clicked # 按键自定义风格设置 # #BUTTON_STYLE = {"hover_color" : buttonColorMap[1], # "clicked_color" : buttonColorMap[2], # "hover_sound" : pygame.mixer.Sound("./sound/sound.wav"), # "click_sound" : pygame.mixer.Sound("./sound/clicked.wav")} # 按键自定义风格设置 # BUTTON_STYLE = {"hover_color" : buttonColorMap[1], "clicked_color" : buttonColorMap[2], "hover_sound" : pygame.mixer.Sound("./sound/hover_sound.mp3"), "click_sound" : pygame.mixer.Sound("./sound/click_sound.mp3") } #基础游戏 def btnBase(): ai2048.game_state = 0 #0为手动 1为AI map_game.start_base_game() print("btnBase") #AI模式 def btnAI(): ai2048.ai_button_callback() print("btnAI") #撤回按键 def btnReturn(): ai2048.game_state = 0 #0为手动 1为AI #调用回调函数(位于map_game.py) map_game.return_callback() print("btnReturn") #提示模式 def btnTips(): sound.tips_sound() ai2048.tips_button_event() print("btnTips") #回顾模式 def btnReshow(): ai2048.reshow_callback() print("btnReshow") buttonBase = Button((10,90,60,40), buttonColorMap[0], btnBase, text="Start", **BUTTON_STYLE) buttonReturn = Button((85,90,60,40), buttonColorMap[0], btnReturn, text="Return", **BUTTON_STYLE) buttonAI = Button((160,90,60,40), buttonColorMap[0], btnAI, text="AI", **BUTTON_STYLE) buttonTips = Button((235,90,60,40), buttonColorMap[0], btnTips, text="Tips", **BUTTON_STYLE) buttonReshow = Button((310,90,60,40), buttonColorMap[0], btnReshow, text="Show", **BUTTON_STYLE)