|
||||
Overview: Framework |
||||
Physical's third, and in many ways most important, component is its programming framework. This is a system of data structures and interfaces that put all the abstract concepts of games and objects into a simple, easy-to-work-with layout. Rather like the MFC classes for Windows programming, it consists of a number of pre-created base classes that provide core functionality and are designed to be extended. These base classes are linked together in a tight hierarchy that provide logical game structure and simple program flow.
A symbolic representation of the structure of a game built with Physical The above diagram shows the structure of a game built with Physical. It shows the four basic classes in Physical: Game, System, Renderer, and Object. Game: System: Renderer: Object:
The programmer would then add some sub-objects for the engines. In this case, I presume the existence of another extension of the Object class, Engine, with the method applyForce(float). (In reality, a class very much like this does exist, called Actuator or DActuator.)
Next, the programmer would take advantage of one of Object's built in functions: stepFunc(). An Object's stepFunc() is called every game step.
Now, this is a little bit pseudo code (the Spaceship class needs a constructor and access to the keyboard, and must designate which atoms belong in the engines) but the reality is not very far off, and it demonstrates how easy it really is to create new objects and interaction schemes in Physical. Through using Object's built in functions of stepFunc() and atomFunc(Atom *) (which is called every time an atom inside an object is updated) adding functionality is a snap. A completed game using Physical would therefore consist of a new Game class and a bunch of new Objects. One of the great thing about Objects is that they are totally portable, and if you wanted to mix a tank from one game with a spaceship from another, you would have no trouble doing so. I have already in my demo game work created a number of potentially useful Objects (a grappling hook, for example), and I can see a future in which many game developers working on independent products would slowly build up and share a huge library of Objects, to the point that entire new games could be easily created out of preexisting elements. (Can you imagine a system in which to create a war game, you just have to drop the Objects "Tank", "Plane", and "Soldier" into a common framework?) To this end I've begun work on the Repository, a place where game designers will be able to freely upload and download new game elements. |