In previous installments I have discussed how to create the skeleton of a game using C # and Tao.SDL. The problem with this approach is to leave the entire project in a single source makes it increasingly awkward to handle when it is getting bigger, and also impossible (almost) divide work among several people.
Therefore, a reasonable alternative when the project is not very small, it is decomposed into a series classes interact.
For example, in a classic platform game, we would have a "character" that handle a number of "enemies" who attack us, "Awards" to collect, maybe "Shooter" (or weapons otherwise) with which to defend, all coordinated by a class "Game", which was responsible for the run of play, not only to repeat the loop game but to make decisions as
- When we touch an enemy, will lose a life or part of the energy?
- "The enemy dies too when we play?
- When levels are changed? Do you have to collect all the prizes? "Reaching a door?
- Is there time limit to go finish a level? "The time out or lose a life the whole game?
- ...
addition, we may refine a little further and distinguish between a "Game" (a play session) and the whole "game" (that could also include a display screen, a credit on the authors, options to customize it .. .).
If we are practical, we might even create a class "Image", which hide the details of image manipulation with SDL , and a class "Hardware", to conceal the English names of the functions and simplify a tedious task, such as writing text. Thus, further work would cost less to carry our game to another graphics library, as Allegro. And above these helper classes could create other more versatile. For example, over "image" could create a class "ElementoGrafico" which allow animated figures (consisting of a sequence of images), which had basic checks collisions, etc.
And how can do all this? Is there any sample source? Of course, but as it would be too long to read all the sources here, you can download a sample project page "remake of Manic Miner ", hosted on Google Code.
Version 0.01 is only a basic skeleton that shows how they could be above classes, both "infrastructure" (Hardware, Image, ElementoGrafico and another for handling fonts and sounds) such as "logic game (Game Presentation , Lending, Item, Character). Later versions of this project will expand gradually to reach something that is truly "playable"