이거 거북이 모듈로 저기 1번 거북이랑 2번 거북이를 움직여서 저 노란선 까지 먼저 가면 승리하는걸로 만들고 싶은데
노란선에 닿으면 소리가 나게해야 하는데 코드를 어떻게 짜야될지 모르겠음
def player1():
t1.fd(5)
def player2():
t2.fd(5)
def buttonbase(width,height,color):
t3.fillcolor(color)
t3.begin_fill()
t3.forward(width)
t3.right(90)
t3.forward(height)
t3.right(90)
t3.forward(width)
t3.right(90)
t3.forward(height)
t3.end_fill()
def makebutton(x,y,msg):
t3.penup()
t3.goto(x,y)
t3.setheading(0)
buttonbase(button_width,button_height,button_color)
t3.goto(x+button_width/2,y-button_height)
t3.pencolor('white')
t3.write(msg,align='center',font=('Arial',30))
def checkButton(x,y,):
if (x>=explain_x and
x<explain_x+button_width and
y<=explain_y and
y>=explain_y-button_height):
print("플레이어 1은 D, 플레이어2는 오른쪽 방향키로 움직입니다.")
def init():
makebutton(explain_x,explain_y,"설명")
import turtle
win = turtle.Screen()
turtle.setup(800,600)
turtle.bgpic("경기장.gif")
turtle.addshape("1번.gif")
turtle.addshape("2번.gif")
win.onkey(player1,"d")
win.onkey(player1,"D")
win.onkey(player2,"Right")
t1 = turtle.Turtle()
t1.shape("1번.gif")
t2 = turtle.Turtle()
t2.shape("2번.gif")
t3 = turtle.Turtle()
t4 = turtle.Turtle()
t1.penup()
t2.penup()
t1.goto(-350,-10)
t2.goto(-350,-120)
t4.penup()
t4.goto(280,100)
t4.right(90)
t4.pendown()
t4.pensize(20)
t4.pencolor('yellow')
t4.fd(320)
button_width=150
button_height=50
button_color='blue'
explain_x=-400
explain_y=300
init()
win.listen()
win.onclick(checkButton)
지금 코드는 이렇게 짰음