@PatrikSkarbo/

Turtle animation test

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
63
64
65
66
67
68
69
70
71
import turtle

#screen = turtle.Screen()    # create a new screen
#screen.setup(500,500)       # 500 x 500 window

#don = turtle.Turtle()       # create a new [ninja] turtle
#don.speed(0)                # make it move faster

#def draw_square() :         # a function that draws one square
#    for side in range(4) :
#        don.forward(100)
#        don.left(90)

#don.penup()                 # go off-screen on the left
#don.goto(-350, 0)
#don.pendown()

#while True :                # now do this repeatedly, to animate :
#    don.clear()             # - clear all the turtle's previous drawings
#    draw_square()           # - draw a square
#    don.forward(10)         # - move forward a bit

screen = turtle.Screen()
screen.setup(500,500)
screen.tracer(0)            # tell screen to not show automatically

boll = turtle.Turtle()


#def k1():
#    boll.forward(45)

#def k2():
#    boll.left(45)

#def k3():
#    boll.right(45)

#def k4():
#    boll.back(45)

#screen.onkey(k1, "Up")
#screen.onkey(k2, "Left")
#screen.onkey(k3, "Right")
#screen.onkey(k4, "Down")


boll.speed(0)
boll.width(3)
boll.hideturtle()            # hide boll , we only want to see the drawing

def draw_square() :
    for side in range(4) :
        boll.forward(30)
        boll.left(90)

boll.penup()
boll.goto(-350, 0)
boll.pendown()

while True :
    boll.clear()
    draw_square()
    screen.update()         # only now show the screen, as one of the frames
    boll.forward(1.3)


screen.listen
screen.mainloop()

result
console