Python code for EllipticalPath file
import math
from Facet import Template
def prep():
global x_dot, y_dot, h, k, a, b, restart
restart = False
scene.button.onrelease(play)
screen.delay(20)
turtle.penup()
turtle.setposition(scene.button.xcor(), scene.button.ycor()-10)
turtle.pendown()
turtle.write("Move", align="center", font=("Arial",16,"bold"))
diameter = 1
dot_colour = "#ffff00"
h = 0
k = 0
a = scene.wnd_width / 3
b = scene.wnd_height / 3
x_dot = h - a; y_dot = k
turtle.penup()
turtle.setposition(x_dot, y_dot)
turtle.setheading(270)
turtle.shape("triangle")
turtle.shapesize(diameter, diameter)
turtle.color(dot_colour, dot_colour)
def play(x, y):
global x_dot, y_dot, h, k, a, b, restart
if restart:
turtle.clearstamps()
restart = False
if x_dot <= h + a:
y_dot = k - (b/a)*math.sqrt(math.pow(a, 2) - math.pow((x_dot - h), 2))
turtle.setposition(x_dot, y_dot)
turtle.stamp()
y_dot = k + (b/a)*math.sqrt(math.pow(a, 2) - math.pow((x_dot - h), 2))
turtle.setposition(x_dot, y_dot)
turtle.stamp()
x_dot += 20
screen.ontimer(play(0,0), 500)
else:
x_dot = h - a; y_dot = k
restart = True
screen.mainloop()
scene = Template();
turtle = scene.controlButtons()
screen = scene.screen
prep()
Important: When trying to click on the button to get things
started, you might need to click away from the button text.