|
The OSRail Railroad Simulator Interface |
|
|
Written by Samuel E. Henley
|
|
Thursday, 22 May 2008 10:12 |
|
The game program of the OSRail project is called Simulator. The source can be found in the src/simulator directory. The root source file for understanding the game program code and design is interface.h. This interface file defines the simulation interfaces used to build the game. The method of the design is to use protocol classes and a protocol hierarchy (from "Large-Scale C++ Software Design", Lakos, John, 1996). This design was selected for two reasons: - Reduce compiler dependencies: Source files in the railroad simulator should only include interface.h and its abstract interface classes. Any interface to be used by other classes must be defined in interface.h. Any members used locally by an interface class can only be defined in the classes’ implantations class. The class factory example: graphics.cpp returns a pointer to the abstract interface class and is implemented in the implantations class source file. The only members actually implemented in interface.h are the abstract interfaces virtual destructors.
- Cross-Platform: By designing common interface for the game simulator platform dependencies are pushed to the lowest level of the class hierarchy. This same advantage includes dependencies on 3rd party libraries. OSRail is an open source project using other voluntarily maintained open source libraries/sources that may at any time fall into disuse, obsolescence or disrepair and require replacement. A common abstract interface will make transition to other platform and libraries possible without redesigning the simulator.
The game interface is made up of the following singleton C++ abstract classes and their implantation: - ISystem( System) – This is the interface class for the railroad simulation game and essentially is the game program itself. The other interface classes can obtain pointers to any other interface class through the System class. The other interface classes are created with a pointer to the singleton ISystem class. ISystem interface will over the games development accumulate platform operating system utility interfaces (time, date, host name, etc.). When these platform system interfaces become significant, an IPlatform or an IUtility interface will be created.
- ISimulatorComponent – This abstract class is the base class for railroad simulator interfaces classes. The ISimulatorComponent class provides a common interface for dispatching components as the simulation game loop is run. System, the implementation class for ISystem, dispatches game operations to each interface for startup, shutdown and normal passes during the game loop. Additionally, System maintains a system state which is used during the game loop to run a particularly component’s foregrounded and/or background processes.
- IGraphics(Graphics) – This component display 3D graphics for the game. At this stage of development only three interfaces are implemented in the Graphics class; isClosed() – The render window is closed, isVisible() – The render window is visible, and getFrameMilliseconds() – returns the elapsed time in milliseconds from the last render. The startup component of the SimulatorComponent interface initializes a place holder scene (a near copy of the CameraTrack in the Ogre Demos).
- ITask(Task) – This component runs scripts. At the current stage of development the class Task has only one interface addScript(), which adds an AngelScript script to a queue for execution in the idle time of the game loop. The startup component initializes the AngelScript library.
- ISound(Sound) – This component plays sounds. No development.
- IAi(Ai) – This component schedules AI scripts. No development.
- IInput(Input) – This component gathers the player input and converts it for the simulator program. No development.
- INetwork(Network) – This component manages network communication. The startup component initializes the curl(libcurl) library.
- IGui(Gui) – This component displays 2D menus on the graphics system. No development.
- IConsoleClient( ConsoleClient) – This component sends and receives commands to/from the Console program. The startup component launches the Console program.
- IFactory(Factory) – This component generates game entities. No development.
- IPropertyManager( PropertyManager) – This component manages user/group intellectual property rights and synchronizes the global database. The global database consists of a svn repository kept in synchronizes during group play. No development.
- ISimulation(Simulation) – This component performs calculation for the railroad simulator. No development.
- ITest(Test) – The Test interface does real-time testing of the train/railroad simulator for program stalls, script stalls and other out of bounds condition. No development.
- ITweaker(Tweaker) – Does input and output of tweaker values to the Console program. These values will allow adjustments while developing simulator. This function will also be used by the simulator players to build and design models. No development.
|
|
Last Updated on Wednesday, 03 June 2009 08:10 |