Learn › GBC Beginner

Lesson 4 of 6 · About 5 min

How the fox moves

Two numbers decide how fast the fox runs and how high it jumps.

The fox of Fox Run at full speed in the meadow.

Speeds in sixteenths of a pixel, acceleration, and the small tricks that make a jump feel fair.

Speed in small units

The GBC has no fast way to work with fractions, so Fox Run keeps speeds in whole numbers of small units. Running speed is in sixteenths of a pixel per frame: RUN_MAX 30 means the fox runs at most 30 sixteenths, a little under 2 pixels, each frame. At about 60 frames a second that is about 112 pixels a second.

Jumps are in eighths of a pixel. JUMP_V is -27, so a jump starts moving up at 27 eighths of a pixel a frame, and gravity slows it a little every frame.

Acceleration and forgiveness

The fox does not reach full speed at once. It speeds up by ACC_G each frame on the ground and by ACC_A in the air, so it turns faster on the ground than in the air.

Two numbers make the controls forgiving. COYOTE gives 6 frames after running off a ledge in which a jump still works. JBUF remembers a jump press for 7 frames, so pressing A just before landing still jumps. Players rarely notice either, but they notice when a game does not have them.

Try a faster fox

In the session you will raise the top speed and the jump. The demo on the title screen works out its jumps from these same two numbers, so it keeps up with the change.

Fox Run in the editor, with the AI's reply about RUN_MAX and JUMP_V in the chat.
Make the fox faster

Try it yourself

In the app this lesson opens a real game for you, with a guide that walks you through these steps:

  1. How the fox moves is set by a few named numbers near the top of the code: RUN_MAX, ACC_G, ACC_A, JUMP_V, COYOTE and JBUF.
  2. Make the fox run a bit faster and jump a bit higher.
  3. Watch the demo on the title screen: the fox runs faster now. Small changes to these numbers make a big difference, so change one at a time.
Start makingDownload on the App StoreGet it on Google Play