Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:48:19+00:00 2026-06-18T08:48:19+00:00

Im making a 2d game in XNA. I started off using drawable game components

  • 0

Im making a 2d game in XNA. I started off using drawable game components and was quite happy. Every sprite is derived from drawable-game-component and each one has its own begin/end statement (even each tile making up a wall).
Ive since realised after reading around a bit that this is a bad way to do it for performance.

Now I’m wondering what is a good way to do it…
Lets say for each room in my game I do…

_spritebatch.Begin(SpriteSortMode.Deferred,
                       BlendState.Opaque,
                     SamplerState.LinearClamp,
                DepthStencilState.Default,
                  RasterizerState.CullNone,
                                  null,
                         _camera.Transform);

for (each block in Blocklist)
{
    _spritebatch.Draw(block._txture,
                      block._position + block._centerVect,
                      block.txtrect, block._color,
               (float)block.txtrot,
                      block._centerVect, 
                          1.0f,
              SpriteEffects.None,
                            0f);
}
_spritebatch.End();

the reason I’m asking is I’ll have to make loads of the fields in each block public so the Room class can get at them to do its _spritebatch.Draw eg. block._position

I’m assuming this wont really matter and performance will improve but is there any nicer architecture anyone can recommend to do this?

Also since that code is up there, can anyone comment on the SpriteBatch.Begin paramaters I’m using? Are they the fastest ones? All I need in there is the transform

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:48:20+00:00Added an answer on June 18, 2026 at 8:48 am

    the reason I’m asking is I’ll have to make loads of the fields in each
    block public so the Room class can get at them to do its
    _spritebatch.Draw eg. block._position

    Assuming you have many rooms and in each room many blocks, you can give each room and each block a public or protected Draw() method, then all the fields of the block do not need to be public.

    class Block
    {
      ... // private fields about Block
      ...
    
      Public void Draw(GameTime gt, SpriteBatch sb)
      {
         sb.Draw(private block fields here);
      }
    }
    

    Then for the Rooms

    class Room
    {
      ... // private fields about room
      ...
      List<Block> blocks;
    
      Public void Draw(GameTime gt, SpriteBatch sb)
      {
         sb.Draw(private room fields here);
         foreach(Block b in blocks)
             b.Draw(gt, sb)
      }
    }
    

    Then in the main game class

    //fields section
    List<Room> rooms;
    
    
        // in the Draw
    
        spriteBatch.Begin();
          foreach(Room r in rooms)
              r.Draw(gt, spriteBatch);
        spriteBatch.End();
    

    In this scenario, there is a single Begin/End block for the whole frame.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a 2d game in XNA. When using drawable game components which one
I'm making a simple game using the Windows Phone Silverlight and XNA Application type
I'm planning on making a casual word game for WP7 using XNA. The game
I am making a game using C# with the XNA framework. The player is
I'm making an XNA game. When I started, I had a broadband connection with
I'm making a game using XNA framework, so I use a lot functions that
I am currently making a golf ball game using C# and XNA. So far
I am making a game on a WP7 device using C# and XNA. I
I'm making a 3D game in XNA using Ox Engine. There is very little
I'm making a multiplayer game in XNA 4.0, using the .NET socket classes. Since

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.