I have a grid like the image below which I want to put in an array in this format:
;x = wall(black cells and grey boxes), s= start (red circle), g = goal(b
looks like you have the view with fixed angles
create function that converts screen position to grid position and back. It should be easy just 2x
linear interpolation. if the camera pan is not with cell based step then you need the corner point of grid lines and use that as a start point ...
for example something like this (hope I measured the pixels correctly):
x = 236 + (+(u-uh)-(v-vh))*60;
y = 133 + (-(u-uh)-(v-vh))*30;
60,30
is the cell size in x,y
(236,133)
is position of center of mid cell (uh,vh)
in pixelsuh,vh
are coordinates in your grid of center celladd the views pan offset to (uv,hv)
or (236,133)
now just compute the also the reverse transform from this (u=?,v=?)
. Do not forget that the map is not rectangle! It is something like this:
0000x0000,
000xxx000,
00xxxxx00,
0xxxxxxx0,
xxxxxxxxx,
0xxxxxxx0,
00xxxxx00,
000xxx000,
0000x0000,
create a set of images of all objects that you can encounter
this can be done on the run, each time you do not found a match add cell to item list as new object type.
loop through all grid cell locations and compare to object types
for pixel precise rendered images you can compare directly pixels 1:1 if that is not the case the you need to compare objects more robustly. But to make a valid algorithm we need to see all the types of object you can encounter usually you can compare:
do not forget to mask comparison to area of cell only to not include the neighboring cells on corners of bounding rectangle
[Notes]
Can not be more specific without further info