Created
December 16, 2022 08:20
-
-
Save stephengruppetta/298fa26e0dc8fd3be0ae39fca72fc34d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
window = turtle.Screen() | |
window.bgcolor("sky blue") | |
# Create all circle-shaped objects | |
def make_circle(turtle_name, x, y, size, colour): | |
turtle_name.color(colour) | |
turtle_name.penup() | |
turtle_name.setposition(x, y) | |
turtle_name.dot(size) | |
# Snowman: body | |
snowman = turtle.Turtle() | |
x_position = 0 | |
y_positions = 75, 0, -100 | |
size = 75 | |
for y in y_positions: | |
make_circle(snowman, x_position, y, size, "white") | |
size = size * 1.5 | |
# Snowman: buttons | |
button_seperation = 25 | |
button_y_positions = [ | |
y_positions[1] - button_seperation, | |
y_positions[1], | |
y_positions[1] + button_seperation, | |
] | |
for y in button_y_positions: | |
make_circle(snowman, x_position, y, 10, "black") | |
# Snowman: eyes | |
y_offset = 10 | |
x_seperation = 15 | |
for x in x_position - x_seperation, x_position + x_seperation: | |
make_circle(snowman, x, y_positions[0] + y_offset, 20, "green") | |
make_circle(snowman, x, y_positions[0] + y_offset, 10, "black") | |
# Snowman: nose | |
snowman.color("orange") | |
snowman.setposition(x_position - 10, y_positions[0] - y_offset) | |
snowman.shape("triangle") | |
snowman.setheading(200) | |
snowman.turtlesize(0.5, 2.5) | |
turtle.done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment