From f2df639f9e42db5ac12f453f0210ec812978f05a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 7 Mar 2021 20:45:00 +0100 Subject: [PATCH] reverse y loop in GetCollidingTiles to account for gravity usually pointing down --- MLEM.Extended/Tiled/TiledMapCollisions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MLEM.Extended/Tiled/TiledMapCollisions.cs b/MLEM.Extended/Tiled/TiledMapCollisions.cs index bbf56ba..485d2c6 100644 --- a/MLEM.Extended/Tiled/TiledMapCollisions.cs +++ b/MLEM.Extended/Tiled/TiledMapCollisions.cs @@ -83,12 +83,12 @@ namespace MLEM.Extended.Tiled { public IEnumerable GetCollidingTiles(RectangleF area, Func included = null) { var inclusionFunc = included ?? (tile => tile.Collisions.Any(c => c.Intersects(area))); var minX = Math.Max(0, area.Left.Floor()); - var maxX = Math.Min(this.map.Width - 1, area.Right); + var maxX = Math.Min(this.map.Width - 1, area.Right.Floor()); var minY = Math.Max(0, area.Top.Floor()); - var maxY = Math.Min(this.map.Height - 1, area.Bottom); + var maxY = Math.Min(this.map.Height - 1, area.Bottom.Floor()); for (var i = 0; i < this.map.TileLayers.Count; i++) { for (var x = minX; x <= maxX; x++) { - for (var y = minY; y <= maxY; y++) { + for (var y = maxY; y >= minY; y--) { var tile = this.collisionInfos[i, x, y]; if (tile == null) continue;