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 8561119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:25:49+00:00 2026-06-11T16:25:49+00:00

I’m working on a 2D top down map generation algorithm where all I’m creating

  • 0

I’m working on a 2D top down map generation algorithm where all I’m creating are rooms that have a Point for top/left and a Point for bottom/right. All rooms are rectangular and do not overlap on any part except some occasionally share walls.

My question is, when I have two rooms that end up sharing a wall between them, how would I quickly and easily spit out a list of ’tiles’ (or Points) that are shared by both rooms within said wall?

I’m kind of hoping for something like:

private List<Point> SharedTiles (Point P1, Point P2, Point P3, Point P4)
{
    /*
    P1 = Top Left point of room1
    P2 = Bottom Right point of room1
    P3 = Top Left point of room2
    P4 = Bottom Right point of room2
    */
    List<Point> _SharedTiles = new List<Point>();
    //Magic goes here...
    return _SharedTiles;
}
  • 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-11T16:25:51+00:00Added an answer on June 11, 2026 at 4:25 pm

    Given two rooms, A and B:

    I am assuming that the points specified do not include the walls of the room. If this is incorrect, you can skip the rectangle inflation in the first step.

    Represent each room as a Rectangle that is extended one tile in each direction to account for the walls:

    var roomAreaA = new Rectangle(a1.X - 1, a1.Y - 1, (a2.X - a1.X) + 2, (a2.Y - a1.Y) + 2); 
    var roomAreaB = new Rectangle(b1.X - 1, b1.Y - 1, (b2.X - b1.X) + 2, (b2.Y - b1.Y) + 2);
    

    Intersect the room areas:

    var roomIntersection = Rectangle.Intersect(roomAreaA, roomAreaB);
    

    The resulting rectangle will represent the intersection between the areas of the two rooms. Since you’ve stated that rooms can only share wall tiles, it necessarily follows that all of the tiles in this intersection area will be wall tiles.

    If necessary, you can convert this rectangle into a list of Point objects. I would not necessarily recommend the method below, depending on how this is being used, but it communicates the point:

    var p = from x in Enumerable.Range(r.X, r.Width)
            from y in Enumerable.Range(r.Y, r.Height)
            select new Point(x, y);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
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
I have a text area in my form which accepts all possible characters from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
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
I have a jquery bug and I've been looking for hours now, I can't

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.