Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Alistair

Hey everyone,

I am recreating pacman for a university project, i am using Hurik's A* pathfinding plugin and i am having trouble implementing a few things. Any help you can give me to get me along the right lines would be great. The plugin is working fantastic, however I want to implement the following features...

1. How could I edit the script so it only looks for paths in the direction that pacman is moving ( no backwards movement)

2. If I wanted to set the target position to be 4 tiles in front of pacman, so if pacman is moving right then the target tile will be 4 tiles to the right of him. The problem here is of course if i set the target position 4 tiles to the right and the 2nd tile is a collision layer then the target position will be out of bounds.

if(this.path == null){
	    var pacman = ig.game.getEntitiesByType( EntityPacman )[0];
            this.getPath(pacman.pos.x, pacman.pos.y, false);
            this.followPath(this.speed);
}

1 decade ago by SlotGamer

Without knowing the code, I can answer quickly in general

1. Maybe you could create a temporary map grid filling in the areas behind and to the sides of pacman with non-moveable spaces and then do your A* search

2. I think you will need to do some of your own calculations to find if the tile 4 in front of pacman is "pathable" with a straight line first.

1 decade ago by Alistair

I like the idea of the map grid filling! many thanks. This is the link to forum page where i found the pathfinder plugin i'm using if you have not used it before that is.

http://impactjs.com/forums/code/a-path-finder
Page 1 of 1
« first « previous next › last »