Tag Info

New answers tagged

0

Note: I know nothing of C++, only Java, but you should be able to figure out the code. Physics is universal language right? I also realize this is a year old post, yet I just wanted to share this with everyone. I have an observer pattern that basically, after the entity moves, it returns the object it has collided with, including a NULL object. Simply put: ...


-1

1) Use Breadth First Search (BFS) to calculate the path http://en.m.wikipedia.org/wiki/Breadth-first_search 2) Highlight path 3) Move the object Pathfinding: http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html


0

Actually this is like any tile based movement from a turn based strategy game. You can simply flood fill the tiles from the selected character to find which should be highlighted. Psuedo code: Set<Tile> getTilesInRange(Character character, int range){ Set<Tile> highlighted; highlighted.add (character.tile); Set<Tile> ...


0

The A* Algorithm works with paths on a graph. The graph does not have to be a grid. If you look at the paths you want, they go through the corners of the square tiles. Specifically, they go through the corners where three tiles are walkable and one tile is a wall. Instead of giving A* a graph with the tile centers, you can build a graph with only these ...


3

As other option, you could split the path into straight parts. Then you only need to find the points where your original path leave a path part (no need to compute, just switch by direction of the next part). Only what remains it is connect points of your new smooth path! EDIT: if you insist on the path you drawn, just compare the two extreme ...


2

One option for path-smoothing is casting rays from the current position to the farthest visible node and go there. You could either do it in real time or just build a new path from the one you already have, so the navigation algorithm stays the same. Starting from the current position, cast rays to each node in the path. When there is a node that cannot be ...


2

You are looking for a grid traversal algorithm. This paper gives a good implementation; use the 2D version. There's also a 3D ray-casting version on the paper. In case the link rots, you can find many mirrors with its name: A faster voxel traversal algorithm for raytracing.


3

Blue's idea is good, but the implementation is a bit clumsy. In fact, you can easily do it without sqrt. Let's assume for the moment that you exclude degenerate cases (BeginX==EndX || BeginY==EndY) and focus only on line directions in the first quadrant, so BeginX < EndX && BeginY < EndY. You'll have to implement a version for at least one ...


2

Your assumption isn't necessarily to find the cells but the lines it cross on this grid. For example taking your image we can highlight not the cells, but lines of the grid it crosses: This then shows that if it crosses a grid line that the cells either side of this line are those that are filled. You can use an intersection algorithm to find if your ...



Top 50 recent answers are included