Walk back and forth

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

A cartoon person and a dog mid-stride, walking across the grass with one leg forward.

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 s

Try this

  1. 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.speed 160 → 320

  2. Halve the distance to 200 pixels. The character turns round far more often, which reads as restless rather than on guard.

    In the program: params.distance 420 → 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

Worked out by the build: it plays the move in the engine on each body and checks what moves on screen. Nobody types this table.
BodyMoves?What moves
2 legs (a person)yeswhole body, arms, legs
4 legs (a dog)yeswhole body, front legs, back legs
no legs (the monster with no legs)yeswhole body

c4c:beh:patrol · version 1.0.0 · CC0 (public domain) · by Jabbertoon