Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

110 Neutral

About genjihl

  • Rank
  1. Hello. I was wondering if there were any optimization benefits with drawing textures with only calling spritebatch.Begin() and spritebatch.End() once, as opposed to calling .Begin() and .End() for each texture. I understand there are limitations to using this approach, such as not being able to change the SpriteSortMode and BlendState, but I am not worried about that. I am only curious about whether or not designing a drawing system like this would have a significant affect on a game's performance. An explanation regarding the "expense" of calling a spritebatch's .Begin() and .End() functions would be appreciated! Thanks!
  2. You're right, it does. I'll use that instead. Thanks everyone!
  3. Hello, please let me know if I'm being way too nit picky or paranoid about my game's performance with my query: To see if my mouse intersecting a Rectangle (in XNA), I've thought of two ways: 1. Check if the object's Rectangle intersects with a new Rectangle created at the mouse's position. Or 2. Initialize a rectangle to follow the mouse around, and update its position every time Update() is called, and when the check occurs, simply provide the mouse's Rectangle. Assuming the check is called very frequently (whenever other classes want to know if the mouse is hitting anything important), which method would be the most efficient? And, is this difference even significant? If you'd like to see what I mean in code: //Option #1 class MouseInput { [indent=1]MouseState lastState; [indent=1]MouseState currentState; [indent=1]public bool Intersects(Rectangle rect) [indent=1]{ [indent=2]return rect.Intersects ( new Rectangle ( currentState.X, currentState.Y, 1, 1) ); [indent=1]} [indent=1]public void Update() [indent=1]{ [indent=2]lastState = currentState; [indent=2]currentState = Mouse.GetState(); [indent=1]} } //Option #2 class MouseInput { [indent=1]MouseState lastState; [indent=1]MouseState currentState; [indent=1]Rectangle mouseRectangle; [indent=1]public void Initialize() [indent=1]{ [indent=2]mouseRectangle = new Rectangle ( currentState.X, currentState.Y, 1, 1); [indent=1]} [indent=1]public bool Intersects(Rectangle rect) [indent=1]{ [indent=2]return rect.Intersects ( mouseRectangle ); [indent=1]} [indent=1]public void Update() [indent=1]{ [indent=2]lastState = currentState; [indent=2]currentState = Mouse.GetState(); mouseRectangle.X = currentState.X; [indent=2]mouseRectangle.Y = currentState.Y; [indent=1]} } [/quote] Thanks in advance for the help!
  4. Thanks for the help everyone. I'm beginning to recognize the benefits to loading ships' data from a file. I admit I'm not used to working this way, but I realize storing/loading data from files an important skill to have, so it's about time I get used to it. To answer your question, jefferytitan, all of the Ship types are the same. There won't be any differences in behavior, only properties (health, shields, etc.). The class (or classes) would be used to produce multiple instances each, as you described (e.g. 30 Fighters, 5 Dreadnoughts). I will go with your suggestion and try using XML to supply my Ship objects with their default data.
  5. Thanks for the quick reply. I'm sorry but I didn't fully understand your suggestions. It sounds like I shouldn't create sub-classes of the Ship class and instead store different ships' default values in an XML file, regardless of the class' complexity. I'm curious, why do you recommend storing default values in an XML file? It seems more convenient to simply hard code the default values into the program. And, is there anything bad about creating sub-classes in this case?
  6. I'm working on a game where I will manually construct a large number of Ship objects (100+), each with their own unique stats, but, of course, sharing the same properties and methods. Someone suggested I should create a sub-class for each different ship to accomplish this, but this goes against my intuition. However, I don't know what would be bad about this approach either. This approach is tempting because I would be able to quickly access a particular subclass object with my IDE's auto-fill feature when I begin typing its name. Is there a performance cost or disadvantage to creating sub-classes in this manner, where I could just create instances of the same class instead?
  • 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!