猫史档案馆


【Python作品分享】turtle弹幕【求助帖】

用户:程序侯程序侯查看:0 回复:1 评论:0 创建时间:2020-05-10T12:12:21


帮我看看为什么开启不了线程?

l = []
num = 0
import turtle
while True:
    num += 1
    try:
        l.append(turtle.textinput('turtle弹幕(按“Canser”键即可退出编辑)', (('第' + str(num)) + '字母是:')) + '')
    except TypeError:
        break
speed = 0
while speed == 0:
    speed = turtle.numinput('turtle弹幕(不能为0)', '请设置弹幕速度')
pen = []
import time, random
def draw(num):
    global speed, l, pen
    pen[num].penup()
    pen[num].hideturtle()
    if speed > 0:
        pen[num].goto(-1000, (num - 12) * 30)
    else:
        pen[num].goto(1000, (num - 12) * 30)
    while True:
        time.sleep(random.uniform(0, 3))
        while abs(pen[num].xcor) <= 1000 + len(l[num]) * 20:
            pen[num].clear()
            pen[num].write(l[num], font = ('楷体', 20, 'normal'))
            pen[num].setx(pen[num] + speed)
    if speed > 0:
        pen[num].goto(-1000, (num - 12) * 30)
    else:
        pen[num].goto(1000, (num - 12) * 30)
import _thread
for num in range(25):
    pen.append(turtle.Pen())
    _thread.start_new_thread(draw, (num,))


回复

上一页1 页 / 共 1下一页
不起眼的账号不起眼的账号

pygame运行似乎没有报错结束了

点赞0


评论