Untitled

 avatar
unknown
plain_text
9 months ago
4.0 kB
0
Indexable
#This list will hold all the new directional values for the redraw
direction_list= []

#This function will append move up
def move_up(): 
    seth(90)
    forward(10)
    direction_list.append("up")

#This function will append move down    
def move_down(): 
    seth(270)
    forward(10)
    direcrion_list.append("down")

#This function will append move left    
def move_left(): 
    seth(180)
    forward(10)
    direction_list.append("left")

#This function will append move right
def move_right(): 
    seth(0)
    forward(10)
    direction_list.append("right")

#This function will create the border
def draw_border():
    begin_fill()
    color("Red")
    goto(-175,175)
    goto(-175,-175)
    forward(350)
    goto(175,175)
    backward(350)
    end_fill()
    
#This function will draw the screen
def draw_screen():
    begin_fill()
    color("light grey")
    forward(300)
    left(180)
    forward(300)
    left(90)
    forward(250)
    left(90)
    forward(300)
    left(90)
    forward(250)
    end_fill()

#This function will erase and redraw the drawings
def redraw(x,y):
    goto(-150,150)
    seth(360)
    draw_screen()
    penup()
    goto(0,0)
    pendown()
    for direction in direction_list: 
        if direction == "up": 
            seth(90)
        elif direction == "down": 
            seth(270)
        elif direction == "left": 
            seth(180)
        elif direction == "right": 
            seth(0)
        forward(10)
        
#This function will draw the knobs
def draw_knob():
    begin_fill()
    color("white")
    circle(25)
    end_fill()
    penup()
    goto(150,-135)
    pendown()
    color("white")
    begin_fill()
    circle(25)
    end_fill()
    
#This function will draw the triangles
def draw_triangles():
    begin_fill()
    color("gold")
    goto(-165,-135)
    goto(-155,-140)
    goto(-155,-130)
    end_fill()
    penup()
    goto(-95, -140)
    pendown()
    begin_fill()
    goto(-85,-135)
    goto(-95,-130)
    goto(-95,-140)
    end_fill()
    penup()
    goto(90,-140)
    pendown()
    begin_fill()
    goto(85,-130)
    goto(95,-130)
    goto(90,-140)
    end_fill()
    penup()
    goto(160,-130)
    pendown()
    begin_fill()
    goto(165,-140)
    goto(155,-140)
    goto(160,-130)
    end_fill()

def move_to_click(x,y):
    goto(x,y)
    canvas.count = canvas.count + 1  
    print(canvas.count)
    

speed(0)   
penup()   
backward(175)
pendown()

#Outer Square
draw_border()

penup()
goto(-150,150)
pendown()


#Inner Square
draw_screen()

penup()
goto(-100,-135)
pendown()

#Circles
draw_knob()

penup()
goto(-155,-130)
pendown()

#Triangles
draw_triangles()

#Logo
penup()
goto(0,-145)
pendown()
write("Etch A Sketch", font=("Brush Script MT", 20), align ="center")

#This code create the console command
shape("classic")
color("black")
penup()
goto(0,0)
pendown()

#This writes the SHAKE button and function
penup() 
goto(109,-187)
write("SHAKE", font=("Arial", 10), align="center")
goto(-127, -184)
write("REDRAW", font=("Arial", 10), align="center")
goto(0,0)

def shake(x,y): 
    penup()
    goto(-150,150)
    seth(360)
    draw_screen()
    color("black")
    goto(pos())
  
#Move to click function
def move_to_click(x,y):
    print(str(x) + ", " + str(y))
    if x> -150 and x<150 and y> -100 and y<150:
        goto(x,y)
        canvas.count = canvas.count + 1

    if x < 165 and x>155 and y<-130 and y>-140:
        seth(90)
        forward(10)
    
    if x<95 and x>85 and y<-130 and y>-140:
        seth(270)
        forward(10)

    if x<-155 and x>-165 and y<-130 and y>-140:
        seth(180)
        forward(10)

    if x<-85 and x>-95 and y<-130 and y>-140:
        seth(0)
        forward(10)
        
    if x<109 and x>99 and y>-190 and y<-180: 
        shake(x,y)
        
    if x<-110 and x>-140 and y>-200 and y<-180: 
        redraw(x,y)
        color("black")

pendown() 
canvas = getscreen()

canvas.onclick(move_to_click)
canvas.count = 0
Editor is loading...
Leave a Comment