After many years I figured this out. After doing array level editors and checking values inside the arrays, if its a obstacle or not. I found there is a test for obstacle. Now you can check for your 2d games. If a enemy is near an obstacle left, right up and down or what ever coordinate you wish. I wish i knew this years ago. I Linked an example you can see for yourself, This is based on a 32x32y tile grid for example you can have what ever values you want.