• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Path finding class

I download and test it. Thanks a lot for another module.

The module and sample look good but I don't really understand how to implement in my game.
 
Adding this to any game, may be a bit of an exageration. Obv it requires a maze like game.
Platformers or open worlds might be a bit difficult.

Im assuming you would have you maze data in a 1D array with a width and height.
All walls would have a value of 1 and path would be 0

your enemy would be at x,y in that map (its posiiton in the array would be enemy_position = enemy_x+enemy_y*width)
your posiiton would also have an x,y (so your psoition in the array would be player_position = you_x + you_y*width)

If you call p.GetRoute( enemy_position, player_position, map, width, height, 0), this would find a path from the enemy to the player.
p.Route might look lie [0,1,2,8,9,15,16] if theres a path or [] if there isnt

How you traverse that array and move your characters really depends on your game.

if i was to create inteligent enemys, i would call p.GetRoute more than less inteligent ones (say once every second rather than every 3 seconds)

I may add another example showing a simple enemy v player later
 
That's more impressive than my example ;-)
Thanks for the offer, I'll pop a header in the code with your username and link to this thread and add it to the module examples.
Thank you
 
  • Like
Reactions: mag
Back
Top Bottom