Questions tagged [turtle-graphics]

A method for drawing computer graphics using a cursor, known as a turtle. Turtle-graphics supports game development, visualizations, animation, etc.

A method for drawing graphics, which uses a cursor (known as a turtle) for specifying the position, the direction and the attributes (color, line width, etc.) of the lines being drawn. It was popularized by the Logo programming language. Similar functionality can currently be found in Python's turtle module, which is part of its standard library.

The turtle runs commands sent to it sequentially, including moving forwards or backwards, turning/rotating, and raising or lowering "the pen" determining if the turtle is currently drawing a line while moving. This output pathway of the turtle can additionally be post-processed into 3-dimensional models. Depending upon the implementation, the turtle may traverse 2D, 3D, or N-dimensional coordinate spaces.

3188 questions
0
votes
3 answers

How to create multiple turtles in a for loop?

Let's say I want to create multiple turtles but also let the user decide how many there is. Is there a way to make a code like this? : n = input() for i in range(n): 'turtle' + i = Turtle() So you would end up with n turtles called 'turtle1',…
0
votes
2 answers

Unexpected Python turtle behavior when turning was invoked from keyboard

I have observed an unexpected behavior of the turtle graphics when turning the turtle by pressing keys on the keyboard. For example turning to the opposite direction resulted in a double line instead of following the already drawn line in the…
Claudio
  • 7,474
  • 3
  • 18
  • 48
0
votes
1 answer

Tron collision with a generated line in turtle graphics

So I'm doing the last part of my tron game which is to code the collision that happens when the 2nd players' tron bike hits the line of the 1st players tron bike. From there, whoever ran into the line loses, and the other one wins. So my issue is…
Ian
  • 35
  • 6
0
votes
1 answer

How to prevent error when closing a turtle screen?

I have this simple code : import turtle s = turtle.Screen() s.bgcolor('black') obj = turtle.Turtle() while True: s.update() And when I close the window, this error comes up : Traceback (most recent call last): File "d:\Visual Studio Code…
0
votes
2 answers

turtle not drawing anything with functions

so for an assingment, I needed to make a function. I wanted to do something cool, so I made a thing that makes squares be a random color, and in a random spot, but for some reason, it wont even show a turtle. Here's the code. import turtle import…
24bit
  • 15
  • 3
0
votes
1 answer

Python turtle: How to close turtle screen suddenly without getting tkinter error

I made a Pong game with Turtle module, but got a problem that while the game was running, I closed the window suddenly and received a wall of traceback message: Is there any way that I can exit the window during the game without getting error…
Gold_Leaf
  • 53
  • 7
0
votes
1 answer

When I press a key, all the other previously moving elements stop moving in python turtle

So I'm making a 2 player tron game in turtle, and my code seemed to be working fine (except the border that's why I commented it out). The only thing is that when I tried to play the game by myself to test it out, whenever I moved the "other" tron…
Ian
  • 35
  • 6
0
votes
1 answer

Trying to find the screensize and make an object go to the screensize over 2 with turtle

So I'm writing a tron game in python turtle and I want to make the two bikes start at whatever the screen width is/2, and height/2. (Same thing for the other but negative width). Sadly this doesn't seem to work because you can't divide a function by…
Ian
  • 35
  • 6
0
votes
2 answers

I'm trying to make a 2 player tron game, and I don't know how to make a countdown to start the game

My code currently draws the 2 tron bikes and each of the players can move them with the WASD and up down left right keys. Right now if you play the game anyone can start playing at any time they want to, there's no specific "starting" time or a…
Ian
  • 35
  • 6
0
votes
1 answer

Is there a way to get and save an angle of a turtle for later?

I'm making a program where the user can click on the screen 3 times and it makes a triangle. It will then find the middle points of those 3 lines. Next, I want it to draw 3 lines perpendicular to each of the lines that make up the triangle (through…
0
votes
1 answer

Why is my function working without being called via keybind?

I'm trying to make a function and keybind so whenever I press "w" the object moves up 15 pixels, but when not only does the keybind not work, the object appears to have already moved up those 15 pixels from it's original position: from turtle import…
0
votes
1 answer

How do I make the turtles wait for the countdown?

I want my turtles to go after the countdown finishes, but I cant figure out a way to do it. There are other issues, but i want to fix this first. I've tried time.sleep, and other stuff. I'm fairly new, so i'm not sure what do to. this is for a class…
24bit
  • 15
  • 3
0
votes
1 answer

Python Turtle Will Not Draw Circles

So I'm making a snowman in python turtle for a coding class, but when it's drawing the buttons, they just don't draw. I've syntax checked it, and looked over, and I don't get why they don't draw. Here is my code import turtle turt =…
0
votes
1 answer

Is there a way to store circle coordinates and move them around in python turtle?

I know it's possible to store polygons in a dictionary since they have definitive coordinates, but is there a way to store the coordinates of a circle into a dictionary and move them around? My program consists of detecting whether a mouse click is…
Azizi
  • 15
  • 3
0
votes
1 answer

How do i connect all the dots on my circle so that it makes a pattern?

So I was trying to make a circle with a certain amount of dots on it with all the dots connected with each other. So if there are 10 dots, dot 1 would be connected with all the other ones and so is dot 2. Eventually it makes a pretty pattern. I…