PYTHON做 篮球游戏

源码:

#Python#
from Walimaker import *
setup(1024,550)
bgpic('./篮球场.jpg')
b=Character('./篮球.png')
b.scale(0.2)
vx=0
vy=0
r=0,0
sc=0
t=TextBox(70)
t.print(0)
t.goto(0,200)
h=Character('./篮筐.png')
h.scale(0.3)
h.goto(350,120)
while True:
    update()
    vy-=0.8
    b.x+=vx
    b.y+=vy
    if b.y<=-275:
        vy=-vy*0.8
        b.y=-275
    if b.x<=-512:
        vx=-vx*0.8
        b.x=-512
    if b.x>=512:
        vx=-vx*0.8
        b.x=512
    if b.get_mouse_clicked():
        b.goto(get_mouse_pos())
        vx=0
        vy=0
        r=get_mouse_rel()
    if b.get_mouse_just_released():
        vx,vy=r
    if b.separate(h):
        sc+=1
        t.print(sc)
    if sc>=5:
        while True:
            update()
            t.print('Congratulations on winning.press Q Reopen')
            if key_pressed(K_q):
                sc=0
                t.print(0)
                break

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值