Learning LibraryGame Development LibraryKids

Frames and motion: movement is many tiny steps

Nothing in a game really glides. It moves in tiny steps, a little each frame. It happens so fast that your eyes see smooth motion, just like a flip-book.

The big idea

Motion is many small position changes, one per frame, that add up to smooth movement.

See it in code

1Start simple

Motion is really just a spot changing by a little, again and again. Watch y grow by 10 five times:

python
y = 0
for step in range(5):
    y = y + 10
    print("y is now", y)
Run it — the spot creeps down in small steps:
y is now 10
y is now 20
y is now 30
y is now 40
y is now 50

No big jumps — just +10, over and over. Stack up enough small steps and you get movement.

2A step further

Now a real enemy. We draw it once at the top, take 200 tiny move_down steps, then draw it again — so you can see where it started and where it ended up:

python
from game import Stage, Enemy

screen = Stage.create()
Stage.clear(screen)

enemy = Enemy(240, 90)
enemy.draw(screen)

for tiny_step in range(200):
    enemy.move_down()

enemy.draw(screen)
Run it — two snapshots show the enemy before and after its steps:
Two purple enemy sprites in a vertical line, one near the top and one lower down, showing the same enemy before and after many small steps.

Same enemy, two moments. All those tiny steps between them are the motion. A game just shows one step at a time, very fast.

3In our world

Add more moments and the path fills in. Here we draw the same enemy at five points in its fall, nudging it with move_down between each — and the snapshots trace the whole path:

python
from game import Stage, Enemy

screen = Stage.create()
Stage.clear(screen)

enemy = Enemy(240, 90)
for snapshot in range(5):
    enemy.draw(screen)
    for tiny_step in range(70):
        enemy.move_down()
Run it — five snapshots trace the enemy's fall down the screen:
Five purple enemy sprites stacked in a vertical line down the play area, showing the path of a falling enemy.

Each enemy in the trail is the same enemy, drawn after many tiny move_down steps. In a real game you only see the newest one each frame. But the motion is always built from small steps like these.

The same idea, everywhere

All animation works this way — cartoons, games, movies. It's lots of small changes, shown fast. Bigger steps mean faster motion. Smaller steps mean slower, smoother motion. Speed is just how big each step is.

Try it yourself

Change the inner range(70) to range(35) for smaller steps, and the snapshots bunch closer together. Then make the enemy drift sideways too by nudging its x a little each step.

The common mistake

Making each step too big. If you move an enemy 200 pixels at once, it seems to teleport instead of glide. Small steps, repeated fast, are what make motion look smooth.

What it unlocks

Motion happens inside the game loop, moves sprites, and builds sliding enemy waves.