Square Dance  -  Random pattern generation

by Martin Richards

updated by David Bradforth

SquareDance is an updated version of a program originally published for the BBC Micro in BEEBUG magazine. It provides an attractive random graphic display based on coloured rectangles. The original BBC version is supplied, along with an updated version for RISC OS which uses more colours.

When run, the screen clears and a pattern of repeating rectangles in different colours builds up on the screen. They appear to 'dance' across the screen, hence the name of the application.

Pressing the space bar will restart the random generator, and a new set of squares will be generated using different forms and colours. Each time you press the space bar the screen will appear to show an entirely different effect.

If you want to leave the program running to provide an attractive abstract display, you can arrange for the pattern to change form at random, instead of having to press the space bar. To do this, just locate the line near the end of the program that reads:
	UNTIL A=32
and replace it with:
	UNTIL TIME MOD 256=RND(255)

A version of this program has also been written in C, and is supplied alongside the two Basic versions for the BBC and for RISC OS. Users who are experimenting with learning C may like to examine the code for the Basic and C versions side by side to see how a simple program like this can be translated with relative ease.


Copyright  RISC User magazine 1998