Hey guys! So I'm developing a tile-based game where you move around tiles by tapping the tile you want to move then tapping an open space to solve the puzzle, but I've run into a snag.
I'm trying to get the tiles to only move to the one available open space if it is IMMEDIATELY above, below, or next to it. Currently the tiles are able to move to the open position regardless of their position, but I need them to only be able to move if they're right next to the open spot.
The idea is that I need a way for the tile tapped on to read the distance between itself and the open space. If the distance is too great, it shouldn't be able to move. If it is the right distance, it should be able to move.
Here's a visual of the issue I'm talking about for you visual learners out there.