Just a suggestion: DIM a 2D array that will keep your world and use that instead of reading pixels from screen.For example:
Now our world array is a 100x100 table that contains 0. Let's assume that 0=nothing in our world
for i=1 to 100
Now our world has the value 1 at its edges. Let's assume that 1=walls.
for i=1 to 500
That put some random walls in our world. Nothing fancy but it'll do the trick.
Let's assume that 2=your player.
Now, you can use that array to modify your world and render it. You can keep your player's x,y coords into 2 variables (player_x,player_y) and when you move him just write 0 to the old position and 2 to the new. There are plenty of ways to render the array to screen. One of the easiest one is
for y=1 to 100
for x=1 to 100
Of course this is really slow and just represents each block in the world with one pixel! You can use a lot of different methods like drawing (say) 16x16 boxes instead of a single pixel, or replace them with sprites - which means that you don't have to render the full world in one screen. In any case, the core principle remains the same: use one array to keep the status of your world and use it for everything.
Hope this helps!