Skip to content
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

Transitional tiles #70

Open
Qualphey opened this issue Apr 29, 2019 · 2 comments
Open

Transitional tiles #70

Qualphey opened this issue Apr 29, 2019 · 2 comments

Comments

@Qualphey
Copy link

I'm looking for a way to make transitional or "bridge" tiles, that could connect two other tile types.

I.e.
Imagine that 0 is terrain, 1 is stairs and 2 is a wall.

let grid = [
  0, 0, 0, 0, 0, 0,
  0, 2, 2, 0, 2, 0,
  0, 2, 0, 0, 2, 0,
  0, 2, 0, 1, 2, 0,
  0, 2, 2, 2, 2, 0,
  0, 0, 0, 0, 0, 0
]

All tiles (0, 1, 2) should be acceptable, but in order to get from 0 to 2 or vice versa, 1 must be crossed.

I can't find a built-in feature to support this and the directional conditions are not exactly what I'm looking for.

Any suggestions?

@johnhorsema
Copy link

You first run an algorithm to make some 2's become 0 whenever there is a bridge at top or bottom:

0
1
2

or

2
1
0

Then just run the pathfinding algorithm normally to get the path.

@esromneb
Copy link
Contributor

esromneb commented Oct 26, 2020

You can do this by using the setDirectionalCondition() function. You need to write code to loop over your entire grid and decide which direction tiles can be entered from. Based on your example, [1][1] can only be entered from the right and the bottom. While [3][3] can be entered from all directions. I am doing this exact thing in my code, however I have 10 levels, not just 3. I may be able to post some code if you wish.

Here's an example, the top is my grid, the bottom is my path, where step 0 is A, and step 1 is B etc. The path is only allowed a difference of 1, and no diagonals are allowed:

Screenshot from 2020-10-26 03-07-12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants