Jump to content
  • Advertisement
Sign in to follow this  

Need component and game organization advice

This topic is 2149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wasn't sure where to post this...the beginner area or here since I'm working in XNA.


I've made good progress as a programmer.  I'm either an advanced beginner or on the bottom half of being an intermediate programmer.  That said, I am working on some simple games in XNA and have gotten some basic things working (working, but probably coded very inefficiently).  So I've been scouring the internet trying to find ways to organize classes and my search has me uncovering things like components and gamestates.


So here is what I need help with.  The mantra is to organize your code into efficient, manageable pieces/classes/components so they can be reused.  But the more "pieces" I make, the more trouble I am running into trying to get those pieces to "see" each other.  When my code is inefficient and bloated, at least I could access what I wanted when I wanted to.


I am making a very simple 2D sci-fi shooter game (think old-school "Lifeforce" for the NES and Space Invaders and Megamania for the Atari 2600).  While technically I have the basics working, I'm wanting to make my code more efficient and reusable for future features in the game as well as a good learning experience for future projects.


Right now I have 5 sprites.  The player's ship, the enemies (in a List<Sprite>), the player's shots and the enemies' shots (each in their own respective lists), and a list for asteroids to randomly come across the screen for an additional hazard.


Here are my questions (for starters :) ):


(and keep in mind that I've done quite a bit of experimenting but the process is extremely frustrating)


1) Should each of those sprites be their own component (drawable maybe?) and updated/drawn from those components?


2) If so, how would a player component work with a shot/projectile component?  I know I can do that via making a projectile object in the player class and updating the shots in there.  Is that the way to go?  Or can the projectile class update itself?  And if that is the way to go, I can't figure out how to get them to see/work with each other.


3) Where do you draw the line to separate those things into separate classes or components?


4) Right now I have a drawable game component that has all these classes feeding into it.  Objects of all of those classes are created in that class and used in there (that's the bloated part).  Bad idea?


5) And would someone mind showing me a "best practice" on how to organize a simple game like this?  I've seen the "there are many different ways to go about it" line often but what I haven't been able to find is a "here is how you can do this".  If I can see that, then I'll have a jumping off point for more testing/experimenting/learning/etc.


Any help is greatly appreciated :).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!