you could create a "map" which is composed by several tiles (32x32 pixel images or whatever) and each tile could have a boolean variable that determines whether or not that particular tile is solid (if solid, nobody can walk on it, for example).
either that, or have an array called impasasble_tiles or something which contain int values (for example, tile_1 is grass, tile_2 is wall), so if the particular tile the player wants to go to is in the impassable_tiles array, then that means he cant go.
there are many ways to go about doing this.