C
Calvix
Guest
Hi there guys, iv'e been strugling with a problem for a week now and i could really use some help, for some context im trying to implement field of view using the ray casting method (iv'e adapted a method from roguebasin to gml), everything is working fine except one thing, so i keep a ds_grid filled with positions, asi in x and y corrdinates of the map, so at some point the grid might look something like
what i need to do is to remove duplicate entries from the grid, so every position in the map is only holded once by the grid. To do this i thought of just sorting the grid by column and then compare the values with the previous value and delete when duplicates apear. The thing is that i can only sort by one column at a time, wich means that repeated values aren't always adjacent to one another, if i paste them as an array youll see what i mean:
as you can see the first column is sorted properly but the second isn't. I don't know how to even aproach this problem anymore, any help would be great! Also if there is a solution that dosen't involve sorting the grid im all ears, i just thought this would be the "propper" way to solve it but right now i don know how to achieve such a sort. Thanx a lot!
GML:
grid[# 0, 0] = 1
grid[# 0, 1] = 4
grid[# 1, 0] = 1
grid[# 1, 1] = 3
grid[# 2, 0] = 1
grid[# 2, 1] = 5
grid[# 3, 0] = 1
grid[# 3, 1] = 3
grid[# 4, 0] = 2
grid[# 4, 1] = 3
grid[# 5, 0] = 2
grid[# 5, 1] = 5
grid[# 6, 0] = 2
grid[# 6, 1] = 6
GML:
[ 1,4 ]
[ 1,3 ]
[ 1,5 ]
[ 1,3 ]
[ 2,3 ]
[ 2,5 ]
[ 2,6 ]
[ 2,2 ]