Sample Programs

Examples

Tutorials and examples are the fastest way (in my opinion) to learn a new language. Well, ZX BASIC is not so new if you are used to Sinclair BASIC. The following is a list of examples, some of them already bundled with the ZX BASIC distribution in the examples/ directory:

  • CIRCLE.BAS
    Draws a circle pixel by pixel using PLOT primitive
  • CLOCK.BAS
    Sample clock which uses the FRAMES variable (taken from the ZX Spectrum 48K user manual)
  • CLOCK2.BAS
    Like above, but a bit improved.
  • COLORS.BAS
    Colors example from the ZX Spectrum user manual
  • LINES.BAS
    Random color lines example from the ZX Spectrum 48K user manual.
  • FACT.BAS
    Factorial ''recursive'' test.
  • FREREGUSTAV.BAS
    A sound demo (taken from the ZX Spectrum 48K user manual)
  • FLAG.BAS
    UK Flag drawing (taken from the ZX Spectrum 48K / 128K user manual)
  • FRACTAL.BAS
    Mandelbrot fractal by @Britlion

Games

  • SNAKE.BAS
    The snake game by Federico J. Álvarez Valero (2003-02-05) (English version)

  • 4INAROW.BAS
    A 4 in a Row program with A.I. that plays against you and fit in just 16Kb. Published on the 80's in the Spanish MicroHobby magazine, issue 18