Graphics On The Sinclair/Timex
Derek Stubbs
This short guide to the graphics capabilities of Sinclair/Timex computers demonstrates pattern creation, circles, conic sections, and bar graphs. To show how graphics can be used in games, there is "Asterbelt," which will test your abilities as a spaceship pilot.
One great advantage of a computer over most calculators is that a computer can handle letters as well as numbers and can give a graphic output. You possibly bought your ZX/TS hoping to produce some fabulous graphics. If you did, you were soon disappointed by two things: the manual says little about graphics, and computer magazines often contain programs with graphics commands that you cannot use, such as HPLOT, SET, RESET, DRAW, and XDRAW.
Don't be worried. The ZX/TS has lots of graphics capability. My favorite is the unique graphic symbol facility. It can print a million-million different patterns. They each remind you of an Indian blanket, or an urban landscape, or the tiles in an oriental design. Sometimes a striking 3-D pattern emerges.
Program 1 generates a random string of graphic symbols (lines 10-40) and then prints and reprints them until the screen is full (lines 50-110). After a pause of four seconds (line 200), a new pattern is generated. Experiment by reducing the string-length of 11 in lines 10, 20, and 60.
Figures And Graphs
To many people, graphics means geometric figures. A simple program (Program 2A) will draw a circle of radius R and center X, Y. The speed of plotting and the interval between points depend on I. You should experiment with values of R, X, Y, and I before going on to a more fascinating plot (Program 2B). Start with R = X = Y = 15 and I = .2.
Now you will see how Program 2B - which I call "Figures" - will print all kinds of conic sections (circles, ellipses, parabolas, and hyperbolas) and all kinds of lissajous figures (weaves, pretzels, and figures of eight). The interesting thing is that Program 2B is only one line longer than Program 2A - yet it is far more versatile.
A third graphics feature that has many uses is a simple graphic plot of data. Program 3, "Graphs," will plot any mathematical function that you input, as A$. It always fits on the screen because you define the limits, XMIN and XMAX.
If you need to plot a bar graph, Program 4 will be adequate. Typically, such a graph is used to plot "time-data" such as "sales per month" or "bushels of corn per year." Also you might use it for "frequency" data like "how many people weighing 50-100 lbs., 100-150 lbs. and so on." Program 4 allows you to plot and label the axes and bars so that you can understand how to mix the PRINT and PLOT commands to get a good screen. Instead of printing I in line 170, you can print another label such as the time or interval concerned; call it C$ and INPUT it at line 135.
The ultimate graphics program is the moving graphics game. You'll have fun with Asterbelt (Program 5). You're the captain of a spaceship denoted by an asterisk at coordinates X, Y. You can drive it to port or starboard by pressing P or S. A thousand asteroids appear as blobs (sub-routine 1000). If you collide with an asteroid, a flash occurs as you destroy it with your hyperspace shields; and you move on through the exploded remnants (subroutine 2000).
You can make it harder by having only two squares between you and the next asteroid to appear. You can adapt subroutine 2000 to keep a count of your collisions. Warning: in the non-play mode, the screen clears very slowly.