Oliver Finally Makes the Bomb Spin
Oliver was building a rotating bomb animation using Python turtle graphics. He reused the animation structure from an earlier moving car project:
tracer(0)
for i in range(900):
db()
update()
time.sleep(0.03)
clear()
lt(1)
The idea seemed simple: draw the bomb repeatedly while rotating a little each frame. But the animation behaved unpredictably, and the bomb appeared to spin out of control.
Together we discovered that the turtle's orientation was not returning to the same angle after drawing the bomb.
Each frame therefore started from a different direction, causing errors to accumulate. Once Oliver fixed this invariant, a second problem appeared: the bomb's position drifted every frame.
A quick fix using:
pu()
home()
pd()
successfully reset the position, but unexpectedly stopped the rotation entirely.
Only then did Oliver realize that home() resets both position and angle. The very rotation logic he had repaired was being erased every frame.
The solution was elegant.
If home() resets the angle every frame, then the rotation must come from the animation loop itself:
for i in range(900):
db()
update()
time.sleep(0.03)
clear()
lt(i)
Now each frame contributed a new amount of rotation, and the bomb began spinning smoothly.
The animation finally worked, but more importantly, Oliver had discovered how state changes over time.
This was not a lesson about syntax.
Oliver encountered:
• state
• invariants
• frame logic
• cumulative effects
He learned that animations depend not only on drawing objects but also on carefully controlling what changes and what stays the same between frames.