我有一个任务,我需要在今天的星期四(星期天)之前完成任务,而香港专业教育学院不知道该如何做,所以有人可以帮忙吗
我需要做什么 添加一个显示,以便将比赛中第一,第二和第三名的放置者移动到领奖台上 *
我当前拥有的代码是:' 有关添加第一第二和第三菜单的任何建议将不胜感激。并从深狗屎中拯救我的屁股 #================================================= =========
# 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()