缩小隧道-哆啦a梦

from Walimaker import *
setup(800, 800)

def create(img, pos, scl = 0.5):
    # 创建
    c = Character(img)
    c.goto(pos)
    c.scl = scl # 属性
    c.scale(c.scl) 
    return c   

def suoxiaosuidao(c):
    if c.get_mouse_clicked():
        c.goto(get_mouse_pos())
    if c.collide(tunnel) and c.get_mouse_clicked():
        if vx > 0:
            # 变大
            c.scl += 0.01
        if vx < 0:
            # 变小
            c.scl -= 0.01
        c.scale(c.scl)

def zhuqingting(c):
    # 当竹蜻蜓和人物接触,人物往上飞
    if heli.get_mouse_clicked():
        heli.goto(get_mouse_pos())
    if c.collide(heli):
        c.y += 5
        heli.y += 5

tunnel = Character('缩小隧道.png')
tunnel.scale(0.3)
heli = Character('竹蜻蜓.png')
heli.scale(0.3)
# 哆啦A梦的创建
dora = create('哆啦A梦.png', (300,300), 0.6)
# 大雄的创建
daxiong = create('大雄.png', (0,300), 0.4)
# 胖虎的创建
panghu = create('胖虎.png', (-300,300))
while True:
    vx, vy = get_mouse_rel() # 分解
    # 哆啦A梦和缩小隧道的交互
    suoxiaosuidao(dora)
    # 大雄和缩小隧道的交互
    suoxiaosuidao(daxiong)
    # 胖虎和缩小隧道的交互
    suoxiaosuidao(panghu)

    # 哆啦A梦和竹蜻蜓的交互
    zhuqingting(dora)
    # 大雄和竹蜻蜓的交互
    zhuqingting(daxiong)
    # 胖虎和竹蜻蜓的交互
    zhuqingting(panghu)
    update()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值