Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / isometric pathfinding

Author
Message
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 20th Mar 2017 12:33
HI

I'm looking for an isometric pathfinding (a pathfinding with waypoint / A*).

I have find that page, but the code doesn't work properly with agk2 :
https://www.thegamecreators.com/codebase/view/6b9a007fa96a4616934dc0fe0063e965

I have found that pathfinding :
https://forum.thegamecreators.com/thread/211568

but it's for 3D.

I have seen the paelax pathfinder, but it's not for isometric .

So if you have another examples/codes, I'm very interested
AGK2 tier1 - http://www.dracaena-studio.com
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th Mar 2017 15:25
Can't you use 2D path finding, and adapt your isometric map to that?

How are you storing your map if not in a 2D array?
The code is dark and full of errors
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 20th Mar 2017 16:49
Hi

In isometric, as you can see, i can have a grid with 64*46 (or 64*32) like that :


But As you can see on this image, the coordinates can be :
x = 32 + i*64
y = 23 + j*46
or
x = i*64
y = j*46

So I don't know how to use a "normal" 2D array with that.
For example, how to use the example from phaelax :
https://forum.thegamecreators.com/thread/206280










AGK2 tier1 - http://www.dracaena-studio.com
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Mar 2017 18:32 Edited at: 20th Mar 2017 18:43
The concept is the same with isometric as it is with an orthogonal map. Think of your square map rotated 45 degrees and you basically have an isometric layout. As long as your map can be laid out in a 2D manner, using A* pathfinding will work. The only difference being how you move from tile to tile. I'll try to write a demo for you tonight after I get home.

I pulled this from one of my code snippets. It should help you draw/layout your iso tiles but also show you how similar the code would be to a standard 2D (orthogonal) map.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Mar 2017 15:26 Edited at: 21st Mar 2017 18:04
I didn't get time last night to make a demo, but I found a page I think will give you a better idea and what I was trying to say.




https://gamedevelopment.tutsplus.com/tutorials/creating-isometric-worlds-a-primer-for-game-developers--gamedev-6511


If your isometric map is a diamond shape like above, then the same pathfinding library will work just fine. What starts to get tricky is when it's not a diamond shape but instead has a staggered layout.


Off the top of my head, I wouldn't have a simple solution for that. I'd have to play around with it, and I'm far from an expert on pathfinding. (I'm just good at porting code to other languages)


Actually, this gives a better visual idea. (click the top-down and isometric buttons)
http://simblob.blogspot.com/2014/07/pathfinding-on-isometric-grids.html


Just randomly came across this, how convenient!
https://forum.thegamecreators.com/thread/190320

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Mar 2017 21:47
I think that the best option is to go full isometric, using the traditional methods as Phaelax details. It'll mean you can easily apply 2D methods to it, and save a lot of work. If that's completely out of the question, then I'd suggest you halve your grid again, so that each tile is a diagonal, as at least with that, there's a chance that A* would work... but I think that compared to an exact 2D grid the results might be a bit clunky.
The code is dark and full of errors
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 22nd Mar 2017 09:13 Edited at: 22nd Mar 2017 09:14
I made a pathfinder for an isometric game. My map editor also stores a regular 2D map when saving my isometric map. The 2D map contains info on each tile on which tile it is linked to on the isometric map, and vice versa. Then I do all pathfinding on the 2D map.
13/0
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 22nd Mar 2017 10:40
Hi

Thanks a lot for your answers !

@Phaelax : For some of my games (clash of bots), I use an isometric diamond grid and for the other (RPG (arkeos)) I use a staggered map.
How Can I use your code with a diamond grid (the code you have posted in another thread) ?
it's for this game :




Quote: "Just randomly came across this, how convenient !
https://forum.thegamecreators.com/thread/190320"

I have found that code, but it didn't work properly with AGK2 and I didn't know how to correct it when I have tried it last year.
This morning, I have found that if we change all the lines (crazy1 =...) :

By

It works fine ^^.

I have made several tests, add some assets (player, background, plants..) hide the tiles, made some changes (moveplayer...) and it's really good even with a 60*90 map ^^ (4000*3000px).


AGK2 tier1 - http://www.dracaena-studio.com
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Mar 2017 13:36
Glad you got the snippet to work, cause I never would've figured out that ((PathY and)) means mod 2. I don't know why they changed mod in AGK2 from %% to an actual command. So it's all good now?

Btw, whoever did your artwork, it looks awesome.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 22nd Mar 2017 16:40
@Blendman

Your graphics are awesome

Nice work, man
PSY LABS Games
Coders don't die, they just gosub without return
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 24th Mar 2017 07:06
@ psy : thanks

@Phaelax :
Quote: "So it's all good now ?"
For the staggered iso, there are some bugs in some case, I have to found and fixe them. I think it's because I use a big map (60*90) = 60*64 / 90*32 (approx 4000*3000pixels)

For the diamond grid, how Can I use your code with a diamond grid (the code you have posted in another thread) ?
AGK2 tier1 - http://www.dracaena-studio.com
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 24th Mar 2017 07:16 Edited at: 24th Mar 2017 07:27
-- double post -- (a moderator can delete this post)
AGK2 tier1 - http://www.dracaena-studio.com
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Mar 2017 17:34 Edited at: 24th Mar 2017 17:44
My code is merely a port of IanM's DBP code. I know a little about how the algorithm works but not enough to write it myself. (though it's something I'm working on).

What I can tell you is a concept for fixing the issue with staggered maps. A* works greats with tile maps, but it's not limited to tiles. It will actually work for any shape or size tiles, or in the case of the algorithm, nodes. You just have to tell the algorithm how your nodes are laid out on the map. When the search progresses to the next possible node, you tell it where it can travel from there. So it's important to understand how your map is drawn and how tiles are ordered.

A typical orthogonal map, using a 4-way search path (does not check diagonals).
It's pretty simple to see what tiles get checked. If the current tile is [X,Y] then the 3 tiles you check would be:

[X-1, Y]
[X, Y+1]
[X+1, Y]




With a pyramid isometric map, it's the same concept and the tiles are just as easy as they technically fall into the same grid pattern like above. But you said staggered, so the standard library won't handle them without modification. Staggered maps can be drawn 4 different ways. Rows or columns can be staggered on the X or Y axis. And then you have the option to stagger either the odd or even rows.



We're still checking only 3 extra tiles from the current tile, it's just their relative coordinates are different than the other two map types. This is where you'd need to modify the algorithm, how it calculates the next tile positions to check.

[X, Y-1]
[X+1, Y-1]
[X+1, Y+1]

Obviously, this depends on how you numbered your tiles (how you've drawn them in order)


The same concept applies for a hexagonal map, which is essentially just a staggered isometric map really.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 25th Mar 2017 12:11
Hi Phaelax

I have tried to adapt your code for a diamond grid and it works fine. It's great ! .
As you can see here, it's excellent :




I Think, I have only to draw the isometric tile, all the rest is made by your 2D pathfinding.
To draw the tile, I use your previous code snippet :


AGK2 tier1 - http://www.dracaena-studio.com

Login to post a reply

Server time is: 2024-04-19 16:14:46
Your offset time is: 2024-04-19 16:14:46