Version 1.0 — © 1996 Christian Cohnen
The 3D starfield is probably the oldest trick in the demoscene book. Every home computer from the C64 to the Amiga had one, and it was often the very first effect a budding demo coder would attempt. The idea is dead simple: scatter points in 3D space, project them onto the screen with perspective division, and scroll the Z axis to fly through them.
This version adds a twist — literally: the entire star field rotates around the view axis using a sine/cosine rotation, so instead of just flying straight ahead you spiral through the stars. Four different star sprites (from large and bright to small and dim) are selected based on depth, giving a convincing sense of distance without any actual lighting calculation. The coordinate space wraps around using bitwise masking, so the field is effectively infinite — stars that fly past the camera reappear in front.
Keyboard controls let you steer in all directions and change the rotation speed, turning the starfield into a tiny interactive flight simulator.
The original applet ran in real time with just a few kilobytes of bytecode. Since browsers no longer support Java applets, here is a screen recording instead — ironic that it takes orders of magnitude more bandwidth to show what a 1996 JVM could do live.
| Name | Type | Description | Default | Required |
|---|---|---|---|---|
stars | int | Number of stars to render | 60 | no |
| Key | Action |
|---|---|
| ↑ / 8 | Fly backward (decrease Z speed) |
| ↓ / 2 | Fly forward (increase Z speed) |
| ← / 4 | Strafe left |
| → / 6 | Strafe right |
| PgUp / 7 | Move up |
| PgDn / 1 | Move down |
| 9 | Rotate counter-clockwise |
| 3 | Rotate clockwise |
| 5 | Center (stop horizontal/vertical drift) |
<applet archive="Starfield.jar"
code="ccStarfield.class" width="300" height="300">
<param name="stars" value="80">
</applet>