New PathFinding

  ... information about changes and new features of AndEngine,

Re: New PathFinding

Postby cloudface » Mon Dec 27, 2010 7:37 pm

Is the andengine.jar with the new pathfinding utils available in any of the sample projects yet? I downloaded the newest example projects but the referenced andengine.jar still doesn't contain the util.path package. Can someone tell me where to get the new andengine.jar with the new path finding classes? A code sample on how to use the pathfinder would be also be pretty cool :)
cloudface
 
Posts: 6
Joined: Sun Oct 31, 2010 4:01 pm

Re: New PathFinding

Postby MTGap » Mon Dec 27, 2010 9:19 pm

I don't believe there is a jar file with pathfinding yet. To get the code you'll have to download the source from the RenderHandlerBranch.
MTGap
 
Posts: 61
Joined: Sun Nov 28, 2010 12:35 am

Re: New PathFinding

Postby Nicolas Gramlich » Mon Dec 27, 2010 10:20 pm

Hi,

it should be in the Default-Branch, see: http://code.google.com/p/andengine/sour ... til%2Fpath

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: New PathFinding

Postby kleach » Wed Dec 29, 2010 11:36 pm

II have been following this thread... Very excited about A* pathfinding.. a great addition!!

I was wondering if you have any examples that may even use hexagon shaped for the tiles and A* pathfinding?
II will check out the latest to see if I can find a way.. I think many here are looking at doing board style games and many are looking at hex and not rect tiles. The A* system will work either way..

Let me know if I can help in any way.. Examples seem, to be the best way to spread the knowledge..

Great engine.. !!!
kleach
 
Posts: 2
Joined: Wed Dec 29, 2010 11:05 pm

Re: New PathFinding

Postby cesarramirez » Mon Jan 03, 2011 8:51 am

it would be great to see an example of the pathfinding in action.
cesarramirez
 
Posts: 21
Joined: Sun Aug 01, 2010 9:04 am

Re: New PathFinding

Postby wrothgar » Mon Jan 10, 2011 3:31 am

cesarramirez wrote:it would be great to see an example of the pathfinding in action.

Agreed. Any idea when the example in the first post will become a part of the AndEngineExamples? I cannot wait to look at your implementation. Great work by the way, it is very exciting!
wrothgar
 
Posts: 19
Joined: Thu Sep 16, 2010 5:45 pm

Re: New PathFinding

Postby CaptnIgnit » Sun Feb 06, 2011 3:44 am

Was curious if any examples have shown up in the last month?
CaptnIgnit
 
Posts: 87
Joined: Tue Feb 01, 2011 5:10 am

Re: New PathFinding

Postby wrothgar » Sun Apr 10, 2011 1:24 am

Wanted to follow up on this topic, has a sample tutorial been released for Pathfinding? Or does someone have an example implementation to share?

Thanks guys!
wrothgar
 
Posts: 19
Joined: Thu Sep 16, 2010 5:45 pm

Re: New PathFinding

Postby Robin » Tue Apr 19, 2011 12:20 am

It's really straight forward. Just implement that Interface ;). Nevertheless, i'll post an example:

My implementation of the interface. I dont work with TMX map, but rather used my own map system
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class PathfinableMapProxy implements ITiledMap<Map>
  2. {
  3.         public static final int PASSABLE_PATHONLY = 1;
  4.         public static final int PASSABLE_WATERONLY = 2;
  5.         public static final int PASSABLE_PATHANDFIELD = 3;
  6.        
  7.         protected Map map;
  8.         protected int passableMode;
  9.        
  10.         public PathfinableMapProxy(Map map, int passableMode)
  11.         {
  12.                 this.map = map;
  13.                 this.passableMode = passableMode;
  14.         }
  15.        
  16.         @Override
  17.         public int getTileColumns()
  18.         {
  19.                 return map.getMapSizeX();
  20.         }
  21.  
  22.         @Override
  23.         public int getTileRows()
  24.         {
  25.                 return map.getMapSizeY();
  26.         }
  27.  
  28.         @Override
  29.         public void onTileVisitedByPathFinder(int pTileColumn, int pTileRow)
  30.         {
  31.                 //nothing here
  32.         }
  33.  
  34.         @Override
  35.         public boolean isTileBlocked(Map pEntity, int pTileColumn, int pTileRow)
  36.         {
  37.                 if(map.isTileWithinbounds(pTileColumn, pTileRow))
  38.                 {
  39.                         switch(this.passableMode)
  40.                         {
  41.                                 case PASSABLE_PATHONLY:        
  42.                                         //TODO: implement this
  43.                                         return false;
  44.                                
  45.                                 case PASSABLE_PATHANDFIELD:
  46.                                         return (map.getField(pTileColumn, pTileRow).hostsEntity() && !map.getField(pTileColumn, pTileRow).getHostedEntity().getGraphic().startsWith("path"))
  47.                                                 || map.getField(pTileColumn, pTileRow).getFloorEntity().getGraphic().startsWith("water");
  48.                                        
  49.                                 case PASSABLE_WATERONLY:
  50.                                         return !map.getField(pTileColumn, pTileRow).getFloorEntity().getGraphic().equalsIgnoreCase("water");
  51.                         }      
  52.                 }
  53.                 return false;
  54.         }
  55.  
  56.         @Override
  57.         public float getStepCost(Map pEntity, int pFromTileColumn, int pFromTileRow, int pToTileColumn, int pToTileRow)
  58.         {
  59.                 return 1; //everything costs the same
  60.         }
  61.  
  62. }
  63.  
  64.  
  65.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4



how to find a path:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. this.proxy = new PathfinableMapProxy(map, PathfinableMapProxy.PASSABLE_PATHANDFIELD);
  2. path_pathfinder = new AStarPathFinder<Map>(this.proxy, 100, false);
  3. path_pathfinder.findPath(map, 10000, path_startTileX, path_startTileY, path_curTileX, path_curTileY);
  4.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I hope this was helpful ;)
Robin
 
Posts: 29
Joined: Wed Jul 21, 2010 11:02 pm
Location: Switzerland

Re: New PathFinding

Postby ruddy_robot » Fri May 20, 2011 9:11 am

Hi,

I'm new to Andengine and im trying to use this Pathfinder thing because i need it for my game. I got Pathfinding work realy quickly but my problem is:

How do i get my AnimatedSprite moving along this path?

I have tried this but i cant imagine this is the right way :lol:
So a little hint would be reaaaly nice

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private Path path;
  2.         private int pathCount = 0;
  3.  
  4.         final IEntityModifierListener listener = new IEntityModifierListener() {
  5.                 @Override
  6.                 public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
  7.                         if (pathCount != path.getLength()) {
  8.                                 int toX = path.getStep(pathCount).getTileColumn() * 42;
  9.                                 int toY = path.getStep(pathCount).getTileRow() * 42;
  10.                                 if (pathCount == path.getLength()) {
  11.                                         registerEntityModifier(new MoveModifier(3, mX, toX, mY, toY));
  12.                                 } else {
  13.                                         registerEntityModifier(new MoveModifier(3, mX, toX, mY, toY, listener));
  14.                                         pathCount++;
  15.                                 }
  16.                         }
  17.                 }
  18.         };
  19.  
  20.         public void moveUnit(final Path path) {
  21.                 this.path = path;
  22.                 main.runOnUpdateThread(new Runnable() {
  23.                         public void run() {
  24.                                 int toX = path.getStep(0).getTileColumn() * 42;
  25.                                 int toY = path.getStep(0).getTileRow() * 42;
  26.                                 registerEntityModifier(new MoveModifier(3, mX, toX, mY, toY, listener));
  27.                         }
  28.                 });
  29.                 pathCount++;
  30.         }
  31.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
ruddy_robot
 
Posts: 3
Joined: Fri May 20, 2011 9:04 am

PreviousNext

Return to Updates

Who is online

Users browsing this forum: No registered users and 4 guests