[Python3 + turtle] = Dibujo de Pacman

Iniciado por reconFito, 17 Marzo 2020, 04:41 AM

0 Miembros y 1 Visitante están viendo este tema.

reconFito

Código (python) [Seleccionar]

from turtle import Turtle, Screen

width = 600
height = 600
X = width - 10
Y = height - 10


def _turtle():
    # Pantalla
    pantalla = Screen()
    pantalla.title("Pacman")
    pantalla.bgcolor("#254555")
    pantalla.setup(width=width, height=height)
    pantalla.colormode(255)
    pantalla.screensize(X, Y)
    pantalla.delay(0)

    # Tortuga
    turtle = Turtle()
    turtle.pensize(2)
    turtle.hideturtle()
    turtle.speed(0)
    turtle.pu()
    turtle.goto(-X/2, Y/2)
    turtle.pd()
    turtle.pencolor("#212140")
    for i in range(91):
        turtle.setheading(-i)
        turtle.fd(width/2)
        turtle.bk(width/2)
    turtle.pu()
    turtle.goto(X/2, Y/2)
    turtle.pd()
    for i in range(91):
        turtle.setheading(i)
        turtle.fd(-width/2)
        turtle.bk(-width/2)

    turtle.pu()
    turtle.goto(-X/2, -Y/2)
    turtle.pd()
    for i in range(91):
        turtle.setheading(i)
        turtle.fd(width/2)
        turtle.bk(width/2)

    turtle.pu()
    turtle.goto(X/2, -Y/2)
    turtle.pd()
    for i in range(91):
        turtle.setheading(-i)
        turtle.fd(-width/2)
        turtle.bk(-width/2)
    turtle.pu()
    turtle.home()
    turtle.pd()
    for i in range(round(width/2)):
        turtle.pencolor("#cfbb00")
        turtle.setheading(-i)
        turtle.fd(90)
        turtle.bk(90)

    turtle.pu()
    turtle.goto(-10, 45)
    turtle.color("#001020")
    turtle.pd()
    turtle.begin_fill()
    turtle.circle(10)
    turtle.end_fill()

    pantalla.exitonclick()


_turtle()