用户:
可爱嫦娥姐姐查看:0 回复:0 评论:0 创建时间:2022-09-06T15:03:26
【作品展示】

【作品介绍】
无双庄园有3个小球,冰雨、紫光、黑暗
【作品源代码】
import pgzrun
HEIGHT = 600
WIDTH = 800
ry = HEIGHT/2
rx = WIDTH/2
sy = HEIGHT/2
sx = WIDTH/2
ty = HEIGHT/2
tx = WIDTH/2
sspeed_y = 6
sspeed_x = 6
rspeed_y = 7
rspeed_x = 7
tspeed_y = 5
tspeed_x = 5
r = 25
s = 25
t = 25
def draw():
screen.fill('white')
screen.draw.filled_circle((sx, sy), s, 'purple')
screen.draw.filled_circle((rx, ry), r, 'blue')
screen.draw.filled_circle((tx, ty), t, 'black')
def update():
global ty,tx,rx,ry,sx,sy,sspeed_x,sspeed_y,rspeed_x,rspeed_y,tspeed_x,tspeed_y
ry = ry+rspeed_y
sy = sy+sspeed_y
ty = ty+tspeed_y
if ry >= HEIGHT-r or ry <= r:
rspeed_y = -rspeed_y
if sy >= HEIGHT-s or sy <= s:
sspeed_y = -sspeed_y
if ty >= HEIGHT-t or ty <= t:
tspeed_y = -tspeed_y
rx = rx+rspeed_x
sx = sx+sspeed_x
tx = tx+tspeed_x
if rx >= WIDTH-r or rx <= r:
rspeed_x = -rspeed_x
if sx >= WIDTH-s or sx <= s:
sspeed_x = -sspeed_x
if tx >= WIDTH-t or tx <= t:
tspeed_x = -tspeed_x
pgzrun.go()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn