0

So I'm trying to create turtles racing but with different windows at the same time. The play and exit buttons work but when I pick a color, nothing happens. Here's some of my code.

P.S I didn't add all of them because stack overflow wouldn't allow many codes

here are my code for the frames:

root.geometry('1000x1000')
frame1 = Frame(root, width = 1000, height = 1000, bg = 'red')
frame1.pack()
frame2 = Frame(root, width = 1000, height = 1000)
frame3 = Frame(root, width = 1000, height = 1000)
frame4 = Frame(root, width = 1000, height = 1000

and these are all of the functions:

play = True
player = ' '

#functions
def hide_frames():
    frame1.pack_forget() 
    frame2.pack_forget()
    frame3.pack_forget()
    
def chosen1():
    global player
    player = 't1'
    hide_frames()
    frame3.pack()             
    
def chosen2():    
    global player
    player = 't2'
    hide_frames() 
    frame3.pack()
def chosen3():
    global player
    player = 't3'
    hide_frames() 
    frame3.pack()
def chosen4():
    global player
    player = 't4'
    hide_frames() 
    frame3.pack()
def chosen5():
    global player
    player = 't5'
    hide_frames() 
    frame3.pack()
def chosen6():
    global player 
    player = 't6'
    hide_frames()
    frame3.pack()
def chosen7():
    global player
    player = 't7'
    hide_frames()
    frame3.pack()
def chosen8():
    global player
    player = 't8'
    hide_frames()
    frame3.pack()
def chosen9():
    global player
    player = 't9'
    hide_frames()
    frame3.pack()   

def playy():
    hide_frames()
    play = False
    frame2.pack()

here's for some of the buttons:

play_button = Button(frame1, text = 'Play',command = playy).pack(side = TOP)
exit_button = Button(frame1, text = 'Quit', command = root.quit).pack(side = TOP)
label = Label(frame2, text = 'please pick your color')
label.pack()
start_button = Button(frame3, text = 'START!', command = start)

and here's for the turtles:

while play == False:
    
    #create dice
    dice = random.randrange(1, 6)
    
    #create turtles
    t1 = turtle.RawTurtle(frame3)
    t1.shape('turtle')
    t1.color('green')
    t1.shapesize(2, 2, 2)
    t1.penup()
    t1.speed(0)
    t1.goto(-400, 400)
    t1.speed(dice)

    t2 = turtle.RawTurtle(frame3)
    t2.shape('turtle')
    t2.color('blue')
    t2.shapesize(2, 2, 2)
    t2.penup()
    t2.speed(0)
    t2.goto(-400, 300)
    t2.speed(dice)

    t3 = turtle.RawTurtle(frame3)
    t3.shape('turtle')
    t3.color('red')
    t3.shapesize(2, 2, 2)
    t3.penup()
    t3.speed(0)
    t3.goto(-400, 200)
    t3.speed(dice)

the turtles are up to nine but I just added 3 of them because long codes aren't allowed here

  • better create minimal working code which we could simply copy and run. And reduce it to 2 or 3 players. Frankly, you could use `for`-loop to create players, and keep them on list. – furas Mar 01 '22 at 13:14
  • with current code I have no idea how it works and what is the problem. – furas Mar 01 '22 at 13:18

0 Answers0