1-е 2-е 3-е меню в питоне черепаха гонщик? - PullRequest
0 голосов
/ 31 марта 2019

У меня есть задание, которое мне нужно закончить к четвергу, сегодня его воскресенье, и я не знаю, как это сделать, поэтому кто-то может помочь

Что мне нужно сделать Добавьте отображение, чтобы первый второй и третий россыпи в гонке переместились на подиум, например, *

код, который у меня сейчас есть: ' Буду очень признателен за любые советы по добавлению первого второго и третьего меню.И спаси мою задницу от глубокого дерьма # ================================================================

#                       Imports

#==========================================================
from PIL import Image, ImageTk
from turtle import *
import turtle
from random import randint
from turtle import Screen, Turtle
from math import sin, cos, atan2, pi
from random import randrange
racers = [] #defines what racers is 

#==========================================================

#                       GAME

#==========================================================

# Creating the window
screen = turtle.Screen()
screen.setup(1225, 1000)

pil_img = Image.open("eightLane.gif")  # Use PIL to open .jpg image.
tk_img = ImageTk.PhotoImage(pil_img)  # Convert it into something tkinter can use.
canvas = turtle.getcanvas()  # Get the tkinter Canvas of this TurtleScreen.
# Create a Canvas image object holding the tkinter image.
img_obj_id = canvas.create_image(0, 0, image=tk_img, anchor='center')

title("RACING TURTLES")

#==========================

#   Creating the turtles

#==========================

#in future adjust position 
LINEUP = [  # (color, (starting postion))
    ('red', (0, 90)), #creates each turtle and where it goes
    ('yellow', (-55, 120)),
    ('blue', (-120, 150)),
    ('green', (-195, 165)),
    ('dark goldenrod', (-270, 180)),
    ('blue violet', (-365, 170)),
    ('magenta', (-465, 140)),
    ('light slate gray', (-550, 100)),
]

for index, (color, position) in enumerate(LINEUP):

    racer = Turtle('turtle', visible=False) #pen settings for placing the turtles initially
    racer.setheading(180 + index * 10) 
    racer.speed('fastest') 
    racer.color(color) 
    racer.penup()
    racer.setposition(position)
    racer.showturtle() #shows the turtle now that it is in position

    racers.append(racer)



DELTA = 0.4  # angle at which they move

def radii(index):  # calculate concentric ellipse radii
    return 265 + index * 44, 90 + index * 36

def race(): #how often it moves a turtle
    """
    every 1/100000000000th of a second, pick a random 
    racer and move it forward a bit
    """

#basically tells the racer what angle to move at so it stays in its lane
    index = randrange(len(racers)) 
    racer = racers[index]

    # get angle from x, y; increase angle; compute new x, y
    theta = atan2(racer.ycor(), racer.xcor()) + DELTA

    a, b = radii(index) 

    x = a * cos(theta) #fancy maths
    y = b * sin(theta)

    racer.setheading(racer.towards(x, y)) #tells the racer where to face
    racer.setposition(x, y)  # moves the racer to the position 

    # check if racer has crossed the finish line
    if pi/2 < theta < pi/2 + DELTA/2: #if the racer has crossed the line run next line else skip
        pass  #someone one
    else:
        screen.ontimer(race, 100) #keeps the loop going

#variable for each racer called their distance
# find max distance for each loop (length of track) 
# times max distance by number of racers
# do a check for each step if all of the racers combined distance is still less than then max dist times no of racers
#then move them but do a check to see if they have individually crossed the line if so stop the racer


# if length of track - racer distance < amount that they move forward each step
#then move them the length of track - racer distance
#else move them their normal amount each step
race()
screen.mainloop()

enter image description hereenter image description here

...