Created
March 22, 2017 03:35
-
-
Save cbscribe/decd9800c96b596926a02e081031e376 to your computer and use it in GitHub Desktop.
Draw a maze to solve with the turtle!
This file contains hidden or 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
| import turtle | |
| t = turtle.Pen() | |
| t.speed(0) | |
| t.width(5) | |
| turtle.tracer(0) | |
| # goto start | |
| t.up() | |
| t.goto(-300, 300) | |
| t.down() | |
| # outer edge | |
| t.forward(520) | |
| t.right(90) | |
| t.forward(520) | |
| t.up() | |
| t.forward(40) | |
| t.down() | |
| t.right(90) | |
| t.forward(520) | |
| t.right(90) | |
| t.forward(520) | |
| t.right(90) | |
| # upper section | |
| t.forward(480) | |
| t.right(90) | |
| t.forward(40) | |
| t.right(90) | |
| t.forward(440) | |
| t.up() | |
| t.left(90) | |
| t.forward(40) | |
| t.left(90) | |
| t.down() | |
| t.forward(480) | |
| t.right(90) | |
| t.forward(40) | |
| t.right(90) | |
| t.forward(480) | |
| t.up() | |
| t.forward(40) | |
| t.down() | |
| t.left(90) | |
| t.forward(40) | |
| t.left(90) | |
| t.forward(480) | |
| # lower section | |
| t.right(90) | |
| t.forward(140) | |
| t.up() | |
| t.forward(40) | |
| t.down() | |
| t.forward(140) | |
| t.left(90) | |
| t.forward(40) | |
| t.backward(80) | |
| t.left(90) | |
| for i in range(11): | |
| t.forward(280) | |
| t.up() | |
| t.forward(40) | |
| if i % 2: | |
| t.right(90) | |
| else: | |
| t.left(90) | |
| t.forward(40) | |
| if i % 2: | |
| t.right(90) | |
| else: | |
| t.left(90) | |
| t.down() | |
| t.forward(320) | |
| t.left(90) | |
| t.up() | |
| t.forward(40) | |
| t.down() | |
| t.forward(480) | |
| # go back to start | |
| t.up() | |
| t.goto(-280, 280) | |
| t.color('red') | |
| t.down() | |
| turtle.tracer(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment