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
4
votes
2 answers

Python turtle tic tac toe

I'm new to python and I programed a tic tac toe with an AI that plays against you. Everything is working but I used textboxes to inform the AI what the player chose. Now I want to upgrade my game so that the player can click on the box he wants to…
twinnxx
  • 49
  • 5
4
votes
2 answers

How can I cycle colors using turtle module in python?

I'm trying to make a rainbow straight line but can't figure out the way the RGB values in turtle.pencolor() should change over time... I tried using a hexadesimal increment from 000000 to FFFFFF but I got a a black to green line loop before getting…
Demis
  • 197
  • 2
  • 10
4
votes
1 answer

How to detect X (close) button in python Turtle graphics?

When I click on the X (close) button while running a infinite loop of drawing in Turtle graphics, some error messages occurs. Here is an example: import turtle wn = turtle.Screen() tess = turtle.Turtle() while True: tess.forward(50) …
liganega
  • 88
  • 8
4
votes
1 answer

Kernel crashes when trying to drag a turtle in python

I decided to use the built-in turtle for the display of my whole program, but if there's a better option you can leave it here too. So, when I was using the turtle and bound a function to the left click drag, it ends up working fine, but only for…
aargon
  • 126
  • 3
  • 9
4
votes
2 answers

Key event seems stuck using `turtle.onkey(function(), "key")`

I'm trying to add keyboard input to move python's turtles but without even pressing the assigned key the turtle moves as if I'm holding the assigned key. What am I doing wrong? My code is below: # import import turtle # init screen, turtle window =…
jll123567
  • 85
  • 7
4
votes
2 answers

How to bind several key presses together in turtle graphics?

I'm trying to make a connect-the-dot python game. I want the game to register 2 button presses. Example: if the user presses Up and Right arrow key, the turtle goes 45 degrees north east. here is my code: import…
user9116121
4
votes
2 answers

Mandelbrot Sequence with Python's Turtle

I am trying to draw the mandelbrot sequence with python's turtle graphics. I am using two classes, one to represent the mandelbrot sequence. class Mandelbrot: def __init__(self,c,limit=50): self.__limit = int(limit) self.__colormap =…
Connor Simone
  • 41
  • 1
  • 2
4
votes
2 answers

How to use Python turtle to plot a function

I am trying to create a python script that will allow me use turtle to plot a function like y = 0.5x + 3. How can this be done? My current approach is: import turtle ivy = turtle.Turtle() def plotter(x): y = (0.5 * x) + 3 ivy.goto(0,…
user4612771
4
votes
3 answers

Is there any way to resize a gif shape with turtle in Python?

I'm using turtle to make a little game and realized I could use image files with turtle.registershape(filename). I know you can resize the default shapes with turtle.shapesize or turtle.resizemode("auto") and changing pensize, but is there any way…
The_Basset_Hound
  • 185
  • 1
  • 2
  • 11
4
votes
2 answers

Python turtle program works in IDLE, not otherwise

I have created a simple button program using turtle in Python. It is most likely very sloppy but works perfectly in IDLE. However, when trying to load it without IDLE it just draws the two buttons and then quits the program. I've looked over the…
Jakey Snakey
  • 95
  • 1
  • 1
  • 7
4
votes
5 answers

Python Turtle.Terminator even after using exitonclick()

I have tried to make functions for turtle to make it extremely easy to draw shapes. The code looks like this: import turtle as t def square(): tw = t.Screen() for i in range(4): t.forward(100) t.right(90) …
user8328768
4
votes
2 answers

Python turtle ondrag event vs. compound shapes

When I register a polygon, or a compound shape with only a single component, I'm able to create a turtle cursor using that shape, add a drag event handler, and drag it around the screen. But when I register a compound shape with a second component,…
cdlane
  • 40,441
  • 5
  • 32
  • 81
4
votes
3 answers

Determine if a point belongs to the region specified by a Koch snowflake of order n

I am trying to write a python script that performs the following computation: Input: (1) List L: a list of some 2-d points (2) List V: vertices of a triangle (3) Positive integer n: the order of Koch snowflake to be created from that…
4
votes
0 answers

Using images with Skulpt Turtle

When using Skulpt, how do I access a gif image on the web server? I am using turtle graphics, and I want to set the shape of the turtle to a picture that is saved on the web server, however I'm not sure how to do this. I know that to do this via a…
rsankar
  • 41
  • 2
4
votes
3 answers

Drawing a fractal tree in Python, not sure how to proceed

I have this so far in python import turtle import math t = turtle.Turtle() t.shape("turtle") t.lt(90) lv = 11 l = 100 s = 17 t.penup() t.bk(l) t.pendown() t.fd(l) def draw_tree(l, level): l = 3.0/4.0*l t.lt(s) t.fd(l) level…
Sebastian
  • 55
  • 1
  • 1
  • 4