-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Walls with several sides #185
Comments
Take a look at the getNeighbors function: |
My idea would be very similar to your sub-squares. you would just store the information of the 8 neighboring cells in a sub-cell not as own grid but as in binary, so you only need 8 bit to represent it. In the getNeighbors-function you would then extend the if for all directions, using the bitwise operators AND and right shift, something like this (assuming you store a
and the same ( Note that I switched it up, 1111 would allow your path finder to go in all 4 directions while 0000 would block everything. |
Alternatively you could completely go with your solution and extend the getNeighbor-function to check the sub-cell and return only the center of the next cell if it is walkable, so for the path finding algorithm it looks like the same map as before (I prefere my solution which should be less memory-consuming but very similar to implement). |
Hi Brean. It works like a charm !
So, I coded according to your answer:
Now, I have 16 possibilities of blocking inside a cell. This goes from the classic wall (0, [0000]), to the free cell (15, [1111]) |
Yeah, awesome work! I would need to store this |
Hi. Is it possible to have walls with several sides ? That is to say that we can enter in the "square", but that we can only exit from certain sides. (See my drawing for explanations).
Thanks for help.
The text was updated successfully, but these errors were encountered: