python-turtle

Calling same function by different objects by pressing different key in python

Calling same function by different objects by pressing different key in python Question: I have created two turtles say ‘tur1’ and ‘tur2’ in python using turtle module. I have created event listener on the screen. I have created a function ‘move_fwd(turte_name)’ which moves the turtle forward by 20 steps. I want that if key ‘w’ …

Total answers: 4

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

Turtle Colision

Turtle Colision Question: I am making a game using the turtle module, and want to detect colision betwen the original and the clone.I have tried saving the position of the clone, and then checking if the original has the same position, but the turtle only detects the clone if it has the exacly same position. …

Total answers: 2

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