Py学习  »  Python

python经典还原2048游戏

python自留地 • 2 月前 • 86 次点击  

源码说明

基于Python3+pygame制作而成,特别适合练手

2048游戏 源码:

长按左侧二维码 2 秒

回复「2048」即可获取源码

(非本号)

 



一、运行效果

二、部分示例代码



def judge_move_up(chess_nums_temp):    # 对棋盘的数字进行「行与列转置」,即原来在第2行第3列变为第3行第2列    # zip: 实现    # *chess_nums_temp对列表进行拆包    chess_nums_temp = [list(row) for row in zip(*chess_nums_temp)]    return judge_move_left(chess_nums_temp)

def judge_move_down(chess_nums_temp):        逻辑:判断能否向下移动, 也就是对于元素进行转置, 判断转置后的棋盘能否向右移动        # 1.「行与列转置」    chess_nums_temp = [list(row) for row in zip(*chess_nums_temp)]    # 2. 判断是否可以向右移动    return judge_move_right(chess_nums_temp)

2048游戏 源码:

长按左侧二维码 2 秒

回复「2048」即可获取源码

(非本号)

 


阅读更多
源码:python连连看

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/192294