Structure of my first C++ game

Started by
12 comments, last by mmakrzem 12 years, 9 months ago
Well your game might not be really big or advanced, but you definitely want to make your engine as reusable as possible. That way when you go to make another game you can pick parts of your old engine that would work perfectly. In that sense using singletons and deep hierarchies are BAD as they make code difficult to port due to dependencies. Here is an excellent article that describes some of the benefits of using more aggregation and less inheritance in your GameObjects/Entities.
Advertisement
I find the entity component architecture to be right in concept but a little too extremist, I don't think its wrong to create a few specialization classes from entity if they are relevant to the game and potentially reusable, and then add components to that.

Components are great to create slight variations of a specialized class, or for instance add special behavior to particular entity types, for instance, you have RPG characters, you could implement the differences between a warrior and a mage with components, but I do believe the RPGChar class is still relevant and not that deep a hierarchy.

Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272


I don't use directx (I use SDL/OpenGL) but I don't see how it could matter here. I've never used a GraphicsEngine class before. I've just used a draw() function that would call subsequent draw() functions on other things such as GameObjects and terrain or tiles. Similarly, why the InputEngine? A way that I like to handle input is by forwarding input events to my Player class to alter the players behavior. Why did you create a GameObjects container object? Why couldn't you just abstract it away and use a vector of some sort. You also shouldn't worry about code re-usability for such a small game, especially if you're trying to learn C++.
in the game engine that i created i have a scenegraph that is used to manage all items in a level. within the scenegraph there are nodes that let you specify geometry, textures, materials, etc.

when you are ready to render, just render the root node and all the others get handled automatically.

have a look at my videos

This topic is closed to new replies.

Advertisement