1 Star 0 Fork 0

超级沈玲玲/Python2048

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
button_event.py 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
超级沈玲玲 提交于 2023-01-10 20:30 . aaa
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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/shenjiajialinyayi/python2048.git
git@gitee.com:shenjiajialinyayi/python2048.git
shenjiajialinyayi
python2048
Python2048
master

搜索帮助