파이썬 내공 150
-
게시물 수정 , 삭제는 로그인 필요
안녕하세요
거북이가 자유낙하할때마다의 그래프를 그리고 싶은데
거북이만 정상적으로 작동하고 그래프는 창은 뜨는데 안그려집니다.
어떻게해야하나요?
import turtle as t
import matplotlib.pyplot as plt
import numpy as np
t.shape("turtle")
plt.xlim([0,100])
plt.ylim([0,100])
def draw_pos(x, y):
t.clear()
t.hideturtle()
t.setpos(x,y)
t.showturtle()
t.stamp()
hl = -(t.window_height())/2
tm = 0
while True:
d = (9.8 * tm**2)/2
ny = y - int(d)
if ny > hl:
t.goto(x, ny)
t.stamp()
x=tm = tm + 0.5
else:
plt.plot(x, ny)
plt.show()
break
t.setup(400, 800)
#t.shape("circle")
t.penup()
t.hideturtle()
s = t.Screen()
s.onscreenclick(draw_pos)
s.listen()
t.mainloop()
거북이가 자유낙하할때마다의 그래프를 그리고 싶은데
거북이만 정상적으로 작동하고 그래프는 창은 뜨는데 안그려집니다.
어떻게해야하나요?
import turtle as t
import matplotlib.pyplot as plt
import numpy as np
t.shape("turtle")
plt.xlim([0,100])
plt.ylim([0,100])
def draw_pos(x, y):
t.clear()
t.hideturtle()
t.setpos(x,y)
t.showturtle()
t.stamp()
hl = -(t.window_height())/2
tm = 0
while True:
d = (9.8 * tm**2)/2
ny = y - int(d)
if ny > hl:
t.goto(x, ny)
t.stamp()
x=tm = tm + 0.5
else:
plt.plot(x, ny)
plt.show()
break
t.setup(400, 800)
#t.shape("circle")
t.penup()
t.hideturtle()
s = t.Screen()
s.onscreenclick(draw_pos)
s.listen()
t.mainloop()