Terrain - maps, simulation
Sections in this page
I have recently had a blast from the past about some games I wrote for the Sinclair ZX Spectrum and similar machines 30 years ago. It seems that the current resurgence of interest in popular programming may be reviving the ideas behind the games. I had a particular technique of my own for generating terrain on a large enough scale to be explorable, despite the lack of memory in those early machines (the Spectrum had only 48k bytes - and that was the larger version). Indeed, one of my games was simply called Explorer. Its predecessor, The Forest, was a simulation of the sport of orienteering.
[Update 24 June 2014: There is now an interesting article looking back at Explorer on Mark Green's blog, Pixelatron.]
There is a web site called World of Spectrum where a group of people are attempting to assemble an archive about all programs written for the ZX Spectrum and make many of them available to download and run in one of the many Spectrum simulators that are now also available for free. They have listed my two programs here (they have promised to correct the spelling of my name).
Technology has advanced so much in 30 years that much better versions of such games are now practical. For one thing processor clock speeds have gone up by a factor of nearly 1,000 - the Spectrum ran (I think) at 4 MHz. Also it is common now to have multiple processors in a single machine (eg, the Intel Core i5 etc), giving another potential speed increase. Also the processing of graphics is now usually hived off to a separate Graphics Processing Unit (GPU) rather than the Central Processing Unit having to do everything, as was the case all those years ago. Today's processors also have special instructions built into their hardware for frequently used computations. For example, I think it was in the mid-1980s that Intel processors (such as 80286) started to have companion chips called coprocessors, for doing non-integer arithmetic. Devices on silicon have now been so much further miniaturised that all such work can now be done on a single chip rather than requiring a coprocessor.
It is now common to have gigabytes of main memory. Even the laptop on which I am writing this has 8 Gbytes of RAM, which is 167,000 times that of the Spectrum. It almost goes without saying that we can now have very much better graphics, of photographic quality (something I could only dream of in the 1980s).
There are two views available: either a map or the view seen by an observer on the ground. Although there are buttons for switching between these views there is also a keyboard alternative: m (with or without shift).
The observer is marked on the map with a red circle which has an arrow point showing the observer's direction of view or motion. The map can be scrolled and panned and there is a button for centring the map on the observer (referred to as "me" on the button). The speed of scrolling/panning can be changed by doubling or halving the step size. The current coordinates of the map and the size of the step are shown in a status line at the bottom. There is also a coloured key to different types of terrain depicted in the map. The colours are those used on orienteering maps.
The other view, the scene, indicates what the observer would see on the ground. The type of terrain ahead is indicated by graphics. One of the advances here is that real photographic images can be used rather than simple drawn graphics. The base line for the graphics indicates whether the ground ahead slopes up or down, according to the contours on the map. The arrow keys are active in the scene and they act as follows.
- UP - moves the observer forward, currently by 10 distance units. In moor or lake the distance is half that. In thicket the distance per step is reduced to 2 units and the word "OUCH!" appears, to warn you that the going is tough.
- LEFT or RIGHT - turns the observer in the appropriate direction in steps of 15 degrees. If you switch to the map view you will see that the red marker has turned too.
- DOWN - turns the observer right round, through 180 degrees, to face back the other way.
NB: The arrow keys may scroll/pan the window in some browsers or on small screens, so letter key alternatives are allowed: initials of Right, Left, Up , Down or the suitably laid out group of keys H, J, U, N.
Note that the observer's current position (x, y) and bearing (degrees clockwise from due North) are shown in the status line at the bottom of the view. A compass is also shown at the bottom centre of the scene view.
The red dots on the map are teleportation machines. In the scene view they appear as on the right here. They were called warp gates in the original Explorer. The point of these is that by typing in any name you will be taken magically to a particular spot on the map. When you find another teleporter you can go back to exactly the same spot by using the same name. A set of names enables you to jump about to known places. So if the game included important immovable objects (with messages on them perhaps) you could always revisit them after you had found them. It is entirely up to you to choose location names. There is no telling in advance where any particular name will take you. Letter case is irrelevant: London and LONDON will both go to the same place.
Black dots on the map are intended to be cave entrances but as yet nothing happens there.
- Underground connections (caves).
- Photographic images will be added to the scene view for grass and lake.
- At present the scene view shows the terrain types on radii 5, 10 and 15 distance units ahead. It is planned to try fading them out the further away they are, or other means of making the interpretation more obvious. Current measurements of drawing speed (in the status line at the bottom) indicate that this will not take too much time*. The idea will be to imagine that there is an all-pervading fog preventing long distance views.
- The profile used for generating the terrain is the same as was used in the original Spectrum version but it would now be possible to do something better (I have an idea).
* I am testing in Firefox 29.0 running on 64-bit Windows 7 Home Premium on an Acer 4830T laptop (Intel Core-i5-2430M processor running at 2.4GHz "with Turbo Boost up to 3.0GHz"). The map takes about 60ms to draw and the scene takes only 1ms or less. Please tell me if your platform takes significantly longer.
I will be writing more here but meanwhile some further information about orienteering maps can be obtained here (and follow the links there to read more about the simulated forest).
In 1982 I had two articles published in the now long-defunct British magazine "Practical Computing". The articles described the basic techniques I was using to generate terrain from mathematical functions rather than storing it in memory. Following here are links to scanned images of the articles.