public boolean isTraversable(Rectangle r) {
        if (r.x / Tile.WIDTH < 0 || r.y / Tile.HEIGHT < 0 || r.x / Tile.WIDTH >= WIDTH || r.y / Tile.HEIGHT >= HEIGHT)
            return false;
        ArrayList<Tile> tilesunder = new ArrayList<Tile>();
        for (int i = 0; i < WIDTH; i++)
            for (int j = 0; j < HEIGHT; j++)
                if (r.intersects(tiles[i][j].getBounds()))
                    tilesunder.add(tiles[i][j]);

        for (Tile t : tilesunder)
            if (!t.isTraversable())
                return false;
        return true;
    }