A Small White Rectangle and a Black Screen From 1999

While going through old notebooks from school, I found a few pages filled with handwritten Pascal code. No frameworks. No engines. Just a black screen and a tiny white rectangle bouncing from one border to another.

It was simple. Almost primitive. But it worked.

At the time, making something move on the screen felt like real magic.

Below is a minimal Pascal program that reproduces that idea using the old CRT unit. It uses the simplest possible logic: move the rectangle by fixed increments and reverse direction when it hits a boundary.

The full code:

program BouncingRectangle;

uses crt;

var
x, y: integer;
dx, dy: integer;
width, height: integer;
rectW, rectH: integer;

procedure DrawRect(px, py: integer);
var
i, j: integer;
begin
for i := 0 to rectH - 1 do
begin
GotoXY(px, py + i);
for j := 0 to rectW - 1 do
write(' ');
end;
end;

begin
clrscr;
TextBackground(black);
TextColor(white);

width := 80;
height := 25;

rectW := 6;
rectH := 3;

x := 10;
y := 5;

dx := 1;
dy := 1;

repeat
clrscr;

DrawRect(x, y);

x := x + dx;
y := y + dy;

if (x <= 1) or (x + rectW >= width) then
dx := -dx;

if (y <= 1) or (y + rectH >= height) then
dy := -dy;

delay(30);
until KeyPressed;

end.

Why It Worked

There is no physics engine here. No floating-point math. No timing corrections.

Just:

  • Position (x, y)
  • Velocity (dx, dy)
  • Boundary checks
  • Direction reversal

The rectangle “bounces” because the sign of movement changes when it reaches the limits of the screen.

That is the entire algorithm.


Why It Still Matters

Looking at that code now, it is almost naive. The screen size is hardcoded. There is no frame synchronization. The rectangle is drawn using blank characters with a white background.

But it demonstrates something fundamental:

  • Movement is just position plus velocity.
  • Interaction is just condition checks.
  • Animation is just repetition over time.

At school, writing this and seeing that white block move across a black screen felt like building a small universe from scratch. There were no tutorials open in ten browser tabs. Only a compiler, a textbook, and trial and error.

It is easy to forget how powerful such small programs felt when everything was new.

Sometimes progress in programming starts not with complex systems, but with a white rectangle moving across a black screen and refusing to leave it.

I miss my good old 1999…

Leave a Reply

Your email address will not be published. Required fields are marked *