1,622 questions
-1
votes
3
answers
189
views
My code gets stuck at the end of the prepare_for_answer function. Is there something really obvious I'm missing?
from turtle import *
import random
import time
#making the main 8-ball
def main_8_ball():
#used to be the main drawing, not needed
write("8", font=('Arial',24,'normal'))
...
0
votes
1
answer
84
views
How to I get the positions for the corners of a turtle screen embeded in a tkinter canvas
I'm trying to draw a grid in the turtle, but doing so requires knowing the positions of the corners of the screen.
turtle.goto(0, 0) does not move the turtle to the middle of the screen; instead, it ...
-1
votes
4
answers
96
views
trinket.io TypeError "unexpected keyword argument 'shape'"
I'm trying to move pieces of a high school comp sci project to trinket and I keep getting the following error:
TypeError: <native JS>() got an unexpected keyword argument 'shape' on line __ in ...
0
votes
1
answer
128
views
Thonny turtle frozen screen in Thonny
When trying to write different functions with the turtle module in Thonny, my screen froze. I've been trying to find out why, but haven't had any luck with it.
It's a simple code, so I'm unsure what ...
-5
votes
1
answer
110
views
How can I move the blue turtle to x = 280 using repeated upward semicircular ‘hops’ in Python turtle? [closed]
I’m building a turtle race. I want the blue turtle to move to x=280 by repeating this pattern:
draw a downward semicircle (“bowl”)
then a short straight stride to the right
repeat until it reaches ...
0
votes
1
answer
175
views
I need another way to fill a shape other than begin_fill() and end_fill()
I want to know if Python Turtle has a fill option other than begin_fill() and end_fill(), because my project is to draw Spongebob. Spongebob's body has fractions of ovals on its borders, so I ...
4
votes
1
answer
66
views
Turtle not detecting key presses in Python [duplicate]
Here is a HUGELY simplified version of my code:
from turtle import Turtle, Screen
import time
speed_x = 20
speed_y = 29
def move_right():
print('exectuted')
def game_loop():
ball.goto(ball....
1
vote
1
answer
22
views
Turtle pauses when I try to turn it
Here is my code:
from turtle import Turtle, Screen
import time
import random
def check_wall_collision():
if ball.xcor() > (window.window_width() / 2) - 20 or ball.xcor() < -(window....
0
votes
1
answer
81
views
Distinguishing callbacks for different events when using the same function
I am coding minesweeper in python turtle. I have made it generate 10x10 button layout using this script:
position_x = -400
position_y = -200
number_colum = 0
rows_buttons = []
for i in range(10):
...
-1
votes
2
answers
72
views
Issue with entering data python
I'm working on a silly page for my friends, however when the code askes for user input I am incapable of entering any data. How can I possibly fix this?
# import the turtle module
import turtle as ...
0
votes
1
answer
107
views
Why can't I see the image equally spaced to the right with python turtle?
I'm trying to create the Breakout game with python's turtle module, but for something I haven't yet identified I can't center the image correctly!
from turtle import Turtle
class Game():
def ...
0
votes
1
answer
68
views
Turtle - screen.update() not working with copy method?
I have a list with several turtle instances. I want to create a copy of one object and let this one move forward.
This works fine. But when I disable screen udpates and do it manually in my code it ...
-1
votes
1
answer
67
views
Im having problems running 2 functions at the same time [duplicate]
Im a coding beginner who just got into python turtle. I have recently been working on a project where you control 2 characters. They are trying to shoot each other over a river. But i ran into an ...
0
votes
1
answer
52
views
How can I make the rate at which obstacles are created proportionate to the movement speed of the obstacles?
I'm making a game similar to Subway Surfers where there are 3 lanes and obstacles come at the player. The obstacles move faster and score goes up every 16th time the game loop is repeated. That all ...
2
votes
2
answers
168
views
Tkinter With Turtle
I was creating a tkinter/turtle program similar to MS paint and I have the barebones Turtle finished but I am unsure of how to add the turtle into tkinter as a sort of window (Having the tkinter as ...
-3
votes
1
answer
165
views
Is there any practical use for the turtle module in Python? [closed]
Is there any practical use for the turtle module in Python? It is good for practicing graphics, but is that all the module is good for? It's objectively slow, yet new versions of Python continue to ...
4
votes
2
answers
103
views
Bullets shooting from wrong position after player moved in small "Space Invaders" game
I'm a beginner in Python and trying to code a game such as Space Invaders.
I created everything but when I move my character and fire, the bullet will remain shooting from the character's original ...
0
votes
0
answers
106
views
Enhancing turtle graphics in a custom tk window
I'm trying to use my own Tk window for my turtle interface so that I can add Tk widgets to my turtle program. It's a very simple program where you can draw with the turtle pen. However, I want to have ...
-1
votes
1
answer
64
views
When I run the code, the car instance of Car spawns at a y-coord below the player and off the screen size. How do i fix this bug?
I'm making a crossy game from 100 Days of code, except I'm making it from scratch since I don't have the recommended IDE(Pycharm) I used randrange to get an integer instead of randint because I'm ...
2
votes
1
answer
114
views
Turtle snake chain project
Below is a Python code for my "Snake Project" (with Turtle and Tkinter).
The purpose of this program is to create a chain of turtles, called followers, that follow each other, with the first ...
0
votes
0
answers
25
views
Python Colab Turtle Tic Tac Toe drawing circles off centre for no reason [duplicate]
def square(x):
for i in range(4):
allmight.pendown()
allmight.forward(x)
allmight.right(90)
def nextshape(jump):
allmight.penup()
allmight.forward(jump)
allmight.pendown()
def ...
0
votes
1
answer
101
views
not getting the final score... python turtle coding
When I try run this code, everything seems to work but when getting the final score, I don't get a score as it only appears blank.
#!/usr/bin/env python3
import json #this is to load the files of from ...
0
votes
2
answers
91
views
AttributeError: 'Turtle' object has no attribute 'turtlesize' on line 23 in main.py
import turtle
drawTurtle = turtle.Turtle()
drawTurtle.shape("turtle")
drawTurtle.speed(500)
drawTurtle.hideturtle()
drawTurtle.penup()
drawTurtle.goto(180,65)
drawTurtle.pendown()
...
0
votes
1
answer
66
views
How can you prevent the holding down of a key in Python turtle?
I am trying to make a game with 2 turtles that move in Python Turtle. I have used the onkey() command to make the turtles move. I want to make them move at the same time because the game is kind of ...
-3
votes
1
answer
71
views
How to make listen() wait between inputs? [duplicate]
So I have a movement script for my turtle (called mc)
from turtle import *
wn = Screen()
MC=Turtle()
def w():
mc.shape(FFM1)
mc.forward(40)
mc.shape(FFM2)
mc.forward(40)
mc.shape(...
0
votes
0
answers
68
views
How to make listen only do 1 command at once?
So I have a movement script for my turtle (called mc)
from turtle import *
def w():
mc.shape(FFM1)
mc.forward(40)
mc.shape(FFM2)
mc.forward(40)
mc.shape(FFS)
def s():
mc....
1
vote
2
answers
356
views
How do I make a waterdrop shape using turtle in python?
Here is my code:
import turtle
t = turtle.Turtle()
t.width(5)
t.right(112.5)
t.forward(100)
t.circle(50, 225)
t.forward(100)
t.hideturtle()
It almost makes the correct shape, but the two points at ...
0
votes
1
answer
95
views
Save image with Python Turtle Graphics?
I have been trying to create and export an image with python turtle graphics, and I am using turtle.getscreen().getcanvas().postscript(name="foo.esp") to export it (found here). When I call ...
-1
votes
1
answer
63
views
How can i fix the error - "Bad Colour Sequence" from line 31?
I am making a Python Turtle project that will let me input 3 colour values which then get used as a colour for a circle, then it should print the rgb values of the colour and the hex values in the ...
1
vote
1
answer
30
views
Return current angle of turtle in Python?
How can I get the current angle of the turtle?
I need to check if the turtle is facing east or west (positive or negative) to make a DVD Video Screensaver.
I've looked through every turtle function ...
0
votes
4
answers
104
views
How do I find the shortest way to make a pattern using turtle in Python?
Here is a pattern that I made:
import turtle
t = turtle.Turtle()
for i in range(4):
t.forward(150)
t.right(90)
t.forward(50)
t.right(90)
t.forward(100)
t.backward(50)
t.left(90)
t.forward(...
0
votes
1
answer
106
views
Turtle writing rotated text, but writes additional text
I found helpful posts on this site on how to get a Python turtle to write rotated text by using the create_text() method in the tkinter Canvas object. The turtle is writing exactly what I want but it'...
4
votes
3
answers
122
views
I'm trying to make the petals rotate from the color orange, yellow, to orange as a loop, but it always ends in the fourth petal as the color black..?
I'm doing an assignment on using turtles to make sunflower petals using pentagons. Everything is as it should be, except for the color of the petals. It strictly says that the colors of said pentagons ...
1
vote
1
answer
257
views
My Turtle Crossing Game on Python : Collision function does not work
I've been trying the Turtle crossing game. It's basically getting the Turtle start out at the bottom of the screen and have it move across the screen while several randomly generated cars travel from ...
2
votes
1
answer
145
views
Why is the snake increasing its speed when it grows?
I am working on the famous snake game in Python and I've stumbled upon a glitch where the snake starts doing when it eats food.
The snake should keep constant speed throughout the game and the ...
1
vote
3
answers
174
views
I'm not able to remove the arrow in python turtle while trying draw a circle of flowers
I have encountered an issue with the turtle graphics code. Despite trying various methods to hide the turtle, such as using bob.hideturtle() at different points in the code, the arrow remains visible. ...
0
votes
0
answers
104
views
TclError preventing creation of Tkinter windows
I have a student on MacOS (Sonoma 14.6.1) getting an error when they try to create a window in a function:
def nothing_window():
window = tkinter.Tk()
window.mainloop()
When they call that ...
1
vote
1
answer
80
views
Turtles don't appear when using the tracer method
Here's my code:
from turtle import Turtle, Screen
window = Screen()
window.setup(width = 800, height = 800)
window.bgcolor("Black")
position = [(-40,0), (-20,0), (0,0)]
turtles = []
window....
0
votes
1
answer
85
views
Python Turtle - Fullscreen Background with the sun in the middle and palm tree silhouettes
I attempted to recreate a background using the code below, but I am unsure how I can recreate the background image below. I was able to get the correct colours and the yellow sun in the middle, ...
0
votes
1
answer
99
views
Determining the angle in python turtle graphics [closed]
The task is to draw an equilateral triangle that will be positioned in the first quadrant, so that it is symmetrical with respect to the bisector of the first and third quadrants.
Image of triangle
...
0
votes
1
answer
38
views
Object filling incorrectly
I'm doing my UNI's basic programming course and haven't used turtle since high school, and I was wondering why exactly this shape is filling incorrectly. Pictures are attached as to how it fill, and ...
2
votes
3
answers
2k
views
Drawing a pattern(with dots) using turtle in python
I am trying to make a hirst painting (dot pattern) using the turtle in python. I managed to achieve it. Hirst_painting_dot_pattern.But my for loop isn't working the way I have expected. It's omitting ...
-1
votes
1
answer
113
views
Why is my Snake Game in Python Stopping with 'float' object is not subscriptable Error?
I'm working on a Python Snake game using the turtle module. I have four files: main.py, food.py, scoreboard.py, and snake.py.
Here is my main.py code:
from turtle import Screen
from snake import Snake
...
0
votes
2
answers
126
views
Why does the turtle not move in a square? [duplicate]
How do I move this, and make a square a proper position.
import turtle
def draw_square():
window = turtle.Screen()
window.bgcolor("red")
brad = turtle.Turtle()
brad.shape(&...
0
votes
1
answer
100
views
Why do the options not appear for my Snake game?
I am creating the snake game with a twist. I want questions to appear on top and their answers to appear randomly on the screen.
I am using turtle and creating classes while retrieving the question ...
1
vote
0
answers
67
views
Collision failed in turtle graphics ping-pong game: the ball is not bouncing after it hits the wall
I wrote a collision function to make the ball bounce back after it hits the wall. It's called wall_collision in ball.py.
Issue
The collision function called wall_collision does not work as expected:
...
1
vote
1
answer
81
views
Dynamically passing Turtles to onkeypress() binds always only one of them
I'm working with Turtle, recreating the pong game as part of an intro course.
I have 2 turtle objects, called paddles, stored in a dict with the relevant keys to move them, see below.
I'm trying using ...
0
votes
3
answers
74
views
Can we use commands as a parameters? [duplicate]
I want to use the commands as parameters in a function.
Is there any way ?
import turtle as t
pen=t.Turtle
def orders(name,var) :
pen.name(var)
orders(forward,50)
orders(right,90)
t.done()
I ...
0
votes
0
answers
30
views
Second instance of a class suppresses/deletes the first one in my Python program [duplicate]
I am creating the Pong game using the Turtle module in Python. So far, I have one file for the paddles (the bars that players control to hit the ball) called paddles.py and a second file for the main ...
2
votes
1
answer
74
views
Why is the bat/board not moving up or down in the Pong Game, when the screen.listen() is called using the Turtle module in Python?
Using the turtle module to make a pong game. For this part, when I press the up/down keys the board doesn't respond to the onkey listen function.
I created the board/bat (or bat specs function from ...