脚本宝典收集整理的这篇文章主要介绍了Pygame _来回弹跳的小球,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
----------------------------------------------------------------------
import pgzrun
WIDTH = 600HeiGHT = 400
sPEed_x = 2speed_y = 2
ball_r =30
x=ball_ry=HEIGHT/2
bounce_height= HEIGHT-ball_rbounce_width = WIDTH - ball_r
def draw(): screen.fill((0,125,125)) screen.draw.filled_circle((x,y),ball_r,(220,100,100))
def update(): global x,y,speed_x,speed_y, ball_r,bounce_height,bounce_width x = x + speed_x y = y + speed_y if x>= bounce_width or x<ball_r:speed_x = -speed_xsounds.crash.play() if y >= bounce_height or y<= ball_r:speed_y = -speed_y sounds.crash.play()pgzrun.go()
--------------------------------------------------------------------------
以上是脚本宝典为你收集整理的Pygame _来回弹跳的小球全部内容,希望文章能够帮你解决Pygame _来回弹跳的小球所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。