Last active
March 14, 2023 12:03
-
-
Save juanfal/0bfa3ca9ef46b85cdba9585395d271ff to your computer and use it in GitHub Desktop.
Drawing a chessboard with python turtle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# chessboard.py | |
# juanfc 2023-03-14 | |
# | |
from turtle import * | |
ancho = 50 | |
speed(0) | |
color("black", "black") | |
penup() | |
goto(-4*ancho, -4*ancho) | |
for fila in range(8): | |
for i in range(4): | |
pendown() | |
begin_fill() | |
for i in range(4): | |
fd(ancho) | |
left(90) | |
end_fill() | |
penup() | |
setx(xcor()+ancho*2) | |
if fila % 2 == 0: | |
setx(-4*ancho+ancho) | |
else: | |
setx(-4*ancho) | |
sety(ycor()+ancho) | |
penup() | |
goto(-4*ancho, -4*ancho) | |
setheading(0) | |
pendown() | |
for i in range(4): | |
fd(ancho*8) | |
left(90) | |
done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment