@James_Maslaki wrote:
For my game the character can land on top of platforms but can't collide left and right. My if statement for touching
the left of a rectangle doesn't do anything. Here's code:foreach (player player in Players){ foreach (platform platform in Platforms){ if (player.hitbox.isOnLeft(platform.hitbox)){ player.cantmoveright = true; } }
the bool cantmoveright works for sure. i even checked in the draw method by drawing string
(Players[0].hitbox.isOnLeft(Platforms[0].hitbox)).ToString();
and still nothing. false.
here's the class for the TouchLeftOf bool in it:
static class RectangleHelper { const int penetrationMargin = 5; public static bool isOnLeft(this Rectangle r1, Rectangle r2) { return ( r1.Left >= r2.Right - 1 && r1.Left <= r2.Right + 1 && r1.Bottom >= r2.Top + penetrationMargin && r1.Top <= r2.Bottom - penetrationMargin ); } }
it just doesn't even respond
Posts: 4
Participants: 3