Hot answers tagged

49

This sounds like a use case for Flow Fields. In this technique, you do a single pathfinding query outward from your player object(s), marking each cell you encounter with the cell you reached it from. If all your tiles/edges have equal traversal cost, then you can use a simple breadth-first search for this. Otherwise, Dijkstra's algorithm (like A* with no ...


8

A* is not performance heavy. I would approach this situation by varying the algorithms. Do A* from time to time and in between check whether the next step is free to step onto or you need evasion. For example, track the players distance from the A* target location, if it's above a threshold recalculate a* and then just do update movements. Most games use a ...


4

Not only is it feasible, I believe it was done in a commercial game in the 90s - BattleZone (1998). That game had 3D units with free non-tile-based movement, and tile-based base construction. This is how it seemed to work: First, A* or something similar (likely a variation of A* with strict limits on how long a path it can find, so it never takes too many ...


2

In WorldMap.draw you are reconstructing the map texture every frame by drawing a bunch of 1px by 1px rects. This is a very expensive way of drawing bitmaps, because it not just runs on the CPU instead of the GPU but also uses a very inefficient method (calling a method to fill rectangles instead of changing the color values of a pixel buffer). If possible,...


2

The height of each individual hexagon is 84px including shadow but the shadow only matters for the last row. So we need to know the size without shadows. I believe the height of the hexagon without shadow is 73px. For all rows except the last row, there is overlap in heights by 1/4 of the hexagon height. The second row starts at 3/4 of the hexagon height. (...


1

Try vector projection as illustrated here Vector projection formula: $$ (\vec{a}\cdot\hat{\vec{b}})\times\hat{\vec{b}} $$ where b with a hat means norm of the vector $$ \hat{\vec{b}} = \frac{\vec{b}}{\left\|\vec{b}\right\|} $$ You can represent side of object B and velocity of object A as vectors and use vector projection to remove any velocity directed ...


1

I suggest. Find right text size for your world. For example you can dynamically create font: public static BitmapFont getFontInWorldUnits(float size, float worldHeght) { FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/simpleprintbold.ttf")); FreeTypeFontGenerator.FreeTypeFontParameter parameter = new ...


1

There's nothing inherently slow or fast about OpenGL, or Java for that matter, when it comes to loading models. The following basic rules apply: You're hitting the disk, so fewer large reads are going to be much faster than lots of small reads. Loading binary files is typically going to be faster than parsing plain text. If the model needs conversion from ...


1

Using a simple truncation as suggested by @Pikalek does only work with positive numbers. Truncating positive numbers is equivalent to the floor-operator but with negative numbers it is equivalent to the ceil- operator. To make it properly work in both cases you need to explicitly use the floor operation. leftCameraBorder = centerX - camera.width / 2 ...


Only top voted, non community-wiki answers of a minimum length are eligible