用户:
中国球1Epc查看:0 回复:1 评论:0 创建时间:2023-04-01T08:24:20
希铄金属制品、胡桃桑
import random
import pgzrun
WIDTH = 1200
HEIGHT = 600
balls = []
def draw():
screen.fill("white")
for ball in balls:
screen.draw.filled_circle(
(ball[0], ball[1]), ball[4], (ball[5], ball[6], ball[7])
)
for x in range(1, ball[4], 3):
screen.draw.filled_circle(
(ball[0], ball[1]),
ball[4] - x,
(
random.randint(ball[5], 225),
random.randint(ball[6], 225),
random.randint(ball[7], 225),
),
)
def update():
for ball in balls:
ball[0] = (ball[0] + ball[2])
ball[1] = (ball[1] + ball[3])
if (ball[0] > WIDTH - ball[4] or ball[0] < ball[4]):
ball[2] = -ball[2]
if (ball[1] > WIDTH - ball[4] or ball[1] < ball[4]):
ball[3] = -ball[3]
def on_mouse_move(pos, rel, buttons):
if (mouse.LEFT in buttons):
x = pos[0]
y = pos[1]
speed_x = random.randint(1, 5)
speed_y = random.randint(1, 5)
r = random.randint(5, 50)
colorR = random.randint(10, 225)
colorG = random.randint(10, 225)
colorB = random.randint(10, 225)
ball = [x, y, speed_x, speed_y, r, colorR, colorG, colorB]
balls.append(ball)
pgzrun.go()
点赞0
评论