Closed ignacioxd closed 6 years ago
The grid system implemented on the dev branch works great. To add pathfinding we can use the map.getTileAt(x, y); method. Each tile needs to have a "walkable" property, then if we change the map dynamically, the pathfinding still works!
After this implementing A* should be really simple.
Maybe we can add a collision layer, so that it can be inspected dynamically and consistently across maps.
This was partially addressed on #14. We now have a grid system with tile alignment and an asset that tracks the hovered tile. We still need to identify when a particular tile is clicked. Once that's working, we should differentiate blocked/available tiles, perhaps using the collision layer I mentioned earlier. Then, shortest path between two tiles.
I have this code mostly worked out, I am going to add a little element that displays the Tile properties below the overlay region to make it easy for people to understand how to access tiles properly.
Okay so rough update.
The new grid system is cool, but it is redundant. The built-in tilemap system saves us the hassle of even having a grid object or individual grid units. The way the code is set up now, our json tiles are not connected at all to the grid we are manually creating.
In demoscene when we create a tilemap, everything done in our new grid system already takes places under the hood of phaser.
https://labs.phaser.io/edit.html?src=src\game%20objects\tilemap\static\tile%20properties.js
This example shows the way we can easily take a phasr 3 tilemap and have it ready for pathfinding. If we stick with our current plan, we will need to reinvent the wheel when it comes to the tilemap system, and things will get difficult fast!
This makes sense. Using the native functionality is preferred. Thanks for figuring this out.
I think a dedicated feature branch for this might be useful. What do you think?
I do think that is a good idea.
I think the difficulty level on this project is pretty high for new people. 2d grids are not easy, and with phaser 3 only a few months out of the dev box, there is going to be a lot of hair pulling trying to figure out the back end of the game. On the website it says to use phaser CE until p3 is out of alpha, but of course they want people to be using and helping on the newest version which is a lot more functional.
I'll create the grid branch and update here so that you can work there on the grid.
Steep learning curve for sure. Since the documentation is currently lacking, I've been looking at the source code directly to get a better understanding of the API. It's a bit tedious, but I've found it a good exercise.
Do you think we should switch to Phaser 2/CE?
There are two modes of thought here, and I think both are worth looking at.
I think option 1 is more viable because the games difficulty level itself is pretty high for a first time game situation. 2d grids, pathfinding, inheritance and the battle system later are not really beginner topics nor are they documented super well on the internet (especially advanced battle systems based on character attribute inheritance).
We are picking two hard battles. We need to either reduce the scope of the game, or probably go to CE so people at lower levels can contribute without pouring through google like we probably all have been.
Those are good points.
I would be opposed to reducing the scope of the game, especially if that contributes to bring more people in. I'd rather continue working on Phaser 3. The main reason for me is that I prefer to learn the newer API, rather than learn an API that is already deprecated. The problem, of course, is availability of documentation and examples, as you well point out.
What would be your ideal reduced-scope game?
Based on recent discussions, we've chosen to reduce the scope of this game. A 2D grid, as described here, is no longer needed, so I'm closing this issue.
This is related to #8. We need to incorporate Phaser's grid alignment system so that each character is always aligned to a cell.
Once a target cell is identified (see #8), we need a pathfinding algorithm that calculates the best path in this grid with only vertical and horizontal movement. This algorithm should be able to calculate how many cells are needed to reach a destination along the chosen path.