public bool collisionOnlyTiles(World world, float x, float y, Rectangle r, bool ignorePlatforms = false) { for (int i = (r.Left / World.tileSizeInPixels); i < (r.Right / World.tileSizeInPixels) + 1; i++) { for (int j = (r.Top / World.tileSizeInPixels); j < (r.Bottom / World.tileSizeInPixels) + 1; j++) { Tile t = world.getTileObject(i, j, World.TileDepth.tile); if (t != null) { if (t.isSolid(world, i, j)) { return(true); } if (!ignorePlatforms && t.isPlatform(world, i, j, World.TileDepth.tile)) { if (r.Bottom <= ((j + 1) * World.tileSizeInPixels) && speed.Y >= 0) { return(true); } } } } } return(false); }
public bool collisionCustom(World world, float x, float y, World.TileDepth tileDepth) { Rectangle r = new Rectangle((int)(position.X + x), (int)(position.Y + y), (int)size.X, (int)size.Y); for (int i = (r.Left / World.tileSizeInPixels); i < (r.Right / World.tileSizeInPixels) + 1; i++) { for (int j = (r.Top / World.tileSizeInPixels); j < (r.Bottom / World.tileSizeInPixels) + 1; j++) { Tile t = world.getTileObject(i, j, tileDepth); if (t != null) { if (t.isSolid(world, i, j)) { return(true); } } } } return(false); }