XNA GameComponent implementation preferences ...?

I recently jumped into the XNA pool, and am learning all the inputs and outputs of a framework in C #. One thing I noticed in my research is that there seems to be no generally accepted β€œright” way to implement GameComponents.

After reading this thread (among others), I found a wide range of preferences among game developers. I saw how some supporter did not use GameComponents at all (or only sparingly), while others claim to use them in everything, down to players / enemy units, missiles, etc. Then there are some who take a more moderate approach, and reserve the GameComponent architecture for medium and high-level objects, such as screens, renderers, scenes, etc., which, in turn, contain and operate more detailed game blocks.

In the end, the game developer will determine how best to implement the framework. Since StackOverflow is staffed by experienced developers who have forgotten more than I ever found out, I would like to know what consensus is before I continue this journey with my own use of the framework.

Does anyone care about their thoughts? Thanks in advance!

+6
c # xna
source share
1 answer

I am new to XNA, so take this answer with salt.

I think this may come down to style preference. I'm not sure what the performance characteristics are between GameComponent and more manual methods, but I know that for me personally, I was quickly upset trying to use GameComponent, as it really does not interfere with my thinking or programming style. At heart, I am a mixture of the things that I have chosen from OOP, procedural, functional, and other programming paradigms. GameComponent seems to use a strict OOP approach.

But I will say that creating an entire GameComponent or even a class as a whole can be problematic when it comes to performance. The issues of maximum readability and maintainability seem to be on the cutting edge in the game development world, where sometimes you really need to compress the optimization from your code. For example, sometimes it’s better to turn one of your game objects into a structure (value type) so that you can save some memory and stop the disgusting garbage collector from creating a backlog in the game (since I studied this question I asked ).

+2
source share

All Articles