Programs - Stars Screen Saver


Aim

When you walk away from your computer, you expect it to be exactly where you left it when you return. Not so with another three hundred people wanting to use it at the same time. In fact they might actually think of doing some damage, ‘by accident’. So I wrote a simple program that could be run as an instant screen saver, with a password to protect the computer from prying fingers.

Method

The program uses the graph unit from Pascal and the standard VGA graphics mode that is available. It has an array that contains the data about the stars: their distance from the centre of the screen, their bearing and their colour.

All the program has to do is to increase their distance from the centre of the screen and plot the new star, and then do the next star. To convert the distance and bearing into plotable co-ordinates the standard trigonometric functions sin and cos are used. Once a star flies off screen it is re-initialised back to the centre and given a new direction and colour.

Every time it has finished moving all of the stars just a little bit, it checks to see whether any keys have been pressed. If so check whether it is the next key we expect. If it is then update the next key that we want, but if not then we have to start at the beginning again. The password is read out of a plain text file at the beginning. It just takes the first line of stars.txt.