python·pygame小游戏

您所在的位置:网站首页 中国象棋小视频 python·pygame小游戏

python·pygame小游戏

2023-10-07 23:46| 来源: 网络整理| 查看: 265

大家好我是小豪,今天给大家带来的是pygame小游戏-中国象棋

因为看到博客上面很多上传了的中国象棋py文件,都是收费的。所以我大胆的上传个免费的…已经把原码上传了,感兴趣的可以去下载。

pygame小游戏-中国象棋下载链接–免费下载

尽可能的为大家提供免费的好玩的有趣的python小项目,培养大家对python的兴趣,学好python~ ············觉得不错点个赞吧!!!············ 下载运行有问题可以留言,基本在线。 说明:运行程序,直接在pycharm下打开文件夹,然后找到Chess_UI文件夹下面的win_game.py直接运行 目前还没找到智能AI版本的,只有这人人对战版本,我尽可能给大家提供更多的有趣的好玩的…游戏,绘图,等用python能实现的项目!

下面是部分代码,大概的写了一部分注释,不过基本上都是见名知意,大家可以去看看。 Ps:看到大量代码先别急,仔细看看是不是变量名占了一大部分,其实很好理解,不用口吐语气助词!! 比如像这样: 虽然看着量特别大,其实就是挨个挨个的写判断而已。 还有这样的:

while not cbd.is_end(): for event in pygame.event.get(): if event.type == pygame.QUIT: # 日常检测点X推出 sys.exit() elif event.type == MOUSEBUTTONDOWN: # 检测鼠标点击 pressed_array = pygame.mouse.get_pressed() for index in range(len(pressed_array)): if index == 0 and pressed_array[index]: # mouse_x, mouse_y = pygame.mouse.get_pos() col_num, row_num = translate_hit_area(mouse_x, mouse_y) chessman_sprite = select_sprite_from_group( chessmans, col_num, row_num) if current_chessman is None and chessman_sprite != None: # 这里判断你点的棋子是否是该颜色方行动(红黑方一人走一步的) if chessman_sprite.chessman.is_red == cbd.is_red_turn: current_chessman = chessman_sprite chessman_sprite.is_selected = True elif current_chessman != None and chessman_sprite != None: if chessman_sprite.chessman.is_red == cbd.is_red_turn: current_chessman.is_selected = False current_chessman = chessman_sprite chessman_sprite.is_selected = True else: # 成功 = 当前棋子移动((行数,列数)...也就是坐标) success = current_chessman.move( col_num, row_num) if success: # 见名知意,这句话也看得懂是判断什么的吧

这只是部分代码,复制运行无效!复制运行无效!复制运行无效! 我只是想说新手常犯的错,看到大量代码头疼,其实不需要的

好了,今天的部分作品已经完成,晚上更新今日课程内容,拜啦~



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3