turtle-graphics

Why are the hearts in turtle appearing slanted?

Why are the hearts in turtle appearing slanted? Question: import turtle t = turtle.Turtle() def heart(x): t.penup() t.goto(x, -100) t.pendown() t.color(‘black’,’red’) t.begin_fill() t.left(45) t.forward(100) t.circle(50, 180) t.right(90) t.circle(50, 180) t.forward(100) t.end_fill() for i in range(3): if i==1: x=-250 heart(x) elif i==2: #continue x=0 heart(x) else: #continue x=250 heart(x) t.hideturtle() turtle.done() This program is supposed to …

Total answers: 1

Why does the turtle not respond to the y border?

Why does the turtle not respond to the y border? Question: I am making a turtle game with map borders, but my turtle only works with the x borders, just skipping the y ones. Anyone can help? def gameplay(): t.forward(10) t.heading() time.sleep(0.1) sc.onkey(turnleft, "Left") sc.onkey(turnright, "Right") sc.listen() if t.distance(apple) < radius_sum: apple.goto(random.randrange(-500, 500), (random.randrange(-500, 500))) …

Total answers: 1

Third Clone Of The Turtle

Third Clone Of The Turtle Question: I made this program, when trying to make a chase game, but I stumbled along something really strange. I created a clone of the turtle, but at the middle of the map a third one appeared. Does anybody know what causes this? import turtle sc = turtle.Screen() t = …

Total answers: 1

Error: TypeError: 'list' object is not callable Using turtle graphics

Error: TypeError: 'list' object is not callable Using turtle graphics Question: I am attempting to code space invaders. I am doing some finishing touches however when trying to create three hearts in the top corner to represent lives I have this error: TypeError: ‘list’ object is not callable The relevant code in main.py is: from …

Total answers: 1

Python Turtle: how to resolve "turtle.Terminator" error?

Python Turtle: how to resolve "turtle.Terminator" error? Question: I’m beginner to python turtle module and trying to create a program that will take input from user and draw a shape according to the inputs: here is the code, import turtle shapes = [] def draw_shape(sides, size, color): turtle.color(color) for i in range(sides): turtle.forward(size) turtle.left(360/sides) while …

Total answers: 3

Drawing Basic Animations in Python

Drawing Basic Animations in Python Question: Hello I am trying to create something like this box with controllable dots I need to be able to move and interact with the dots. I have tried turtle and pyglet, but neither of them seem to do what I want them to do. Turtle is letting me create …

Total answers: 1

Why does a library class break when I try to store and use an instance (delegation) instead of making a subclass (inheritance)?

Why does a library class break when I try to store and use an instance (delegation) instead of making a subclass (inheritance)? Question: I’m making a game using the turtle standard library module for graphics. I have working code that creates a subclass of Turtle, like so: import random class Food(Turtle): def __init__(self): super().__init__() # …

Total answers: 2

How to fill color in kite using turtle

How to fill color in kite using turtle Question: I tried to create a kite using turtle in Python. I drew it correctly but it doesn’t fill in the color in all four parts. This is my code: import turtle turtle.fillcolor(‘orange’) turtle.begin_fill() turtle.goto(0,100) turtle.goto(-100,0) turtle.goto(0,0) turtle.end_fill() turtle.fillcolor(‘pink’) turtle.begin_fill() turtle.goto(100,0) turtle.goto(0,100) turtle.goto(0,-100) turtle.end_fill() turtle.fillcolor(‘black’) turtle.begin_fill() turtle.goto(-100,0) …

Total answers: 1

Why is the turtle offset?

Why is the turtle offset? Question: I am trying to create a program to move the turtle to where the mouse is. Right now I am doing: import turtle t = turtle.Turtle() canvas = turtle.getcanvas() width = canvas.winfo_width() height = canvas.winfo_height() midpointX = width / 2 midpointY = height / 2 t.speed(0) while True: mouseX, …

Total answers: 1