In this thread, it tells that in 2d platformer games, I should pre-define and connect node to find the correct path.
But I don't understand how to find the node's children. In my program, I define map as following, 0=free space, 1=solid terrain, 2=node
the original map definition is:
numpy.array([ [0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,1],
[1,1,1,1,1,1,1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0],
[1,1,1,1,1,1,1,1,1,1,1], ])
the map after adding nodes
numpy.array([ [0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,2,2],
[2,2,2,2,2,2,2,0,0,1,1],
[1,1,1,1,1,1,1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0],
[2,2,2,2,2,2,2,2,2,2,2],
[1,1,1,1,1,1,1,1,1,1,1], ])
In the original A* (A star) algorithm, it searches 8 directions and every direction checks only one node if available.
But in a platfomer, I don't know how to deal with this, there are too many possibilities. For example, assuming the character's jump value is 3, then we go to left now I can:
- jump to left using 200% power, (keep pressing left while jumping and falling, move 6 steps actually)
- jump to left using 166% power
- jump to left using 133% power
- jump to left using 100% power
- jump to left using 66% power
- jump to left using 33% power
- just walk (the paths 1-7 in the pic)
8 directions and bigger jump value lead to more possibilities. What's more, there are countless possibilities when falling from a high solid terrain.
For every possibility, in order to connect the nodes, I need to check the corresponding coordinate in the map (array) if existing node.
So I am confused. Am I over-complicating / misunderstanding A* or did I miss something because it requires a huge calculation for every node in a big map like 500*500?