Untitled
unknown
plain_text
a year ago
3.4 kB
8
Indexable
# Copy and paste the code from your Sandbox once you've completed the challenge
speed(0)
def draw_device():
# draws border
penup()
goto(-175,-175)
seth(0)
pendown()
for i in range(4):
begin_fill()
color("red")
forward(344)
circle(10,90)
end_fill()
penup()
goto(-160,150)
pendown()
for i in range(2):
begin_fill()
color("lightgrey")
forward(315)
right(90)
forward(250)
right(90)
end_fill()
penup()
goto (-125,-160)
pendown ()
begin_fill()
color("white")
circle (25)
end_fill()
penup()
goto (125,-160)
pendown()
begin_fill()
color("white")
circle (25)
end_fill()
penup()
goto (-155,-130)
pendown()
begin_fill()
color("gold")
goto (-165,-135)
goto (-155,-140)
goto (-155,-130)
end_fill()
penup()
goto (-95,-140)
pendown()
begin_fill()
color("gold")
goto (-85,-135)
goto (-95,-130)
goto (-95,-140)
end_fill()
penup()
goto (90,-140)
pendown()
begin_fill()
color("gold")
goto (85,-130)
goto (95,-130)
goto (90,-140)
end_fill()
penup()
goto (160,-130)
pendown()
begin_fill()
color("gold")
goto (165,-140)
goto (155,-140)
goto (160,-130)
end_fill()
#draws title
penup()
goto(0,-145)
pendown()
color("yellow")
write("Etch A Sketch", font =("Brush Script MT", 20), align="center")
color("black")
penup()
goto(130,-195)
pendown()
write("SHAKE", font = ("Arial", 15))
penup()
goto(-150, -195)
pendown()
write("REDRAW", font=("Arial", 15))
draw_device()
penup()
goto (0,0)
pendown()
shape("classic")
directions_list = []
def move_on_click(x,y):
if -160 < x < 155 and -100 < y < 155:
goto(x,y)
directions_list.append("move")
elif -150 > x > -165 and -130 > y > -140:
seth(180)
forward(10)
directions_list.append("left")
elif -95 < x < -75 and -130 > y > -140:
seth(0)
forward(10)
directions_list.append("right")
elif 85 < x < 95 and -130 > y > -140:
seth(270)
forward(10)
directions_list.append("down")
elif 155 < x < 165 and -130 > y > -140:
seth(90)
forward(10)
directions_list.append("up")
def shake(x, y):
if 130 < x < 200 and -200 < y < -145:
current_x, current_y = pos()
clear()
draw_device()
penup()
goto(current_x, current_y)
pendown()
def redraw(x, y):
clear()
draw_device()
penup()
goto(0,0)
pendown()
for direction in directions_list:
if direction == "move":
continue
elif direction == "left":
seth(180)
elif direction == "right":
seth(0)
elif direction == "down":
seth(270)
elif direction == "up":
seth(90)
forward(10)
start_x, start_y = pos()
penup()
goto(start_x, start_y)
pendown()
directions_list.clear()
def all_click(x,y):
move_on_click(x,y)
shake(x,y)
if -150 < x < -50 and -195 < y < -180:
redraw(x,y)
canvas = getscreen()
canvas.onclick(all_click)Editor is loading...
Leave a Comment