A star algorithm

Get help using Construct 2

Post » Fri Dec 30, 2011 1:14 pm

Is it possible to "code" A star (A*) algorithm in Construct 2?
I know there is PathFinder behavior, but i'd like to kode it in construct events to show in school that contsruct also can do it (not only programming language).
B
55
S
14
G
10
Posts: 287
Reputation: 7,677

Post » Fri Dec 30, 2011 1:56 pm

Events aren't well suited to highly algorithmic code like the A* algorithm - that's part of what plugins are for, to offload the algorithmic things. So I'd go for the PathFinder behavior.
Scirra Founder
B
395
S
231
G
88
Posts: 24,367
Reputation: 193,694

Post » Fri Dec 30, 2011 3:20 pm

I agree with Ash but if it's just to show off a bit, you can try adaptating r0j0's cap into a capx (you need to download construct classic)
http://69.24.73.172/scirra/forum/viewtopic.php?f=8&t=8368&p=63821&hilit=pathfinding
I think it's pretty doable, all functionalities you need are in c2 already (except for the foreach ordered... But it's just to set random start and goal on start of layout)Yann2011-12-30 15:23:03
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Sat Dec 31, 2011 7:03 pm

Here is an example for grid based astar pathfinding. It's useful for a visualization of the algorithm, but plugins are better suited for something like this. As it is it's a bit laborious to re-implement it for every project.
http://dl.dropbox.com/u/5426011/examples%208/astar.capxR0J0hound2011-12-31 21:21:37
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Mon Jan 02, 2012 11:37 am

Thank you.
B
55
S
14
G
10
Posts: 287
Reputation: 7,677


Return to How do I....?

Who is online

Users browsing this forum: Bootfit, brunopalermo, grigrizljac, korbaach and 16 guests