Original Post
Hi all people, I just want to start by saying this really is a great place to learn all kinds of things about game programming.
Well, I've been playing with C++ for quite a long time now, and a while back I wrote Spacewar-SDL:
www.sourceforge.net/projects/spacewar-sdl
As you will see if you look at the code, the design of the game is horrible. The design process was not much more than:
1. Hey cool star screen. Let me put two ships in it!
2. Cool two ships! Now get them moving.
...
It took me two weeks to get a fun version, the original version somewhat less. But the time was spent well, I learned alot, especially about object oriented programming.
But now I am busy some with C# (please please please don't start the war again), and I really like some OOP features it has. But I would like some comments on my current engine design, which I am currently using to reïmplement Spacewar-SDL on a better way. This is how far i have come:
- IGraphicsObject, IPhysicalObject and IUpdatedObject interfaces, the name sais it all.
- The Kernel class. It is static, and it contains the game loop, and methods that do some things.
- The GameState class. Static, and it contains only some data on the current game state.
- The GraphicsSubsystem class, which contains a list of all IGraphicsObject instances that need to be drawn at that time.
- The UpdaterSubsystem class, which will handle all updates, and sends messages to all IUpdatedObject instances.
- The CollisionDetector class, which, well, checks for collision detection and sends messages to objects like "Hey SHIP RED, you were hit by LASER RED, handle it!"
Now, I just do not know if this is a good way to do things. Now I am getting very strange peices of code (from the Ship class):
public void Collision(ICollisionObject Other)
{
if(Other.Identifier.Player != _Identifier.Player &&
Other.Identifier.Type == "LASER");
{
_HP -= 1;
// the laser destroys itself
if(_HP <= 0)
Kernel.ShipKill(this);
}
}
Is this a good way to do this? Call the Kernel to do things like this, or should they be done at the Ship class?
And does anyone have any comments on the general design of the engine?
And is, looking at the above code, the border between engine and game fading too much?
As last, are there good articles at the design of an engine, not the implementation?
-
CL Game Studios. Probably.
[edited by - Sijmen on November 24, 2003 3:44:46 PM]