repl.it
@potatosmurfer/

Turtle adventure

Python (with Turtle)

No description

fork
loading
main.py
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
51
52
53
54
55
56
57
58
59
60
61
62
import turtle
import random

screen = turtle.Screen()
t = turtle.Turtle()
turtle.speed(200)

turtle.speed("fastest")
t.speed("fastest")


move_speed = 10
turn_speed = 10
colors = ["green", "blue", "yellow", "red", "orange"]
toggle = True
screen.setup(1920, 1800)
check = False
shufflecolor = True

def colorchange():
  if shufflecolor == True:
    random.shuffle(colors)
    c1 = colors[0]
    t.color(c1)
    turtle.color(c1)
#def penup():
  #Check = True
  #if toggle == True:
    #turtle.penup()
    #t.penup()
    #Check = False
    #toggle = False
  #elif toggle == False and Check == True:
    #turtle.pendown()
    #t.pendown()
    #toggle = True
    

def forward():
  colorchange()
  turtle.forward(move_speed)
  t.forward(move_speed)

def backward():
  colorchange()
  turtle.backward(move_speed)
  t.backward(move_speed)

def left():
  turtle.left(turn_speed)
  t.right(turn_speed)
def right():
  turtle.right(turn_speed)
  t.left(turn_speed)


screen.onkey(forward, "Up")
screen.onkey(backward, "Down")
screen.onkey(left, "Left")
screen.onkey(right, "Right")
#screen.onkey(penup, "x")
screen.listen()
result
console
?