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

  • Home
  • SEARCH
  • 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 679241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:14:18+00:00 2026-05-14T01:14:18+00:00

I’m creating a 2D tile-based RPG in XNA and am in the initial design

  • 0

I’m creating a 2D tile-based RPG in XNA and am in the initial design phase. I was thinking of how I want my tile engine to work and came up with a rough sketch. Basically I want a grid of tiles, but at each tile location I want to be able to add more than one tile and have an offset. I’d like this so that I could do something like add individual trees on the world map to give more flair. Or set bottles on a bar in some town without having to draw a bunch of different bar tiles with varying bottles.

But maybe my reach is greater than my grasp. I went to implement the idea and had something like this in my Map object:

List<Tile>[,] Grid;

But then I thought about it. Let’s say I had a world map of 200×200, which would actually be pretty small as far as RPGs go. That would amount to 40,000 Lists. To my mind I think there has to be a better way. Now this IS pre-mature optimization. I don’t know if the way I happen to design my maps and game will be able to handle this, but it seems needlessly inefficient and something that could creep up if my game gets more complex.

One idea I have is to make the offset and the multiple tiles optional so that I’m only paying for them when needed. But I’m not sure how I’d do this. A multiple array of objects?

object[,] Grid;

So here’s my criteria:

  • A 2D grid of tile locations
  • Each tile location has a minimum of 1 tile, but can optionally have more
  • Each extra tile can optionally have an x and y offset for pinpoint placement

Can anyone help with some ideas for implementing such a design (don’t need it done for me, just ideas) while keeping memory usage to a minimum?

If you need more background here’s roughly what my Map and Tile objects amount to:

public struct Map
{
    public Texture2D Texture;
    public List<Rectangle> Sources; //Source Rectangles for where in Texture to get the sprite
    public List<Tile>[,] Grid;
}
public struct Tile
{
    public int Index; //Where in Sources to find the source Rectangle
    public int X, Y; //Optional offsets
}
  • 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-05-14T01:14:18+00:00Added an answer on May 14, 2026 at 1:14 am

    What you could do is simply have an array of Tile:

    class Grid
    {
        Tile[,] grid;
    }
    

    … and have that Tile class have a List<Sprite> in it:

    class Tile
    {
        List<Sprite> sprites;
    }
    

    … and that Sprite class would have your texture and offset:

    class Sprite
    {
        Vector2 offset;
        Texture2D texture;
    }
    

    Finalize all that by having draw methods:

    class Grid
    {
        Tile[,] grid;
    
        void Draw(GraphicsDevice graphics)
        {
            // call your tiles Draw()
        }
    
    
    }
    
    class Tile
    {
        List<Sprite> sprites;
        void Draw(GraphicsDevice graphics, int x, int y)
        {
            // call your sprites Draw()
        }
    }
    
    class Sprite
    {
        Vector2 offset;
        Texture2D texture; // or texture and rectangle, or whatever
    
        void Draw(GraphicsDevice graphics, int x, int y)
        {
            // draw the sprite to graphics using x, y, offset and texture
        }
    }
    

    Of course it gets much more complicated than that but you should get the idea.

    Separating all your concerns in different classes let you easily add new fonctionnality that won’t conflict with existing code. Trying to mash all your data in a single object such as your List<Tile>[,] is bad form and will eventually bite you when you try to expand.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.