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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:35:50+00:00 2026-06-19T03:35:50+00:00

I understand the theory behind Per Pixel Collision in Xna, you get the texture

  • 0

I understand the theory behind Per Pixel Collision in Xna, you get the texture data from two textures, and then compare them, checking the alpha values of, for example, your character texture.

What I’m wanting to do is use Per Pixel Collision to check if the Player Sprite has touched the map by checking for collisions with a certain colour (Black). I’ve tried implementing this before, but the characters always falls through the map with no programming errors thrown.
Please point me towards articles/tutorials/videos, or if anybody here could give me some tips and points that would be great too.

  • 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-19T03:35:51+00:00Added an answer on June 19, 2026 at 3:35 am

    I would not check pixel to pixel between two textures, if I were you. Checking just one point vs a map is not too bad, though;

    //In Class-scope:
    Color[] CollisionMapData;
    Texture2D CollisionMap;
    
    public void LoadContent()  
    {  
        CollisionMap = Content.Load<Texture2D>("map");  
        CollisionMapData = new Color[CollisionMap.Width * CollisionMap.Height];  
        CollisionMap.GetData<Color>(CollisionMapData);  
    }  
    
    public Boolean Collision(Vector2 position)  
    {  
        int index = (int)position.Y * CollisionMap.Width + (int)position.X;
    
        if (index < 0 || index >= CollisionMapData.Length) //Out of bounds  
            return true;
    
        if (CollisionMapData[index] == Color.Black)
            return true;
    
        return false;
    }
    

    To check the entire player-sprite against a map, you would have to call the Collision-method for each pixel in the players sprite, creating a vector2 to get the right point.
    It is a lot easier to check maybe a few points (for instance; topleft, topmiddle, topright, left, right, bottomleft, bottommiddle, bottomright. No need to check middle because sides are already being tested.)

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

Sidebar

Related Questions

I understand the theory behind the factory design pattern now, but can't seem to
I want to understand the actual theory behind types rather than just learning about
I don't understand the exact algebra and theory behind Haskell's monads. However, when I
I have a stored procedure that works correctly, but don't understand the theory behind
I just read some stuff about the theory behind 3d graphics. As I understand
I basically understand the theory behind using the Hough Transform to detect parabolas (i.e.
I understand the theory behind incompatible serialVersionUIDs (i.e. you can discriminate different compilation versions
I understand the theory of matrix multiplication, I just have two questions about this
I'm trying to understand the main concepts of graph theory and the algorithms within
I understand, from MSDN, that ClassInitialize is to mark a method that will do

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.