# Tag Info

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 ...

4

Tiled does support drawing lines as collision objects. To do this, you should just not close the polygon (right-click once you're done with the polyline). In the past these have been separate tools, but in Tiled 1.2 they have been unified into a single tool. Probably the UI needs to be more clear that the tool can be used to create both polygons and ...

3

Typically for a pure data change like this, we would not use separate classes. Instead, you could make your class non-abstract (say "BasicMob" to leave room if you need more complex mob classes in future) and give it one or several Factory Methods that populate the data of your mob to make a specific variant. eg.. public static BasicMob CreateFireElemental(...

2

Try creating a 3-4 frame animation of a semi-transparent blue-white dot that moves downward a few pixels before expanding out to a 1-2 pixel radius circle. Then just create random instances of this animation all over the map. Should give the appearance of rain droplets. From there you can adjust it by maybe adding more frames or adjusting the shape when it ...

2

This code is what is responsible for making your soldier blink/teleport: runningTime += Gdx.graphics.getDeltaTime(); positionX = speed * runningTime; Once the soldier hits the barb wire, it will change speed every frame: frame 1 it will go slow because it hits the barb wire, so the positionX = speed * runningTime; will then bring him to an earlier position,...

2

First: you have your arguments to atan2 backwards. If you check the docs, you'll see it takes y first, then x But why go to all the work to take the angle, convert it from radians to degrees, convert it back to degrees, then convert it back to a vector? This is a pile of extra trig you don't need. instead, when you spawn the bullet, calculate its velocity ...

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. (...

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

First of all: M-VC Separate Game from GUI - a suitable approach might be M-VC (Model-View/Controller). If you do it right, there should be NO REFERENCE on the game towards the controller, but the controller knows about the game. Doing it that way you can create controllers for any GUI you want (Android, JavaFX, TCP/IP) without ever changing the game. ...

2

I've done some code reading and now it's obvious... you do the following with your code: create a wander Routine create a repeatInfinite Routine for the wander Routine create a selector Routine for the repeatInfinite Routine so far so good - but if you read the code for the Selector (the selector Routine) you'll notice the following: // We need to ...

2

You are adding the Snake body to your canvas but you never remove it. That's why reset() won't clear your Snake. You're adding the Snake body within your start() method: Snakes = makeSnakeBodies(); canvas.getChildren().addAll(Snakes); //HERE you add the Snakes now the Snakes are added to your Canvas (well: Pane) but they are never removed. Solution: ...

2

I can't think of a pre-made library to do this all directly, and with such a low "resolution", you probably want precise control over how wide each column is etc. You can basically treat your display like a very low resolution image, (e.g. a char screen[80][50]) then write that out each update, or you can just print the chars directly using something like ...

2

There's lots of information in the article about Output libraries on RogueBasin wiki. You're likely looking for curses or one of the derivatives, like ncurses, PDCurses, etc. Such a style of library lets you render UIs in a text-based console, supporting for example sub-windows, changing text at specific coordinates, and depending on the specific library ...

2

Destroying the VAO and VBOs when the chunk is no longer needed. This is the main thing that you're doing wrong, and it implies that you're also creating resources at runtime. Creating and destroying resources at runtime is a slow operation and something you should try to do as little of as possible. Instead you should keep a pool of free VBOs/etc, and ...

2

The Easy Stuff I would suggest that you start by learning 2D collision detection between (non-rotating) circles. Here, rotation can be considered a non-factor - and that greatly reduces the complexity of the problem. In essence, with non-rotating colliding circles, all you need to do is look at the degree to which they would have intersected in a given ...

2

Depends how your engine works. Your player could be responsible for checking for ropes, or your ropes could be responsible for checking for the player. Either way, I think both your player and your rope are going to need to know that they're attached, so whichever way you choose, you're going to need to have an 'attach' function in both classes.

1

I was thinking about putting them into an array list, and ordering them based upon their depth YES. but they are different object types. The guy is an object of class character, and the girl is an object of class NPC. Is there a way to put both of these object types into one array list, or should is their another solution. Define an interface that has ...

1

From my experience in game developing, when making a game for multiple platforms, its easier to organise everything in such a way that works for most of them. In this case, using a SurfaceView is like telling to android "Give me a rectangular area on the screen, where I will draw custom graphics". This is very similar to how game development is being done ...

1

Your main game loop should usually loop through 3 main processes. Each of these processes usually run in context to a specific scene/screen in your game .. menu screen, gameplay screen, exit screen , etc. Process input: this is usually where people use an observer design pattern and create an event dispatcher which dispatches events to game objects who are ...

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 would not do this the way you describe. How many pixels will you test in the event there is no collision (the probable case)? All of them! Instead define a polygonal outline for your tank and whichever objects exist on the map. Then, you can test each point of the tank polygon against each edge of the obstacle polygon and determine if there is a collision. ...

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 ...

1

There are a few misunderstandings of A* here. You add every node to the closed set before you add it to the open set, but that's strictly speaking premature: at this point, we know we've found a route here, but we don't yet know whether it's the shortest route possible. We know we've found the shortest route to current, since it was at the head of the ...

1

I'm not sure about your normals. Taking Calculate Normals from Heightmap as reference, I'd say change it like this: private Vector3f calculateNormal(int x, int z, BufferedImage image) { float heightL = getHeight(x - 1, z, image); float heightR = getHeight(x + 1, z, image); float heightD = getHeight(x, z - 1, image); float heightU = getHeight(...

1

This error is telling you exactly what the problem is... SpriteBatch.end must be called before begin. The render() method code you have shared calls batch.begin() then batch.end(). But at some point before you are calling render(), you are probably calling batch.begin(). So then render is calling batch.begin() a second time and giving you that error. ...

1

The error tells you exactly what's wrong: Caused by: java.lang.NullPointerException This means that something wasn't initialized at com.mygdx.game.world.TileType.<clinit>(TileType.java:50) This means that it happened on line 50 on TileType. You forgot to initialize the tileMap hashmap

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