chrismdp / tinyking

Tiny King
GNU General Public License v3.0
8 stars 1 forks source link

Pathfinding #35

Closed chrismdp closed 3 years ago

chrismdp commented 3 years ago

We are going to have to solve the pathfinding as some point. I'm thinking a navigational mesh which majors on the corners and edges of the tiles. Well trodden paths turn into dirt.

chrismdp commented 3 years ago

https://www.npmjs.com/package/ngraph.path

chrismdp commented 3 years ago

http://totologic.blogspot.com/2014/01/accurate-point-in-triangle-test.html?m=1

chrismdp commented 3 years ago

Need to tackle this before real-time experiment, as I need this in order to do both real-time and turn based gameplay

chrismdp commented 3 years ago

Actually: another much simpler way of doing this would be to reduce the size of the hexagons and make houses and fields take up more than one hexagon. Can then build Astar pathfinding fairly easily.

chrismdp commented 3 years ago

We can do square building by allowing a build across both edges of the hex: https://www.google.co.uk/search?q=hex%20grid.buildings&tbm=isch&hl=en-gb&hl=en-GB&tbs=rimg:CUjaAwVEccLAYU6kqadzVVW0&client=safari&prmd=isnv&sa=X&ved=0CBIQuIIBahcKEwiAisD_hPvrAhUAAAAAHQAAAAAQBw&biw=441&bih=650#imgrc=UOR84CLcjdqCAM

chrismdp commented 3 years ago

Scrap wall tile buildings - it doesn’t really work and is confusing to work with. Instead I could increase the hex size again, and have buildings take a whole hex with one of six rotations so there’s an entrance side. The rest of the hex is blocked off.

Then when pathfinding across hexes, the person always aims for the exit side which means a) people might walk side by side and b) they’ll always walk in straight lines even when pathfinding doesn't work.

chrismdp commented 3 years ago

Next I need to path using the sides of the hex so I'm not going over all the centers each time (which is a waste). I have this information in the navigation map, so I need to return it from the pathfinding algorithm.

After that I should do better weights on the path - trees should be twice as slow (and reduce your speed).