Should I Actually USE GameComponent?

GameComponents look interesting, but why would I bother to use them in my game when I can just write my own cascading Update methods Same thing for DrawableGameComponent, IDrawable, and all that. Is there some future engine functionality I can leverage using these classes / interfaces Because I don't see any actual use for them right now.

Thanks!




Answer this question

Should I Actually USE GameComponent?

  • GoDaddy

    I can see how it could be useful for beginners. Sometimes normal flexibility is too much. I have seen some reaaaaally poorly structured beginner indie program code out there, and this framework could go a long way towards helping beginners get started on the right foot instead of tripping on their way out of the gate.

    But for professionals who are experienced enough to safely play outside the box, it loses its utility do to its lack of flexibility.

    The only reason this was an issue for me is because I thought I might miss out on a large chunk of advanced functionality if I side-stepped the GameComponent framework. This doesn't seem to be the case though, so I'll just go ahead and skip it.

    Thank you all for your help!



  • Mike Oleary

    It may take YOU 5 minutes of programming time, but for another programmer, who is not as experienced as you, this piece of code written by the XNA guys counts.
    "Every line of code you write should count for your game" or something like that is what XNA is about.
    A beginner game programmer just wants make something happen, not spend several days researching and implementing (maybe rewriting code several times) a framework for Update / Draw . For him, the fact that MS took 5 minutes out of theirs precious time to write this counts enourmously in boosting his self confidence and allowing him to enjoy game programming right from the start.
    On the other hand, if someone wants more flexibility, they are free to discard the Components Framework and write their own. The same reasoning can be applied to other areas of XNA: Conent Loading, Windows Initialization, Resource Management, Game Loop... They may not save some developers too much time, but they are a blessing for countless others.


  • csLearner

    bryanedds wrote:
    ...when I can just write my own cascading Update methods

    You answered your own question.



  • irs

    bryanedds wrote:
    But for professionals who are experienced enough to safely play outside the box, it loses its utility do to its lack of flexibility.

    What lack of flexibility Inherit from it and do what you need.



  • bsam

    GameComponents go a long ways to supporting the goal of Encapsulation under XNA. It allows you to abstract portions of your game code that perform a well-defined function and then reuse that component later.

    Also, under Windows at least, you might use a game component created by someone else that you don't have the source to but just a .DLL for.

    Finally, you need to understand that when you use GSE, you are allowing the XNA team to prescribe a certain level of architecture for your game that is generally useful for beginning game developers. They set up the draw and update loops automatically, handle the display, etc. They have made decisions on how to do these things that you choose to live with when using GSE. You can always just use the XNA framework without GSE and do everything manually (you don't even need to use C# Express in that case... remember that XNA is just a .NET assembly when it comes down to it, and GSE is mostly an IDE wrapper around XNA and C# Express). Of course, if you do that, you won't have access to the Content Pipeline and it will be difficult (at the very least) to move your game to the 360, but you can do it that way if you choose.


  • zot166249

    So they introduced this entire GameComponent framework to save me 5 minutes worth of programming

    Why would I couple my code with an external set of interfaces and classes just to save myself a few minutes of programming Why would I surrender so much control to external forces for so little benefit Maybe my Update method will need more parameters than just GameTime Same for my Draw method

    Maybe this GameComponent framework should be scrapped. Seems like they're overstepping their bounds as library writers. Perhaps stick to writing code libraries and pull away from this framework stuff. The framework stuff is what the game developer writes anyways. Unless of course, there are solid plans to put some non-arbitrary functionality into the framework.

    I appreciate your response, but I feel the need to relay my concerns more fully so that I might receive a more convincing answer.

    Thanks!



  • Should I Actually USE GameComponent?