History and Technical Notes


I just like "watching the trains go by".

The first version of the Railway scene was written on a Sinclair Spectrum using Spectrum Basic (approx 1985). Needless to say the graphics and movement were relatively crude, and as I recall there was only one locomotive type and two types of stock.

I started writing the current version in '95 as an exercise in C++. I had just completed a C++ course, and was looking for a suitable project to practice on. The previous idea of trains running by came to mind and a screensaver seemed a sutiable target.

The first scene was very simple - it was the mainline one with the tunnel mouth on the left. At first there was just one locomotive, a couple of train types and they just ran left to right / right to left. In due course signals were added, then more types of locomotive and stock, then another scene.

Having got that far, it needed a little bit of effort to get the object model right, but once that was resolved, more scenes and loco types were added.

The next big jump was the addition of steam locomotives and narrow gauge scenes. This got me into object inheritance, polymorphism, virtual functions and other peculiar C++ things.

This more or less brought the screensaver to its present state - the one major development left was the special features - things like the quarry, the depot, the terminus etc. These scenes involve a lot more than just trains running across the scene, and ultimately a general piece of code was developed to handle these, rather than specifically coding each scene.

About this time I was persuaded to make it available as shareware, and the first released version - version 5 was uploaded to two CompuServe libraries in May 96.

Since when, it has continued to grow - more scenes - more trains and the latest version (v6.10) was released in October 97. This is likely to be the last 16 bit version, as the next version, which will be 32 bit, is well on the way to being ready.



Technical Notes


The program was developed using Microsoft Visual C++

The primary object is the train which doesn't do much, other than to encapsulate the locomotive object and one or more stock objects. Most of the work is done by the locomotive object as this handles all the code for moving, acceleration, deceleration etc.

Effectively the train object is told to move, it knows where it is trying to move to, and calls the locomotive object's move method with parameters of the target position and the load (the stock). The locomotive object handles the movement.

All these objects have a drawing method, which is called when the display is updated. In most cases the bitmaps are held in graphic objects, which encapsulate all the code necessary for memory management, rendering, colouring, reflecting etc.

Another basic object is the signal object. Inherited objects provide semaphore signals instead of colour lights when required.

Steam locomotives, narrow gauge locomotives and multiple units are all derived from the train and locomotive objects and provide the extra functions needed, e.g. animation, smoke effects etc.

The final major object is the feature object. These are things like the goods yard, the depot, the quarry etc. A root feature object provides the basic functions necessary and the core interface, specific objects are derived from this base to provide the functionality nedded.