Python Forum
Homework: Smiley Face game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Homework: Smiley Face game
#1
Hi guys! I am taking my first computer programming class and working on a homework assignment involving a game that will change a smiley face (drawn using turtle) based on user input.
Basically, when the program starts a regular smiley face will be drawn (yellow face, black eyes and mouth, smile). The user is then prompted to change the face with the following menu:

Change My Face
1) Make me frown
2) Make me angry
3) Make my eyes blue
0) Quit

If the user selects 1, the smiley face is redrawn with the frown turned to a smile and the menu will change to:

Change My Face
1) Make me smile
2) Make me angry
3) Make my eyes blue
0) Quit

If the user selects 2, the smiley face is redrawn and filled in red with a frown and the menu will change to:

Change My Face
1) Make me smile
2) Make me happy
3) Make my eyes blue
0) Quit

And so on, with the menu always changing based on the attributes of the face that was last drawn.

We were given starter code to work on this project (with __<Fill-In>__ everywhere we are to add a single line/partial line of code). We also need to and can add methods and data as necessary to this existing code. I am having a hard time understanding class and objects, anyway, and this is proving to be a more difficult assignment for me than I originally thought it would be. Here is the starter code we were given (we are defining class in the same file as our main function for convenience):

import turtle


class Face:
    def __init__(self):
        self.__smile = True
        self.__happy = True
        self.__dark_eyes = True

    def draw_face(self):
        turtle.clear()
        self.__draw_head()
        self.__draw_eyes()
        self.__draw_mouth()

    def is_smile(self):
        ___<Fill-In>___

    def is_happy(self):
        ___<Fill-In>___

    def is_dark_eyes(self):
        ___<Fill-In>___

    def change_mouth(self):
        ___<Fill-In>___
        self.draw_face()

    def change_emotion(self):
        ___<Fill-In>___
        self.draw_face()

    def change_eyes(self):
        ___<Fill-In>___
        self.draw_face()


def main():
    face = ___<Fill-In>___
    face.___<Fill-In>___

    done = False

    while not done:
        print("Change My Face")
        mouth = "frown" ____<Fill-In>___ "smile"
        emotion = "angry" ____<Fill-In>___ "happy"
        eyes = "blue" ____<Fill-In>___ "black"
        print("1) Make me", mouth)
        print("2) Make me", emotion)
        print("3) Make my eyes", eyes)
        print("0) Quit")

        menu = eval(input("Enter a selection: "))

        if menu == 1:
            ___<Fill-In>___
        elif menu == 2:
            ___<Fill-In>___
        elif menu == 3:
            ___<Fill-In>___
        else:
            break

    print("Thanks for Playing")

    turtle.hideturtle()
    turtle.done()


main()
First, I am confused by the menu:
 
mouth = "frown" ____<Fill-In>___ "smile"
emotion = "angry" ____<Fill-In>___ "happy"
eyes = "blue" ____<Fill-In>___ "black"
I was thinking of setting a variable in my code to draw the face (like eye_color) and using if statements:
if eye_color == "blue":
     eyes = "black"
else:
    eyes = "blue"
is there a simpler way to achieve this? The way it is set up looks like I should be doing it with a partial line of code...
Reply


Messages In This Thread
Homework: Smiley Face game - by itmustbebunnies - Nov-02-2018, 04:17 PM
RE: Homework: Smiley Face game - by ichabod801 - Nov-02-2018, 05:08 PM
RE: Homework: Smiley Face game - by mogy - Jun-08-2019, 01:28 AM
RE: Homework: Smiley Face game - by Yoriz - Jun-08-2019, 08:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Face recognition system with return hostel form safwan 3 584 Jan-30-2024, 03:17 AM
Last Post: safwan
  Homework Hangman Game jagr29 3 2,395 Jan-20-2022, 10:38 PM
Last Post: deanhystad
  Which python built in library is used for face recognition? Michel_John 4 2,028 Sep-28-2021, 07:33 PM
Last Post: Underscore

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020