Hi there, I am writing some code right now and I am testing it on both linux 32 bits and windows 64 bits. To avoid portability problems I am using types declared at orx (such as orxU32), but I am using some C functions too (mostly malloc and free).
Can anyone tell if this can create problems in the future, considering I want to compile it for IOS and android later?
Comments
Out of curiosity, for which kind of use do you use dynamic allocation in your game? Just asking as there might be some obscure orx features that could help depending on the case.
So I create monsters and the grid as pointers.
Second I need I need a two copies of the scenario walkable areas to run the pathfinding for the monsters.
Also, do you really need a copy for pathfinding? Isn't there any way to use the original one? Again, I'm just curious.
I may chage the algorithm to djikstra or A* in the future, but the grids are so small and simple that I don't really think it will be a problem.
Actually the orxAnimSet module computes a shortest path matrix (+handling of priorities) in a very similar manner for the animation graph but with a more compact memory representation (cf orxAnimSet_ComputeLinkTable). This code is over 8 years old so I'd probably write things a bit differently now.
I really don't believe the higher cost (O(x³)) will be a problem, since the movement rules make the problem simplified:
- Monsters can overlap, so I don't need to recalculate the path every frame.
- I only recalculate the path if the player moves out of a cell (which takes more than a second at normal movespeed).
- Monsters will only try to attack the player if it is within a certain range and the monster can see the player (aka there is no wall in the line between the monster and the player). This restriction allows me to search a smaller area.