forked from tarunsinghofficial/HacktoberFest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaze
50 lines (39 loc) · 865 Bytes
/
Maze
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Maze
Maze, move from one side to another.
"""Maze, move from one side to another.
Excercises
1. Keep score by counting taps.
2. Make the maze harder.
3. Generate the same maze twice.
"""
from turtle import *
from random import random
from freegames import line
def draw():
"Draw maze."
color('black')
width(5)
for x in range(-200, 200, 40):
for y in range(-200, 200, 40):
if random() > 0.5:
line(x, y, x + 40, y + 40)
else:
line(x, y + 40, x + 40, y)
update()
def tap(x, y):
"Draw line and dot for screen tap."
if abs(x) > 198 or abs(y) > 198:
up()
else:
down()
width(2)
color('red')
goto(x, y)
dot(4)
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
draw()
onscreenclick(tap)
done()
©2017-2020, Grant Jenks. | Page source