Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
Pathfinder example

sven
Registered User
Quote
2022-05-05 18:45:58

I dont remember if i did post version 1 in this forum or not but this version has now also diagonal movements and handy functions to use it.

Inside scriptfile lines 510 to 541 is all you need to understand.
(there is commentlines with info you need)
Download:
https://drive.google.com/file/d/...

This code is 100% written by me so it uses my logic -and may not be understandable other people--but with handy functions i created its simple to use for all.

Functions usage:



Map=NewPathfinderMap(20,20,30);
[creates a map 20x20 with scale 30 as a Map]
(scale 30 represent scale 3 in coppercube editor-so if you have tile with scale 3 in coppercube editor then use 3*10 here)
createmap(Map);
[This is only needed if you want to draw it-so it creates clones of scenenode (tile) that represents each tile on map]

SetPathfinderStart(Map,1);
SetPathfinderEnd(Map,400);
[add Start and End position to the map,depends on your mapsize 400 may not fit there so try another number]

SetPathfinderSolid(Map,254);
[sets tile with id 254 to be block]
(you can get ID if you click on map then it will print it..so no need to figure them out)

GenerateRandomMap(Map,50,1);//if 1 then it adds also start and end.-so make sure you manually didnt add them first.
[generates a world to a Map MAP with 50 blocks and with start and end position]

display_map(Map);
[displays a Map MAP -sets textures for a walkable ,block,start and end]
[not needed if dont need to see MAP]

var P=PathFinder(Map,1);
[scan Map MAP for a path with (1) that means with diagonal movement]
[path will be saved as P array]

draw_path(P);
[draws path P]

clear_map(Map);
[sets all walkable and removes start and end pos and other info]

reset_map(Map);
[resets info but keeps blocks as they are]
(probably will change it--but right now you need to reset map if you have scanned it)




This project is just made for learning purpose so dont expect anything too special here.
(sooner or later i make a clean version out of it so its alil better then)


count2rfeit
Registered User
Quote
2022-05-05 21:56:31

@sven,

It looks good!

I am surprised at how small your script is considering what it can do.

thanks for sharing it...


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact