Skip to content
Game 0 Unit 5 of 15 1 hr learning time

Many Things at Once

Here's why the scene reached for Blitz. Put eighty objects in the frame loop, move every one of them each frame, and compiled Blitz draws the lot smoothly at full speed — the thing an interpreted BASIC can't keep up with. This is the headline trick of the whole language.

33% of Meet Blitz

This is the unit that explains why Blitz exists. You have the loop, the decision, and the frame; now you put them together and ask the machine to do something hard — move eighty objects, all at once, every single frame. An interpreted BASIC would lurch and stutter under that load. Compiled Blitz takes it in its stride, smoothly, fifty times a second. Seeing that is worth more than any speech about "compiled is faster," so let's watch it.

What you'll see by the end

Eighty circles, each one repositioned every frame, gliding together at full speed.

Eighty circles, weaving around the screen — and not one of them is hand-placed. A loop draws all eighty every frame, with new positions each time, and the frame loop runs the whole thing fifty times a second. It's smooth because Blitz is fast enough to finish all that work inside a single frame.

The whole program

; Eighty objects, all moving every frame. Compiled Blitz does it smoothly.
BLITZ
  BitMap 0,320,256,3
  BitMap 1,320,256,3
  Slice 0,44,3
  t.f = 0
  db = 0
  While Joyb(0) = 0
    VWait
    Show db
    db = 1-db
    Use BitMap db
    Cls 0
    For i = 0 To 79
      x.w = 160 + Sin(t + i*0.4)*140
      y.w = 128 + Cos(t*0.8 + i*0.27)*110
      Circle x, y, 7, 2+i/20
    Next
    t = t + 0.04
  Wend

The shape is the game loop from last unit, with real work inside it.

While Joyb(0) = 0
  VWait
  Show db
  db = 1-db
  Use BitMap db
  Cls 0
  For i = 0 To 79
    x.w = 160 + Sin(t + i*0.4)*140
    y.w = 128 + Cos(t*0.8 + i*0.27)*110
    Circle x, y, 7, 2+i/20
  Next
  t = t + 0.04
Wend
  • While Joyb(0) = 0Wend is the frame loop — keep going until the fire button.
  • VWait paces it to one pass per screen refresh.
  • The For i = 0 To 79 loop draws all eighty circles. Each one's position is worked out from Sin and Cos of t plus an offset for i, so they fan out and swirl. t = t + 0.04 nudges the whole pattern on a little each frame — that tiny change, times eighty circles, times fifty frames a second, is the motion you see.

That inner loop — eighty objects, recomputed and redrawn every frame — is the workload. Blitz eats it.

Drawing where you can't see: double buffering

There's a trick making the motion clean instead of flickery, and it's worth a moment. The lines Show db, db = 1-db, Use BitMap db set up double buffering: you keep two bitmaps and, each frame, show one while you draw on the other, then swap. The viewer only ever sees a finished picture, never the half-drawn one — so there's no flicker, no tearing, just smooth motion.

It works like this: db flips between 0 and 1 every frame (db = 1-db). You Show the bitmap you just finished, then Use BitMap db to draw onto the other one while this one is on screen. Two pages, swapped in time with the frame. You don't need to master it today — just know that drawing on a hidden page and flipping is how every smooth Amiga game avoids flicker, and Blitz makes it a handful of lines.

Why this is the point of Blitz

Eighty moving objects is nothing to a compiled program, and everything to an interpreted one. Each frame, Blitz runs eighty rounds of Sin, Cos, multiply, and Circle — and finishes with time to spare before the next refresh. An interpreted BASIC, re-reading and re-interpreting every one of those lines as it goes, would fall behind, and the motion would judder. This is the trade you met in unit 1 paying off: the compile step buys you the speed to move a crowd. It's why Worms and Skidmarks were Blitz games and not BASIC ones.

Type it and compile it

Type the program into Ted and press right-Amiga + X (choose the recompile option if Blitz asks about memory). The swarm appears and starts weaving. Press the fire button — or reset — to stop, since the loop runs until then.

Try this: a bigger crowd

Change For i = 0 To 79 to For i = 0 To 199 — two hundred circles now. Run it again. Compiled Blitz barely notices; the motion stays smooth. Push it higher and watch for the point where a single frame's work finally won't fit in a fiftieth of a second and the motion starts to slow — that edge is the machine's real limit, and Blitz lets you get right up to it.

Try this: change the dance

Change t = t + 0.04 to t = t + 0.1 for a faster, wilder weave, or 0.01 for a slow drift. The single number that advances each frame sets the whole pattern's speed — proof that all eighty objects are driven by the one loop ticking over.

What you've learnt

The headline of the whole language: compiled Blitz can move a crowd of objects every frame and stay smooth, where an interpreted BASIC would choke. The frame loop (While / VWait / Wend) runs the work; an inner loop repositions and redraws every object; and double buffering — two bitmaps, draw on the hidden one and flip — keeps it flicker-free. That combination, fast enough to fill a frame with motion, is exactly what the Amiga scene reached for Blitz to do.

What's next

You've moved crowds of circles — but games are made of pictures, not outlines. The next phase is Blitz's graphics proper. First — Slices and the Display — taking real control of the screen the bitmap is shown through.