猫史档案馆


【Python作品分享】疯狂的小球【教程贴】

用户:张2r9R张2r9R查看:0 回复:3 评论:0 创建时间:2021-07-02T19:18:26


【作品展示】

center_image

 

【作品介绍】

很NB

喵得很

 

【作品源代码】

import pgzrun
import random
WIDTH=800
HEIGHT=600
balls=[]
for i in range(100):
    x=random.randint(100,WIDTH-100)
    y=random.randint(100,HEIGHT-100)
    speedx=random.randint(1,5)
    speedy=random.randint(1,5)
    r=random.randint(5,50)
    colorR=random.randint(10,255)
    colorG = random.randint(10, 255)
    colorB = random.randint(10, 255)
    ball = [x, y, speedx, speedy, r, colorR, colorG, colorB]
    balls.append(ball)
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]>WIDTH-ball[4]or ball[0]HEIGHT-ball[4]or ball[1]

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
BLUEGEUSTBLUEGEUST

额,有意义吗?

点赞0


评论


Python-happyyyyPython-happyyyy

mc好评

点赞0


评论


CBSCBS

然后运行是一个bug

点赞0


评论