用户:小郭儿-查看:0 回复:2 评论:0 创建时间:2021-02-23T11:42:51
【作品展示】

【作品介绍】
鼠标点击,在鼠标点击处生成同心圆
【作品源代码】
import pgzrun
import random
import time
q = 1
HEIGHT = 600
WIDTH = 800
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]))
def update():
for ball in balls:
ball[0] = ball[0] + ball[2]
ball[1] = ball[1] + ball[3]
if ball[0] <= 0 or ball[0] >= WIDTH:
ball[2] = -ball[2]
if ball[1] <= 0 or ball[1] >= HEIGHT:
ball[3] = -ball[3]
def on_mouse_move(pos,rel,buttons):
global q
if mouse.LEFT in buttons:
x = pos[0]
y = pos[1]
speed_x = random.randint(1, 10)
speed_y = random.randint(1, 10)
# r = random.randint(20, 40)
for i in range(random.randint(10,50),0,-1):
color_R = random.randint(0, 255)
color_G = random.randint(0, 255)
color_B = random.randint(0, 255)
t = q*i
ball = [x, y, speed_x, speed_y, t, color_R, color_G, color_B]
balls.append(ball)
pgzrun.go()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn
人机47号imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%8A%A0%E6%B2%B9.gif"alt="emotion_编程猫_加油"
点赞0
评论