第6周 >“华容道”游戏 Python程序设计导论

XJAU

答案见附件

# “华容道”游戏项目模板

import simpleguitk as gui
import math

# 全局变量
canvas_height = 500           # 画布高度,单位为像素
canvas_width = 400            # 画布宽度,单位为像素
game_over = False             # 游戏是否结束
figure_moving = False         # 是否有运动的人物
figures = {}                  # 所有人物
steps = 0                     # 移动步数
current_figure = None         # 鼠标点中的人物
current_center = []           # 鼠标点中人物的中心坐标
original_point = []           # 鼠标点击的初始位置坐标,用来计算鼠标拖动的方向
speed = 5                     # 人物移动的速度
machao_image = gui.load_image('http://202.201.225.74/video/PythonResoure/ProjectResource/images/project6/machao.png')
zhangfei_image = gui.load_image('http://202.201.225.74/video/PythonResoure/ProjectResource/images/project6/zhangfei.png')
zhaoyun_image = gui.load_image('http://202.201.225.74/video/PythonResoure/ProjectResource/images/project6/zhaoyun.png')
huangzhong_image = gui.load_image('http://202.201.225.74/video/PythonResoure/ProjectResource/images/project6/huangzhong.png')
guanyu_image = gui.load_image('http://202.201.225.74/video/PythonResoure/ProjectResource/images/project6/guanyu.png')
caocao_image = gui.load_image('http://202.201.225.74/video/PythonResoure/ProjectResource/images/project6/caocao.png')
soldier_image = gui.load_image('http://202.201.225.74/video/PythonResoure/ProjectResource/images/project6/shibing.png')


# Figure类(棋子类)
class Figure:
    def __init__(self, image, src_center, src_size, des_center, des_size, name, move_direction=None):
        self.image = image                     # 棋子图像
        self.src_center = src_center           # 源图像中心坐标
        self.src_size = src_size               # 源图像大小
        self.des_center = des_center         
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值