#๐Ÿ”’ Need help drawing robot using python turtle.

7 messages ยท Page 1 of 1 (latest)

cerulean lanceBOT
#

@frozen lodge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

frozen lodge
#

# Set up the screen
wn = turtle.Screen()
wn.bgcolor("pink")

# Create a turtle
t = turtle.Turtle()
t.speed(0)

# Function to draw a circle using turtle
def draw_circle(color, radius, x, y):
    t.penup()
    t.fillcolor(color)
    t.goto(x, y-radius)  # Adjusting the y-coordinate to center the circle
    t.pendown()
    t.begin_fill()
    t.circle(radius)
    t.end_fill()

# Function to draw a rectangle
def draw_rectangle(color, width, height, x, y):
    t.penup()
    t.fillcolor(color)
    t.goto(x, y)
    t.pendown()
    t.begin_fill()
    for _ in range(2):
        t.forward(width)
        t.left(90)
        t.forward(height)
        t.left(90)
    t.end_fill()

# Function to draw a rectangle with rotation
def draw_rectangle_rotated(color, width, height, x, y, angle):
    t.penup()
    t.fillcolor(color)
    t.goto(x, y)
    t.setheading(angle)
    t.pendown()
    t.begin_fill()
    for _ in range(2):
        t.forward(width)
        t.left(90)
        t.forward(height)
        t.left(90)
    t.end_fill()
    t.setheading(0)  
draw_circle("white", 40, 0, 150)
draw_circle("blue", 20, 0, 190)
draw_rectangle("black", 80, 100, -40, 50)
draw_rectangle_rotated("grey", 60, 20, -40, 50, -30)   # Left arm
draw_rectangle_rotated("grey", 60, 20, 40, 50, 30)    # Right arm
draw_rectangle_rotated("grey", 60, 20, -40, -50, -30)  # Left leg
draw_rectangle_rotated("grey", 60, 20, 40, -50, 30)  # Right leg
draw_circle("blue", 10, -40, 50)   # Left shoulder joint
draw_circle("blue", 10, 40, 50)    # Right shoulder joint
draw_circle("blue", 10, -70, 30)   # Left elbow joint
draw_circle("blue", 10, 70, 30)    # Right elbow joint
draw_circle("blue", 10, -40, -50)  # Left hip joint
draw_circle("blue", 10, 40, -50)   # Right hip joint
draw_circle("blue", 10, -70, -70)  # Left knee joint
draw_circle("blue", 10, 70, -70)   # Right knee joint
t.penup()
t.goto(-20, 80)  # Adjust to position the text
t.color("white")
t.write("OYO")
t.hideturtle()```
#

Output

frozen brook
#

hi @frozen lodge
nice to meet you.
i can help you.

cerulean lanceBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Need help drawing robot using python turtle.