Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - muhdsalm

Pages: [1]
1
General / Problem with intersections
« on: February 17, 2022, 03:04:29 pm »
Hi.
I'm using SFML.Net, the c# bindings for sfml, and I'm getting a weird logic error.

Here's my code:
public static bool IsColliding(Entity enity1, Entity entity2)
        {
            if (enity1.GetSprite().GetGlobalBounds().Intersects(entity2.GetSprite().GetGlobalBounds()))
            {
                Console.WriteLine(enity1.GetSprite().GetGlobalBounds().Intersects(entity2.GetSprite().GetGlobalBounds()));
                Console.WriteLine(enity1.GetSprite().GetGlobalBounds().Left + ", " + entity2.GetSprite().GetGlobalBounds().Left);
                Console.WriteLine(enity1.GetSprite().GetGlobalBounds().Top + ", " + entity2.GetSprite().GetGlobalBounds().Top);
                return true;
            }
           
            return false;
           
        }
(how do I format code?)

As you can see, it's a simple function, which returns true if the sprites collide, and false if they don't. I also added some writeline() statements for debug.

Weirdly, this is the output I get:

True
342, 260
-40, 350

How? How is it returning true if the rectangles are obviously not intersecting?

(Also, this is my first time at the forum, so forgive me if this is not a correct type of problem in the correct type of section, etc.

Pages: [1]