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

Trying to draw a checkerboard using Turtle in Python - how do I fill in every other square?

I'm trying to draw a checkerboard. I drew the board, but now I have to define a function (a loop) that fills in every other square with black. I've been trying to write a loop to do this for a while, can someone help? Here's my code: import…
user3105664
  • 179
  • 3
  • 6
  • 11
4
votes
2 answers

Python Turtle collision with screen boundaries

How do I make the collision? so the turtle/snake doesn't go out of the box. I'm trying to make them stay inside the (-200, -200) and (200, 200). from turtle import * from random import * def bounding_box(): up() right(90) forward(200) …
Singh2013
  • 169
  • 1
  • 4
  • 12
4
votes
3 answers

Infinite loop with two randomly walking turtles

After I got the hang of my previous programme (the turtle that walked randomly and bounced off the walls until it hit them 4 times), I tried doing the following exercise in the guide, which asks for two turtles with random starting locations that…
reggaelizard
  • 811
  • 2
  • 12
  • 31
3
votes
3 answers

How exactly do hex color codes work? / How to implement something like a heat map

I am working on a simple program to just draw circles around some fixed points using the Python turtle package; however, I wanted to make it somewhat like a heat map where the colors get "cooler" as they get farther from the original point. My idea…
NSchrading
  • 144
  • 1
  • 13
3
votes
2 answers

How to color one size elements the same color in Python Turtle?

I just did a code that draws a a circle, then draws 6 more circles in it, then draws 6 more circles in every circle... et cetera. def krug(x,y,r): if r < 3: return for n in range(6): x1 = x + round(2*r*math.cos(n*(3.14/3))) …
3
votes
3 answers

Turtle and list in Python

I am experiencing trouble with my code it is supposed to be drawing a house with a cross through the center but is getting messed up somewhere and I cant figure out where. import turtle def drawhouse(bob): pairs = [(100, 135), (70.71, -135),…
3
votes
1 answer

Third Clone Of The Turtle

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 =…
Klap
  • 57
  • 6
3
votes
1 answer

How to colour in inside of an object easily?

import turtle back = turtle.Turtle() back.speed(0) back.penup() back.goto(-255,175) back.pendown() back.begin_fill() for x in range(4): back.forward(500) back.right(90) back.forward(350) …
3
votes
1 answer

How to create rotated text in Python's turtle graphics?

I am using Python 3.9 with tkinter and tcl version 8.6, so according to an answer here on stackoverflow from the year 2010, I should be able to draw rotated texts. And actually I am able to draw rotated texts in tkinter so I tried to create a…
Claudio
  • 7,474
  • 3
  • 18
  • 48
3
votes
1 answer

Python turtle draw filled irregular polygon based on user clicks

I would like to make a program that creates a turtle window that the user can click 4 times to create an irregular polygon. It will automatically go back to the starting point after the 4th click to make sure that it is properly closed. That much…
AceSoap19
  • 31
  • 2
3
votes
1 answer

A start to tiling the screen with triangles

At the moment, I'm trying to get started trying to tile the python turtle graphics screen with equilateral triangles of random colors. I've made a function which is successfully able to make a triangle starting at say coordinates v_1 = (x, y). Once…
user516079
  • 133
  • 4
3
votes
2 answers

How to hide the turtle in python

How do you hide the turtle while drawing in Python 3. It is covering my work and I need to see exact corners and other things. Is it also possible to draw with it hidden? Thank you. I have tried this command and it did nothing. t = turtle.Turtle() s…
3
votes
1 answer

How do I make the goal move? (Python, Turtle)

This is the code. I don't know why but the goal does not move when I run the code. I am really new to coding so excuse me if it is something silly. Thank you so much for all your help. if isCollision(player, goal): …
3
votes
2 answers

Python turtle: trigger function on any key pressed

How can I add random key pressed with turtle (that means that I don't want this:scr.onkey(fun,'r')? I tried this... import turtle as system scr=system.Screen() def p(): print('button pressed') scr.onkey(p,any) ...but this does not work. How…
George
  • 31
  • 5
3
votes
3 answers

Turtle Maze in python. I do not know how to avoid the turtle passing walls and cheat

i am a complete beginner to coding and at school we started learning python. My little cousin discovered that, and asked me to make a game... since i am not an expert i decided to do a simple game, a maze. I coded some functions to generate the maze…