mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
reverse y loop in GetCollidingTiles to account for gravity usually pointing down
This commit is contained in:
parent
053aaaf17c
commit
f2df639f9e
1 changed files with 3 additions and 3 deletions
|
@ -83,12 +83,12 @@ namespace MLEM.Extended.Tiled {
|
||||||
public IEnumerable<TileCollisionInfo> GetCollidingTiles(RectangleF area, Func<TileCollisionInfo, bool> included = null) {
|
public IEnumerable<TileCollisionInfo> GetCollidingTiles(RectangleF area, Func<TileCollisionInfo, bool> included = null) {
|
||||||
var inclusionFunc = included ?? (tile => tile.Collisions.Any(c => c.Intersects(area)));
|
var inclusionFunc = included ?? (tile => tile.Collisions.Any(c => c.Intersects(area)));
|
||||||
var minX = Math.Max(0, area.Left.Floor());
|
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 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 i = 0; i < this.map.TileLayers.Count; i++) {
|
||||||
for (var x = minX; x <= maxX; x++) {
|
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];
|
var tile = this.collisionInfos[i, x, y];
|
||||||
if (tile == null)
|
if (tile == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue