多线程海龟移动动画例子_multithread turtle example

"""
   多线程海龟移动动画例子_multithread turtle example 
"""
from queue import Queue
from random import randint
from turtle import Screen, Turtle
from threading import Thread, active_count

QUEUE_SIZE = 1
turtle_SPEED = 3

def move_turtle(turtle, direction):
    """
       移动海龟线程,超过x坐标288就往下移50
    """
    x, y = turtle.position()

    while True:
        while direction == "right":

            if x > 288:
                y -= 50
                actions.put((turtle.sety, y))
                direction = "left"
            else:
                x += turtle_SPEED
                actions.put((turtle.setx, x))

        while direction == "left":
            if x < -288:
                y -= 50
                actions.put((turtle.sety, y))
                direction = "right"
            else:
                x -= turtle_SPEED
                actions.put((turtle.setx, x))

You must log in to read the rest of this article. Please log in or register as a user.

  

本站所有作品,教程等皆为原创,盗版必究。一旦付款,表示同意本站知识付费原则:数字商品,不支持退款。扫码付款后的朋友可以加QQ: 406273900,提供技术支持及发送作品图片与配音素材。亦可直接向微信号scratch8付款购买。
李兴球的博客_Python创意编程技术前沿 » 多线程海龟移动动画例子_multithread turtle example

学本领,探索更大的世界!

李兴球博客 风火轮编程主页
error: Content is protected !!