猫史档案馆


Python球

Python球

Lv.1

py小白,停更一切图形化

获赞:29收藏:8浏览:213作品收藏:16

签名:学py

回复帖子评论
上一页1 页 / 共 1下一页

【Python作品分享】喵灵骷髅地下城 中回复

运行不了emotion_泪

2023-01-30T12:31:01 点赞:0

【Python作品分享】分解质因数【作品秀】 中回复

center_image

2023-01-30T12:59:35 点赞:0

大家喜欢源码编辑器3.0还是4.0? 中回复

3333333 顺手(最开始接触)

2023-01-30T14:00:23 点赞:0

本周副室长 中回复

 

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()

2023-04-04T21:30:38 点赞:0

3D专用库,想做MC不是梦!(正在攻)【作品秀】 中回复

center_image

2023-04-05T14:43:35 点赞:0