Skip to content

Instantly share code, notes, and snippets.

@horstjens
Last active July 11, 2016 09:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horstjens/c2233a2f223ebb46a6a6 to your computer and use it in GitHub Desktop.
Save horstjens/c2233a2f223ebb46a6a6 to your computer and use it in GitHub Desktop.
turtle cannonball
import math
import turtle as t
p1 = t.Turtle()
p1.left(70)
p1.speed=9
p1.dx = math.cos(p1.heading()*math.pi/180)*p1.speed
p1.dy = math.sin(p1.heading()*math.pi/180)*p1.speed
for step in range(100):
x = p1.xcor()
y = p1.ycor()
p1.dy -= 0.1
x += p1.dx
y += p1.dy
p1.goto(x,y)
t.exitonclick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment