Simple Animation and Movement Jump to this section
This lesson covers simple animation techniques: controlling speed and updating drawings in a loop to create motion.
Simple frame-by-frame animation Jump to this section
You can clear the drawing and redraw slightly moved shapes to make simple animations.
import turtle
import time
screen = turtle.Screen()
t = turtle.Turtle()
t.hideturtle()
t.penup()
for x in range(-150, 151, 10):
t.clear()
t.goto(x, 0)
t.dot(30, 'red')
screen.update()
time.sleep(0.05)
Note:
screen.update()andtime.sleep()work for simple demos. For smoother animations exploreontimerortracer()later.
Using speed with drawing
Jump to this section
speed(0) combined with quick loops can draw many frames quickly for an animated effect.
Exercise Jump to this section
- Animate a ball moving left-to-right and bouncing back.
