Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
4.7 kB
5
Indexable
Never
#Create a creature program!

#sets canvas size and stores half of height and width as a shorter name to simplify placing the shapes
set_size(400, 400)
height = get_height() /2
width = get_width() /2

##############################

#draws the square head
def rect_head():
    rect = Rectangle(300, 300)
    rect.set_position(50,50)
    rect.set_color(Color.red)
    add(rect)
    
#draws the square eyes
def rect_eyes():
    lreye = Rectangle(40,40)
    lreye.set_position(255, 160)
    lreye.set_color(Color.black)
    add(lreye)
    rreye = Rectangle(40,40)
    rreye.set_position(105, 160)
    rreye.set_color(Color.black)
    add(rreye)
    
#draws the pointed mouth option
def rect_smile():
    smle = Line(125, 285, 275, 285)
    add(smle)
    lsmle = Line(125, 255, 125, 285)
    add(lsmle)
    rsmle = Line(275, 285, 275, 255)
    add(rsmle)

#############################

#draws the circle head
def circ_head():
    test = Circle(150)
    test.set_position(width, height)
    test.set_color(Color.red)
    add(test)

#draws the round eyes
def circ_eyes():
    lreye = Circle(20)
    lreye.set_position(width + 75, height- 20)
    lreye.set_color(Color.black)
    add(lreye)
    rreye = Circle(20)
    rreye.set_position(width - 75, height- 20)
    rreye.set_color(Color.black)
    add(rreye)

#draws the curved mouth
def circ_smile():
    x = Line(width - 75, height + 75, width -37.5, height + 85)
    add(x)
    y = Line(width + 75, height + 75, width + 37.5, height + 85)
    add(y)
    z = Line(162.5, 285, 237.5, 285)
    add(z)

#############################


    
#this list is used to keep track of the users choices, to print out the information at the end
lst = []

#asks the user what they want their head shape to be, puts answer in lst
def head_q():
    head = input("What shape do you want your head to be? (Square or Circle) ")
    head = head.lower()
    
    if head == "square":
        lst.append("square")
    elif head == "circle":
        lst.append("circle")
    else:
        q = input("That is not an option, please enter a valid option. Type to continue")
        head_q()
            
            

#asks user what eyes they want, and puts in their choice in lst
def eye_q():
    q2 = input("What shape do you want the eyes to be? (Square or Circle) ")
    q2 = q2.lower()
    if q2 == "square":
        lst.append("square")
    elif q2 == "circle":
        lst.append("circle")
    else:
        q = input("That is not an option, please enter a valid option. Type to continue")
        eye_q()

#asks user what smile they want, and puts it in lst
def smile_q():
    q3 = input("What shape do you want the smile to be? (Sharp or Round) ")
    q3 = q3.lower()
    if q3 == "sharp":
        lst.append("sharp")
    elif q3 == "round":
        lst.append("round")
    else:
        q = input("That is not an option, please enter a valid option. Type to continue")
        smile_q()
        
#puts together the creature using the users previous options
#uses a list to later describe the information about the creature
def put_together():
    if (lst[0]) == "circle":
        circ_head()
    if (lst[0]) == "square":
        rect_head()
        
    if (lst[1]) == "circle":
        circ_eyes()
    if (lst[1]) == "square":
        rect_eyes()
        
    if (lst[2]) == "sharp":
        rect_smile()
    if (lst[2]) == "round":
        circ_smile()
    
 #goes through list of colors, adds one to x each time if the color is not listed. since 
    #there are 9 colors, if x = 10, then the input is not one of the colors and it is not a valid option, it 
    #then goes on to repeat the question
    
#Asks user their favorite color to change the name of the friend to that color.
def name_color():
    COLORS = ["red", "green", "blue", "yellow", "cyan", "orange", "black", "gray", "purple"]
    
    while(True):
        col = input("Whats your favorite color? ")
        col = col.lower()
        
        if col in COLORS:
            color = str("Color." + col)
            break
        else:
            n = input("That is not an option, please enter a valid option. Type to continue")


    
    #gets the name and prints it out using the color above.
    name = input("What do you name your friend?")
    txt = Text(name)
    txt.set_position(40, 390)
    txt.set_color(col)
    txt.set_font("30pt Arial")
    add(txt)
    return name
   
   
#puts all of the functions together to create the image and nametag of friend 
head_q()
eye_q()
smile_q()
put_together()
name = name_color()

#prints out info about the creature!
print(name + " has a " + lst[0] + " head, with " + lst[1] + " eyes, and a " + lst[2] + " smile!")