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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:22:18+00:00 2026-06-13T20:22:18+00:00

I have a problem which I can’t seem to find a different solution for

  • 0

I have a problem which I can’t seem to find a different solution for at the moment that is a bit more efficient to my current idea.

I am making a little game with XNA which will have a randomly generated path to move along, but I don’t know how to separate the textures above and below the lines, since the lines are randomly generated. I hope this image can explain the problem:

enter image description here

So the line(s) are randomly added. My own idea was to create a lot of rectangles with different heights and position them next to each other, but I think that is a little bit inefficient and it also forces me the line to be thick enough such that the rectangle can be a bit wider than only 1-2 pixel, otherwise you might see some “emtpy” spots near the line.

If anything is unclear, please feel free to ask and I will add it to the question, but I think my problem should be clear enough.

  • 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-13T20:22:19+00:00Added an answer on June 13, 2026 at 8:22 pm

    You could replace pixels you don’t need with transparent pixels:

    //extract pixel data from texture
    Texture2D topTexture = ...
    Color[] topTextureData = new Color[topTexture.Width * topTexture.Height];
    topTexture.GetData<Color>(topTextureData);
    
    for(int x = 0; x < topTexture.Width; x++)
    {
        //depending on how you represent lines, set transparent all the pixels at and below line
        //basically, for each x dimension, you find where the line is - you have to
        //write the method for getting this y, as I don't know how you represent lines
        int lineY = GetLineYAtThisX(x);
    
        //all the pixels at (and below) the line are set transparent
        for(int y = lineY; y < topTexture.Height; y++)
        {
            topTextureData[x + y * topTexture.Width] = Color.Transparent;
        }  
    }
    
    //save this data into another texture, so you don't ruin the original one.
    Texture2D maskedTopTexture = new Texture2D(GraphicsDevice, topTexture.Width, topTexture.Height);
    maskedTopTexture.SetData<Color>(topTextureData);
    

    You don’t even have to do this for the bottom one, just draw the top one above it.

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

Sidebar

Related Questions

I have a problem which i can't seem to find the solution to. I
I have a small problem which I can't seem to find a solution to.
Once again I have a problem which I can't find the solution to. A
I have a problem which has an solution that can be solved by iteration,
I have a problem which I can't find a solution. I have a Parent
I have a problem which I can't find a solution to. I have an
I have a unique problem to which I can not find a solution. I
I have a problem which seems simple, but I can't find an elegant solution
I have a small problem which i can't seem to figure out. I tried
I have a small problem which i can't seem to solve myself. Look at

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.