如何在Turtle Racer中添加第一,第二,第三功能?

时间:2019-04-03 09:03:38

标签: python tkinter turtle-graphics appjar

我的目标是创造一个登上领奖台的效果,以便乌龟在比赛结束后按照完成的顺序排列。问题在于,每当红龟完成时,其他乌龟都会停下来,无论红龟先在哪里完成,并且即使它们具有相同的代码,其他乌龟也不会注册为已完成。

我尝试过  改变完成比赛所需的距离 如果先于if后删除if statemetns 修改代码

每只乌龟都必须创建它,除了一只变成了两只,等等

one=Turtle() #name of the turtle
one.color('red') #color of the turtle 
one.shape('turtle') #shape of the turtle 
one.penup() #makes the trail line
one.goto(-220,170) #starting space #first number is horizontal position second is vertical
one.pendown()
for turn in range(36): # how many times it rotates
    one.right(10) # how far the turtle spins each rotation 

停止和放置海龟的代码如下

first = False
second = False
third = False
fourth = False
fifth = False
sixth = False
seventh = False
eighth = False 

if TurtleOne>=500: #if TurtleOne has traveled more than 500 do the following 
        one.penup()
        if first == False:
            one.goto(-300,-110)
            first = True
        elif first == True:
            one.goto(-250,-110)
            second = True
        elif second == True:
            one.goto(-200,-110)
            third = True
        elif third == True:
            one.goto(-150,-110)
            forth = True
        elif forth == True:
            one.goto(-100,-110)
            fifth = True
        elif fifth == True:
            one.goto(-50,110)
            sixth = True
        elif sixth == True:
            one.goto(0,-110)
            seventh = True 
        elif seventh == True:
            one.goto(50,-110)
            eighth = True
        elif eighth == True:
            time.sleep(5) #waits 10 seconds
            turtle.bye()   # closes the window 
            import Lanes   # goes back to lane selection         
elif TurtleTwo>=500:
        two.penup()
        if first == False:
            two.goto(-300,-110)
            first = True
        elif first == True:
            two.goto(-250,-110)
            second = True
        elif second == True:
            two.goto(-200,-110)
            third = True
        elif third == True:
            two.goto(-150,-110)
            forth = True
        elif forth == True:
            two.goto(-100,-110)
            fifth = True
        elif fifth == True:
            two.goto(-50,110)
            sixth = True
        elif sixth == True:
            two.goto(0,-110)
            seventh = True 
        elif seventh == True:
            two.goto(50,-110)
            eighth = True
        elif eighth == True:
            time.sleep(5) #waits 10 seconds
            turtle.bye()   # closes the window 
            import Lanes   # goes back to lane selection   
elif TurtleThree>=500:
        three.penup()
        if first == False:
            three.goto(-300,-110)
            first = True
        elif first == True:
            three.goto(-250,-110)
            second = True
        elif second == True:
            three.goto(-200,-110)
            third = True
        elif third == True:
            three.goto(-150,-110)
            forth = True
        elif forth == True:
            three.goto(-100,-110)
            fifth = True
        elif fifth == True:
            three.goto(-50,110)
            sixth = True
        elif sixth == True:
            three.goto(0,-110)
            seventh = True 
        elif seventh == True:
            three.goto(50,-110)
            eighth = True
        elif eighth == True:
            time.sleep(5) #waits 10 seconds
            turtle.bye()   # closes the window 
            import Lanes   # goes back to lane selection   
elif TurtleFour>=500:
        four.penup()
        if first == False:
            four.goto(-300,-110)
            first = True
        elif first == True:
            four.goto(-250,-110)
            second = True
        elif second == True:
            four.goto(-200,-110)
            third = True
        elif third == True:
            four.goto(-150,-110)
            forth = True
        elif forth == True:
            four.goto(-100,-110)
            fifth = True
        elif fifth == True:
            four.goto(-50,110)
            sixth = True
        elif sixth == True:
            four.goto(0,-110)
            seventh = True 
        elif seventh == True:
            four.goto(50,-110)
            eighth = True
        elif eighth == True:
            time.sleep(5) #waits 10 seconds
            turtle.bye()   # closes the window 
            import Lanes   # goes back to lane selection   
elif TurtleFive>=500:
        five.penup()
        if first == False:
            five.goto(-300,-110)
            first = True
        elif first == True:
            five.goto(-250,-110)
            second = True
        elif second == True:
            five.goto(-200,-110)
            third = True
        elif third == True:
            five.goto(-150,-110)
            forth = True
        elif forth == True:
            five.goto(-100,-110)
            fifth = True
        elif fifth == True:
            five.goto(-50,110)
            sixth = True
        elif sixth == True:
            five.goto(0,-110)
            seventh = True 
        elif seventh ==True:
            five.goto(50,-110)
            eighth = True
        elif eighth == True:
            time.sleep(5) #waits 10 seconds
            turtle.bye()   # closes the window 
            import Lanes   # goes back to lane selection   
elif TurtleSix>=500:
        six.penup()
        if first == False:
            six.goto(-300,-110)
            first = True
        elif first == True:
            six.goto(-250,-110)
            second = True
        elif second == True:
            six.goto(-200,-110)
            third = True
        elif third == True:
            six.goto(-150,-110)
            forth = True
        elif forth == True:
            six.goto(-100,-110)
            fifth = True
        elif fifth == True:
            six.goto(-50,110)
            sixth = True
        elif sixth == True:
            six.goto(0,-110)
            seventh = True 
        elif seventh == True:
            six.goto(50,-110)
            eighth = True
        elif eighth == True:
            time.sleep(5) #waits 10 seconds
            turtle.bye()   # closes the window 
            import Lanes   # goes back to lane selection   
elif TurtleSeven>=500:
        seven.penup()
        if first == False:
            seven.goto(-300,-110)
            first = True
        elif first == True:
            seven.goto(-250,-110)
            second = True
        elif second == True:
            seven.goto(-200,-110)
            third = True
        elif third == True:
            seven.goto(-150,-110)
            forth = True
        elif forth == True:
            seven.goto(-100,-110)
            fifth = True
        elif fifth ==True:
            seven.goto(-50,110)
            sixth = True
        elif sixth == True:
            seven.goto(0,-110)
            seventh = True 
        elif seventh == True:
            seven.goto(50,-110)
            eighth = True
        elif eighth == True:
            time.sleep(5) #waits 10 seconds
            turtle.bye()   # closes the window 
            import Lanes   # goes back to lane selection   
elif TurtleEight>=500:
        eight.penup()
        if first == False:
            eight.goto(-300,-110)
            first = True
        elif first == True:
            eight.goto(-250,-110)
            second = True
        elif second == True:
            eight.goto(-200,-110)
            third = True
        elif third == True:
            eight.goto(-150,-110)
            forth = True
        elif forth == True:
            eight.goto(-100,-110)
            fifth = True
        elif fifth == True:
            eight.goto(-50,110)
            sixth = True
        elif sixth == True:
            eight.goto(0,-110)
            seventh = True 
        elif seventh == True:
            eight.goto(50,-110)
            eighth = True
        elif eighth == True:
            time.sleep(5) #waits 10 seconds
            turtle.bye()   # closes the window 
            import Lanes   # goes back to lane selection   

0 个答案:

没有答案