Created
October 13, 2020 22:10
-
-
Save nsa-yoda/bd9eb58ba394f55f17bc14108b2f62a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle as t | |
ARM_LENGTH = 30 | |
FOOT_LENGTH = 30 | |
RT_EYE_POS = [80, 0] | |
RT_PUPIL_POS = [78, 20] | |
# automatically calculate left eye | |
# and pupil positions based on right eye | |
LT_EYE_POS = [RT_EYE_POS[0] * -1, RT_EYE_POS[1]] | |
LT_PUPIL_POS = [RT_PUPIL_POS[0] * -1, RT_PUPIL_POS[1]] | |
def hide_turtle(): | |
t.penup() | |
t.setposition(-1000, -1000) | |
# Draw at fastest speed | |
print("Setting speed") | |
t.speed('slowest') | |
# draw left eye | |
print("Drawing left eye") | |
t.penup() | |
t.setposition(LT_EYE_POS[0], LT_EYE_POS[1]) | |
t.pendown() | |
t.circle(30) | |
# draw left pupil | |
print("Drawing left pupil") | |
t.penup() | |
t.setposition(LT_PUPIL_POS[0], LT_PUPIL_POS[1]) | |
t.dot(12) | |
# draw right eye | |
print("Drawing right eye") | |
t.penup() | |
t.setposition(RT_EYE_POS[0], RT_EYE_POS[1]) | |
t.pendown() | |
t.circle(30) | |
# draw right pupil | |
print("Drawing right pupil") | |
t.penup() | |
t.setposition(RT_PUPIL_POS[0], RT_PUPIL_POS[1]) | |
t.dot(12) | |
# draw face | |
print("Drawing face") | |
t.penup() | |
t.setposition(0, -80) | |
t.pendown() | |
t.circle(140) | |
# draw mouth | |
print("Drawing mouth") | |
t.penup() | |
t.setposition(0, -60) | |
t.pendown() | |
t.circle(20, 80) | |
# drawing body | |
print("Drawing body") | |
t.penup() | |
t.setposition(0, -80) | |
t.left(-170) | |
t.pendown() | |
t.forward(80) | |
# get position for body bottom | |
pos = t.position() | |
# draw one leg | |
print("Drawing one leg") | |
t.left(30) | |
t.forward(FOOT_LENGTH) | |
# reset to body bottom | |
t.setposition(pos[0], pos[1]) | |
# draw the other leg | |
print("Drawing other leg") | |
t.right(60) | |
t.forward(FOOT_LENGTH) | |
# reset to half of body bottom | |
print("Resetting to position") | |
t.penup() | |
t.setposition(pos[0], pos[1] + 30) | |
t.pendown() | |
# draw one arm | |
print("Drawing one arm") | |
t.left(60) | |
t.forward(ARM_LENGTH) | |
# reset to half of body bottom | |
print("Resetting to position") | |
t.setposition(pos[0], pos[1] + 30) | |
# draw the other arm | |
print("Drawing other arm") | |
t.right(60) | |
t.forward(ARM_LENGTH) | |
hide_turtle() | |
print("I'm done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment