Walk back and forth
A steady patrol: walk 420 pixels, turn round, walk back, turn round again, for as long as the scene lasts.

Use it in a cartoonOpen it in the block editorThe pack file (JSON)
What it is for
Walk back and forth is a background loop: a guard on patrol, a shopkeeper behind a counter, a dog walking along a fence. It never stops, so give it a whole scene. Unlike most moves it turns the character round at each end, by flipping its width, so a dog really does face the way it walks. One full round trip, there and back with both turns, takes about 5.75 seconds with the settings as they are.
The principle it shows: timing
Every number in the move comes from two settings: the distance and the speed. The time of each leg of the patrol is distance ÷ speed, worked out once, and both the glide and the walk use it, so the feet always stop exactly when the travel does. Change the speed and every part of the timing changes with it. Writing timing as a formula, not as fixed seconds, is what makes a move easy to remix.
The program, line by line
settings: distance = 420, speed = 160
when it starts
forever:
at the same time:
— 1:
move right (distance) in (distance/speed) s
— 2:
for (distance/speed) s:
walk cycle every 0.62 s
size width -1 in 0.25 s
at the same time:
— 1:
move right (-distance) in (distance/speed) s
— 2:
for (distance/speed) s:
walk cycle every 0.62 s
size width 1 in 0.25 ssettings: distance = 420, speed = 160— how far each walk goes, in pixels, and how fast, in pixels per second.forever:— everything below repeats until the move stops.at the same time:— the first branch,move right (distance) in (distance/speed) s, glides 420 pixels to the right in 420 ÷ 160 = 2.6 seconds. The second,for (distance/speed) s:withwalk cycle every 0.62 s, walks for exactly as long, a stride every 0.62 seconds.size width -1 in 0.25 s— the turn: the width glides from 1 to −1, which squashes the character to nothing in the middle and opens it out again mirrored, now facing the other way.- The second
at the same time:—move right (-distance)brings it back 420 pixels to the left, walking again. size width 1 in 0.25 s— turn back to face the first way.
Try this
Double the speed from 160 to 320 pixels a second. The character covers the same 420 pixels in half the time, so the patrol becomes a brisk march with sharper turns.
In the program:
params.speed160→320Halve the distance to 200 pixels. The character turns round far more often, which reads as restless rather than on guard.
In the program:
params.distance420→200
How it differs from Pace and Walk in
Pace drifts slowly to one side and back with short tired steps and never turns round; it reads as worry. Walk in is a single entrance that ends in a stop. Walk back and forth is the brisk, even one that loops.
Works on
| Body | Moves? | What moves |
|---|---|---|
| 2 legs (a person) | yes | whole body, arms, legs |
| 4 legs (a dog) | yes | whole body, front legs, back legs |
| no legs (the monster with no legs) | yes | whole body |