Beispiel #1
0
    def create_player_shapes(self, color: str = 'black') -> None:
        """Creates custom turtle shapes for the x and o player markers.

        This method sets up custom shapes that can be used with the
        turtle.shape() method. Recall that you could make your turtle look
        like an actual turtle (instead of the default arrow shape) by calling
        turtle.shape('turtle'). After this method has been called, you can
        change the sape of your turtle to an x or an o by calling
        turtle.shape('x marker') or turtle.shape('o marker').

        These shapes are initialized at a size appropriate for display on a
        3x3 grid on a 300px game board.
        """

        # Build the x out of a backslash and forward slash.
        # These numbers are the vertices of the slashes.
        backslash = ((-25,-25), (25,25))
        forwardslash = ((-25,25), (25,-25))
        shape = Shape('compound')
        shape.addcomponent(backslash, '', color)
        shape.addcomponent(forwardslash, '', color)
        self.screen.register_shape('x marker', shape)

        # Approximate the o with a 20-sided polygon.
        # These numbers are the vertices of the polygon.
        circle = (( 00.00,-25.00), ( 07.73,-23.78), ( 14.69,-20.23),
                  ( 20.23,-14.69), ( 23.78,-07.73), ( 25.00, 00.00),
                  ( 23.78, 07.73), ( 20.23, 14.69), ( 14.69, 20.23),
                  ( 07.73, 23.78), ( 00.00, 25.00), (-07.73, 23.78),
                  (-14.69, 20.23), (-20.23, 14.69), (-23.78, 07.73),
                  (-25.00, 00.00), (-23.78,-07.73), (-20.23,-14.69),
                  (-14.69,-20.23), (-07.73,-23.78),)
        shape = Shape('compound')
        shape.addcomponent(circle, '', color)
        self.screen.register_shape('o marker', shape)
Beispiel #2
0
    def __init__(self, fen, color, nom, taille):
        """Initialise l'instance de monstre"""
        super().__init__(fen)
        self.right(90)
        self.nom = nom
        self.taille = taille / 25  # taille du sprite

        fantomee = Shape('compound')
        fantomee.addcomponent(fantomeCorps, color)
        fantomee.addcomponent(fantomeOeilG, 'white')
        fantomee.addcomponent(fantomeOeilD, 'white')
        fantomee.addcomponent
        (tuple((x + 1, y) for x, y in fantomePupilleG), 'blue')
        fantomee.addcomponent
        (tuple((x + 1, y) for x, y in fantomePupilleD), 'blue')

        fantomeo = Shape('compound')
        fantomeo.addcomponent(fantomeCorps, color)
        fantomeo.addcomponent(fantomeOeilG, 'white')
        fantomeo.addcomponent(fantomeOeilD, 'white')
        fantomeo.addcomponent
        (tuple((x - 1, y) for x, y in fantomePupilleG), 'blue')
        fantomeo.addcomponent
        (tuple((x - 1, y) for x, y in fantomePupilleD), 'blue')

        fantomen = Shape('compound')
        fantomen.addcomponent(fantomeCorps, color)
        fantomen.addcomponent(fantomeOeilG, 'white')
        fantomen.addcomponent(fantomeOeilD, 'white')
        fantomen.addcomponent
        (tuple((x, y + 2) for x, y in fantomePupilleG), 'blue')
        fantomen.addcomponent
        (tuple((x, y + 2) for x, y in fantomePupilleD), 'blue')

        fantomes = Shape('compound')
        fantomes.addcomponent(fantomeCorps, color)
        fantomes.addcomponent(fantomeOeilG, 'white')
        fantomes.addcomponent(fantomeOeilD, 'white')
        fantomes.addcomponent
        (tuple((x, y - 1) for x, y in fantomePupilleG), 'blue')
        fantomes.addcomponent
        (tuple((x, y - 1) for x, y in fantomePupilleD), 'blue')

        fen.register_shape(self.nom + 'est', fantomee)
        fen.register_shape(self.nom + 'ouest', fantomeo)
        fen.register_shape(self.nom + 'nord', fantomen)
        fen.register_shape(self.nom + 'sud', fantomes)
        self.orienter('est')
        self.shapesize(self.taille, self.taille)
def main():
    screen = Screen()
    screen.setup(width=1.0, height=1.0) # for fullscreen
    screen.bgcolor('black')
    screen.title("Apollo 8 Free Return Simulation")
    gravsys = GravSys()

    image_earth = 'earth_100x100.gif'
    screen.register_shape(image_earth)
    earth = Body(1000000, (0, -25), Vec(0,-2.5), gravsys, image_earth)
    earth.pencolor('white')
    earth.getscreen().tracer(n=0, delay=0)

    image_moon = 'moon_27x27.gif'
    screen.register_shape(image_moon)
    moon = Body(32000, (344, 42), Vec(-27, 147), gravsys, image_moon)
    moon.pencolor('gray')

    csm = Shape('compound')
    cm = ((0, 30), (0, -30), (30, 0))
    csm.addcomponent(cm, 'white', 'white')
    sm = ((-60, 30), (0, 30), (0, -30), (-60, -30))
    csm.addcomponent(sm, 'white', 'black')  
    nozzle = ((-55, 0), (-90, 20), (-90, -20))
    csm.addcomponent(nozzle, 'white', 'white')
    screen.register_shape('csm', csm)

    ship = Body(1, (Ro_X, Ro_Y), Vec(Vo_X, Vo_Y), gravsys, 'csm')
    ship.shapesize(0.2)
    ship.color('white')
    ship.getscreen().tracer(1,0)
    ship.setheading(90)

    gravsys.sim_loop()
    input()
Beispiel #4
0
 def __init__(self, color, x, y):
     self.color = color
     self.t = Turtle(shape='circle')
     self.t.penup()
     self.xpos = x
     self.ypos = y
     self.f = Shape('compound')
Beispiel #5
0
def main():
    # Setup screen
    screen = Screen()
    screen.setup(width=1.0, height=1.0)  # for fullscreen
    screen.bgcolor('black')
    screen.title("Gravity Assist Example")

    # Instantiate gravitational system
    gravsys = GravSys()

    # Instantiate Planet
    image_moon = 'moon_27x27.gif'
    screen.register_shape(image_moon)
    moon = Body(MOON_MASS, (500, 0), Vec(-500, 0), gravsys, image_moon)
    moon.pencolor('gray')

    # Build command-service-module (csm) shape
    csm = Shape('compound')
    cm = ((0, 30), (0, -30), (30, 0))
    csm.addcomponent(cm, 'red', 'red')
    sm = ((-60, 30), (0, 30), (0, -30), (-60, -30))
    csm.addcomponent(sm, 'red', 'black')
    nozzle = ((-55, 0), (-90, 20), (-90, -20))
    csm.addcomponent(nozzle, 'red', 'red')
    screen.register_shape('csm', csm)

    # Instantiate Apollo 8 CSM turtle
    ship = Body(1, (Ro_X, Ro_Y), Vec(Vo_X, Vo_Y), gravsys, "csm")
    ship.shapesize(0.2)
    ship.color('red')  # path color
    ship.getscreen().tracer(1, 0)
    ship.setheading(90)

    gravsys.sim_loop()
Beispiel #6
0
def main():
    s = Turtle()
    s.reset()
    s.getscreen().tracer(0, 0)
    s.ht()
    s.pu()
    s.fd(6)
    s.lt(90)
    s.begin_poly()
    s.circle(6, 180)
    s.end_poly()
    m1 = s.get_poly()
    s.begin_poly()
    s.circle(6, 180)
    s.end_poly()
    m2 = s.get_poly()
    planetshape = Shape('compound')
    planetshape.addcomponent(m1, 'orange')
    planetshape.addcomponent(m2, 'blue')
    s.getscreen().register_shape('planet', planetshape)
    s.getscreen().tracer(1, 0)
    gs = GravSys()
    sun = Star(1000000, Vec(0, 0), Vec(0, -2.5), gs, 'circle')
    sun.color('yellow')
    sun.shapesize(1.8)
    sun.pu()
    earth = Star(12500, Vec(210, 0), Vec(0, 195), gs, 'planet')
    earth.pencolor('green')
    earth.shapesize(0.8)
    moon = Star(1, Vec(220, 0), Vec(0, 295), gs, 'planet')
    moon.pencolor('blue')
    moon.shapesize(0.5)
    gs.init()
    gs.start()
    return 'Done!'
 def __init__(self):
     turtle.Turtle.__init__(self)
     goal = PhotoImage(file="images/goal.png").zoom(1, 1)
     myscreen.addshape("goal", Shape("image", goal))
     self.shape("goal")
     self.penup()
     self.speed(0)
Beispiel #8
0
 def make_paddle_shape(paddle_width_half, paddle_height_half):
     paddle_shape = Shape(
         "compound")  # Compound need to make more complex shape.
     # Add points to new shape.
     paddle_points = ((-paddle_height_half, -paddle_width_half),
                      (-paddle_height_half, paddle_width_half),
                      (paddle_height_half, paddle_width_half),
                      (paddle_height_half, -paddle_width_half))
     # Add points and set color.
     paddle_shape.addcomponent(paddle_points, "black")
     return paddle_shape
Beispiel #9
0
    def __init__(self, fen, color, nom, taille):
        """Initialise correctement la tortue"""
        super().__init__(fen)
        self.deplacer((3, 3))  # enlever après
        pacman = Shape('polygon', corps)
        self.right(90)

        self.taille = taille / 25
        self.nom = nom
        fen.register_shape('j' + self.nom, pacman)
        self.color(color)
        self.orienter('est')
        self.shapesize(self.taille, self.taille)
        self.shape('j' + self.nom)
def main():
    ## create compound yellow/blue turtleshape for planets
    global s
    s = Screen()
    s.setup(1120, 840)
    s.reset()
    s.tracer(0, 0)
    t = Turtle()
    t.ht()
    t.pu()
    t.fd(6)
    t.lt(90)

    t.begin_poly()
    t.circle(6, 180)
    t.end_poly()
    m1 = t.get_poly()

    t.begin_poly()
    t.circle(6, 180)
    t.end_poly()
    m2 = t.get_poly()

    planetshape = Shape("compound")
    planetshape.addcomponent(m1, "orange")
    planetshape.addcomponent(m2, "blue")
    s.register_shape("planet", planetshape)
    s.update()
    ## setup gravitational system
    gs = GravSys()
    sun = Star(1000000, Vec(-250, 0), Vec(0, -0.35), gs, "circle")
    sun.color("yellow")
    sun.pensize(1.8)
    sun.pu()
    earth = Star(5000, Vec(450, 0), Vec(0, 70), gs, "planet")
    earth.pencolor("green")
    earth.shapesize(0.8)

    rm = 12.0583
    vm = (8.0 * 5000 / rm)**.5
    moon = Star(1, Vec(450 + rm, 0), Vec(0, 70 + vm), gs, "planet")
    moon.pencolor("blue")
    moon.shapesize(0.5)
    gs.init()
    gs.start()
    s.tracer(True)
    return "Done!"
def main():
    # Setup screen
    screen = Screen()
    screen.setup(width=1.0, height=1.0)  # For fullscreen.
    screen.bgcolor('black')
    screen.title("Apollo 8 Free Return Simulation")

    # Instantiate gravitational system
    gravsys = GravSys()

    # Instantiate Earth turtle
    #image_earth = 'earth_100x100.gif'
    #screen.register_shape(image_earth)
    t = Turtle()
    screen.register_shape('earth', drawCircle(6.371, 72, t))
    earth = Body(1000000, (-200, 0), Vec(0, -2.5), gravsys, 'earth')
    earth.pencolor('white')
    earth.fillcolor('white')
    earth.getscreen().tracer(0, 0)  # So csm polys won't show while drawing.

    # Instantiate moon turtle
    #image_moon = 'moon_27x27.gif'
    #screen.register_shape(image_moon)
    #moon_circle = circle(1.737)
    screen.register_shape('moon', drawCircle(1.737, 72, t))
    moon = Body(32000, (156.7, 0), Vec(-27, 147), gravsys, 'moon')
    moon.pencolor('gray')
    moon.fillcolor('gray')

    # Build command-service-module(csm)shape
    csm = Shape('compound')
    cm = ((0, 0.1), (0, -0.1), (0.1, 0))
    csm.addcomponent(cm, 'Silver', 'red')  # Silver and red are also good.
    screen.register_shape('csm', csm)

    # Instantiate Apollo 8 CSM turtle
    ship = Body(1, (Ro_X, Ro_Y), Vec(Vo_X, Vo_Y), gravsys, 'csm')
    ship.shapesize(0.1)
    ship.color('white')  # Path color. Silver and red are also good.
    ship.getscreen().tracer(1, 0)
    ship.setheading(90)

    gravsys.sim_loop()

    screen.bye()  #close window automatically
Beispiel #12
0
def __drawEyeBrows():
    __startFunction()
    eyebrows = Shape("compound")

    #draw Left eye Brow
    turtle.begin_poly()
    turtle.penup()
    turtle.goto(-80, 0)
    turtle.left(5)
    turtle.pendown()
    turtle.fd(15)
    turtle.left(90)
    turtle.fd(5)
    turtle.left(90)
    turtle.fd(30)
    turtle.left(90)
    turtle.fd(5)
    turtle.left(90)
    turtle.fd(15)
    turtle.end_poly()
    leftbro = turtle.get_poly()
    eyebrows.addcomponent(leftbro, "black", "cyan")

    #draw Right Eye Borw
    turtle.penup()
    turtle.right(5)
    turtle.goto(80, 0)
    turtle.begin_poly()
    turtle.left(180)
    turtle.right(5)
    turtle.fd(15)
    turtle.right(90)
    turtle.fd(5)
    turtle.right(90)
    turtle.fd(30)
    turtle.right(90)
    turtle.fd(5)
    turtle.right(90)
    turtle.fd(15)
    turtle.end_poly()
    rightbro = turtle.get_poly()
    eyebrows.addcomponent(rightbro, "black", "cyan")
    screen.addshape("EyeBrows", eyebrows)
    __drawEndFunction()
def main():
    # Setup screen
    screen = Screen()
    screen.setup(width=1.0, height=1.0)  # For fullscreen.
    screen.bgcolor('black')
    screen.title("Apollo 8 Free Return Simulation")

    # Instantiate gravitational system
    gravsys = GravSys()

    # Instantiate Earth turtle
    image_earth = 'earth_100x100.gif'
    screen.register_shape(image_earth)
    earth = Body(1000000, (0, -25), Vec(0, -2.5), gravsys, image_earth)
    earth.pencolor('white')
    earth.getscreen().tracer(0, 0)  # So csm polys won't show while drawing.

    # Instantiate moon turtle
    image_moon = 'moon_27x27.gif'
    screen.register_shape(image_moon)
    moon = Body(32000, (344, 42), Vec(-27, 147), gravsys, image_moon)
    moon.pencolor('gray')

    # Build command-service-module(csm)shape
    csm = Shape('compound')
    cm = ((0, 30), (0, -30), (30, 0))
    csm.addcomponent(cm, 'white', 'white')  # Silver and red are also good.
    sm = ((-60, 30), (0, 30), (0, -30), (-60, -30))
    csm.addcomponent(sm, 'white', 'black')
    nozzle = ((-55, 0), (-90, 20), (-90, -20))
    csm.addcomponent(nozzle, 'white', 'white')
    screen.register_shape('csm', csm)

    # Instantiate Apollo 8 CSM turtle
    ship = Body(1, (Ro_X, Ro_Y), Vec(Vo_X, Vo_Y), gravsys, 'csm')
    ship.shapesize(0.2)
    ship.color('white')  # Path color. Silver and red are also good.
    ship.getscreen().tracer(1, 0)
    ship.setheading(90)

    gravsys.sim_loop()
def createPlanetShape():
    s.tracer(0,0)
    t = Turtle()
    t.ht()
    t.pu()
    t.fd(6)
    t.lt(90)
    t.begin_poly()
    t.circle(6, 180)
    t.end_poly()
    m1 = t.get_poly()
    t.begin_poly()
    t.circle(6,180)
    t.end_poly()
    m2 = t.get_poly()

    planetshape = Shape("compound")
    planetshape.addcomponent(m1,"orange")
    planetshape.addcomponent(m2,"blue")
    s.register_shape("planet", planetshape)
    s.tracer(True,0)
Beispiel #15
0
def main():
    s = Turtle()
    s.reset()
    s.getscreen().tracer(0,0)
    s.ht()
    s.pu()
    s.fd(6)
    s.lt(90)
    s.begin_poly()
    s.circle(6, 180)
    s.end_poly()
    m1 = s.get_poly()
    s.begin_poly()
    s.circle(6,180)
    s.end_poly()
    m2 = s.get_poly()

    planetshape = Shape("compound")
    planetshape.addcomponent(m1,"orange")
    planetshape.addcomponent(m2,"blue")
    s.getscreen().register_shape("planet", planetshape)
    s.getscreen().tracer(1,0)

    ## setup gravitational system
    gs = GravSys()
    sun = Star(1000000, Vec(0,0), Vec(0,-2.5), gs, "circle")
    sun.color("yellow")
    sun.shapesize(1.8)
    sun.pu()
    earth = Star(12500, Vec(210,0), Vec(0,195), gs, "planet")
    earth.pencolor("green")
    earth.shapesize(0.8)
    moon = Star(1, Vec(220,0), Vec(0,295), gs, "planet")
    moon.pencolor("blue")
    moon.shapesize(0.5)
    gs.init()
    gs.start()
    return "Done!"
Beispiel #16
0
    def dibuja_estrella(self, lapiz):
        '''
        Define una figura de estrella como el lapiz que dibujará
        '''

        fig = Shape("compound")
        lapiz.setx(0)
        lapiz.sety(4)

        lapiz.begin_poly()
        lapiz.goto(1, 1)
        lapiz.goto(3.5, 1)
        lapiz.goto(1.5, -0.5)
        lapiz.goto(2.5, -3)
        lapiz.goto(0, 1.5)
        lapiz.goto(-2.5, -3)
        lapiz.goto(-1.5, -0.5)
        lapiz.goto(-3.5, 1)
        lapiz.goto(-1, 1)
        lapiz.end_poly()

        fig.addcomponent(lapiz.get_poly(), "purple", "purple")
        self.screen.register_shape("estrella", fig)
        lapiz.reset()
Beispiel #17
0
area.penup()
area.goto(play_right, play_top)
area.pendown()
area.goto(play_left, play_top)
area.goto(play_left, play_bottom)
area.goto(play_right, play_bottom)
area.goto(play_right, play_top)
# PADDLES
L = Turtle()
R = Turtle()
L.penup()
R.penup()
# Paddles shape
paddle_w_half = 10 / 2  # 10 units wide
paddle_h_half = 40 / 2  # 40 units high
paddle_shape = Shape("compound")
paddle_points = ((-paddle_h_half, -paddle_w_half), (-paddle_h_half,
                                                    paddle_w_half),
                 (paddle_h_half, paddle_w_half), (paddle_h_half,
                                                  -paddle_w_half))
paddle_shape.addcomponent(paddle_points, "black")
screen.register_shape("paddle", paddle_shape)
L.shape("paddle")
R.shape("paddle")
# Move paddles into position
L.setx(play_left + 10)
R.setx(play_right - 10)
paddle_L_move_direction = 0  # L paddle movement direction in next frame
paddle_R_move_direction = 0  # R paddle movement direction in next frame
paddle_move_vert = 4  # Vertical movement distance per frame
Beispiel #18
0
# Create variable score
score = 0

# Create player turtle
player = turtle.Turtle()
#player.color('Teal')
#player.shape('turtle')
#player.penup()
#player.speed(0)

beeimage = "bee.gif"
#wn.addshape(beeimage)
#player.shape(beeimage)
smallerBee = PhotoImage(file="bee.gif").subsample(10, 10)
wn.addshape("smaller", Shape("image", smallerBee))
player = Turtle("smaller")
player.penup()
player.speed(0)

# Create opponent turtle
comp = turtle.Turtle()
comp.color('black')
comp.shape('turtle')
comp.penup()
comp.setposition(random.randint(-290, 290), random.randint(-290, 290))

# Create food
maxFoods = 20
foods = []
for count in range(maxFoods):
score_pen = turtle.Turtle()
score_pen.speed(0)
score_pen.color('white')
score_pen.penup()
score_pen.setposition(-290, 280)
scorestring = "Score: %s" % score
score_pen.write(scorestring,
                False,
                align='left',
                font=("Times New Roman", 14, 'normal'))
score_pen.hideturtle()

player = turtle.Turtle()
smallerPlayer = PhotoImage(file='boris.gif').subsample(3, 3)
window.addshape('larger', Shape('image', smallerPlayer))
player.shape('larger')
player.penup()
player.speed(0)
player.setposition(0, -250)
player.setheading(90)

playerspeed = 15

enemies = 10
enemies_list = []

for i in range(enemies):
    enemies_list.append(turtle.Turtle())

for enemy in enemies_list:
Beispiel #20
0
def __drawEyes():
    __startFunction()

    #draw the eye when opened with mid cornea
    openeyes1 = Shape("compound")
    turtle.begin_poly()
    turtle.goto(-80, 0)
    turtle.pendown()
    turtle.circle(15)
    turtle.penup()
    turtle.end_poly()
    lefteye1 = turtle.get_poly()
    openeyes1.addcomponent(lefteye1, "black", "cyan")
    turtle.begin_poly()
    turtle.goto(80, 0)
    turtle.pendown()
    turtle.circle(15)
    turtle.penup()
    turtle.end_poly()
    righteye1 = turtle.get_poly()
    openeyes1.addcomponent(righteye1, "black", "cyan")

    #place the cornea mid the openedeyes
    turtle.begin_poly()
    turtle.penup()
    turtle.goto(-80, 0)
    turtle.pendown()
    turtle.circle(8)
    turtle.penup()
    turtle.end_poly()
    leftcornea1 = turtle.get_poly()
    openeyes1.addcomponent(leftcornea1, "cyan", "cyan")
    turtle.begin_poly()
    turtle.penup()
    turtle.goto(80, 0)
    turtle.pendown()
    turtle.circle(8)
    turtle.penup()
    turtle.end_poly()
    rightcornea1 = turtle.get_poly()
    openeyes1.addcomponent(rightcornea1, "cyan", "cyan")
    screen.addshape("OpenedEyesM", openeyes1)

    # draw the eye when opened with left cornea
    openeyes2 = Shape("compound")
    turtle.begin_poly()
    turtle.goto(-80, 0)
    turtle.pendown()
    turtle.circle(15)
    turtle.penup()
    turtle.end_poly()
    lefteye2 = turtle.get_poly()
    openeyes2.addcomponent(lefteye2, "black", "cyan")
    turtle.begin_poly()
    turtle.goto(80, 0)
    turtle.pendown()
    turtle.circle(15)
    turtle.penup()
    turtle.end_poly()
    righteye2 = turtle.get_poly()
    openeyes2.addcomponent(righteye2, "black", "cyan")

    # place the cornea left the openedeyes
    turtle.begin_poly()
    turtle.penup()
    turtle.goto(-83, 0)
    turtle.pendown()
    turtle.circle(8)
    turtle.penup()
    turtle.end_poly()
    leftcornea2 = turtle.get_poly()
    openeyes2.addcomponent(leftcornea2, "cyan", "cyan")
    turtle.begin_poly()
    turtle.penup()
    turtle.goto(77, 0)
    turtle.pendown()
    turtle.circle(8)
    turtle.penup()
    turtle.end_poly()
    rightcornea2 = turtle.get_poly()
    openeyes2.addcomponent(rightcornea2, "cyan", "cyan")
    screen.addshape("OpenedEyesL", openeyes2)

    # draw the eye when opened with Right cornea
    openeyes3 = Shape("compound")
    turtle.begin_poly()
    turtle.goto(-80, 0)
    turtle.pendown()
    turtle.circle(15)
    turtle.penup()
    turtle.end_poly()
    lefteye3 = turtle.get_poly()
    openeyes3.addcomponent(lefteye3, "black", "cyan")
    turtle.begin_poly()
    turtle.goto(80, 0)
    turtle.pendown()
    turtle.circle(15)
    turtle.penup()
    turtle.end_poly()
    righteye3 = turtle.get_poly()
    openeyes3.addcomponent(righteye3, "black", "cyan")

    # place the cornea Right the openedeyes
    turtle.begin_poly()
    turtle.penup()
    turtle.goto(-77, 0)
    turtle.pendown()
    turtle.circle(8)
    turtle.penup()
    turtle.end_poly()
    leftcornea3 = turtle.get_poly()
    openeyes3.addcomponent(leftcornea3, "cyan", "cyan")
    turtle.begin_poly()
    turtle.penup()
    turtle.goto(83, 0)
    turtle.pendown()
    turtle.circle(8)
    turtle.penup()
    turtle.end_poly()
    rightcornea3 = turtle.get_poly()
    openeyes3.addcomponent(rightcornea3, "cyan", "cyan")
    screen.addshape("OpenedEyesR", openeyes3)

    #draw the eye when closed
    closeeyes = Shape("compound")
    turtle.begin_poly()
    turtle.goto(-80, 0)
    turtle.pendown()
    turtle.fd(28)
    turtle.left(90)
    turtle.fd(2)
    turtle.left(90)
    turtle.fd(28)
    turtle.left(90)
    turtle.fd(2)
    turtle.end_poly()
    leftcloseeye = turtle.get_poly()
    closeeyes.addcomponent(leftcloseeye, "black", "cyan")
    turtle.penup()
    turtle.begin_poly()
    turtle.goto(80, 0)
    turtle.pendown()
    turtle.left(90)
    turtle.fd(28)
    turtle.left(90)
    turtle.fd(2)
    turtle.left(90)
    turtle.fd(28)
    turtle.left(90)
    turtle.fd(2)
    turtle.end_poly()
    rightcloseeye = turtle.get_poly()
    closeeyes.addcomponent(rightcloseeye, "black", "cyan")
    screen.addshape("ClosedEyes", closeeyes)

    __drawEndFunction()
#initialisering, setter "vindu" konfigurasjon.
eksempel = turtle.Screen()
#eksempel.screensize(500, 500)
eksempel.setup(1000, 1000)                        #alternativ konfigurasjon av stage (arbeidsflate)
eksempel.title("Eks. 364, sett inn bilde.")

#eksempel.bgpic("./turtlelpg.png")

#initialisering, definerer hvor turtle starter, farge, hastighet mv.
figur = Turtle("turtle")
figur.hideturtle()
figur.penup()
figur.setposition(-200, -200)     # Starter i "Origo", for Turtle er det  midt i skjermen. 

#Same size as imported image:
#eksempel.addshape(name="./bilder/Solbergfoss_photo3364_200x150.gif",shape=None)
#figur.shape("spaceship.gif")

#Bigger image,resize:
larger = PhotoImage(file="./turtlelpg.png").zoom(3, 3)
eksempel.addshape("larger", Shape("image", larger))
figur.shape("larger")

#Lesser image, resize:
#lesser = PhotoImage(file="./turtlelpg.png").subsample(5, 5)
#eksempel.addshape("lesser", Shape("image", lesser))
#figur.shape("lesser")
figur.showturtle()

eksempel.mainloop()