New answers tagged

1

You could let a point travel on a circle in discreet steps and adjust the radius for each step, that would make it look jagged and irregular. Something like this might work for you: /** * * @param px The center X of the shape * @param py The center Y of the shape * @param numberOfNodes How many dents the shape can have. * @param minRadius Radius of ...


1

libGDX Json converts Enums to strings and therefore cannot serialize / de-serialize Map keys to anything but strings. To fix this, either... Use strings for keys in Maps (ObjectMap, HashMap ect.). Use GSON, which can serialize Enum Map Keys just fine. Write lots of special serialization / de-serialization code using a class that implements Json....


0

It looks like you never assign the game member-variable in your TitleScreen class, so it is null when the click handler is invoked. Try setting the game variable in the constructor of TitleScreen, you are already passing in a Game instance called aGame, you problably want to assign that to game: public GameScreen(Game aGame){ batch = new SpriteBatch(); ...


0

It's hard to tell, but it looks like you are only ever testing for one collision. You need to maintain a list or collection of walls in order to test each one for the collision. That may be why it fails upon adding more walls. Once you have a collection of the walls you would test the player against each one before moving. One way to solve the ...


0

If you have a grid that is xSize x ySize in size and it is stored in a one-dimensional array, then a way of finding the index in that array for a given (x, y) coordinate is: int index = x + y * xSize; Each increment to the y-axis advances the index by the entire width of the grid, and each increment to the x-axis increments along that row. In your example ...


1

I think there is a minor typo in your code, see SpriteSheet class public BufferedImage grabImage(int col, int row, int width, int height) { BufferedImage img = image.getSubimage((col * 32) - 32, (row * 32) -32, width, height); //return image; typo here! return img; } what actually happens: you crop a sub image (named img) from your ...


1

for(int i=0; i< (tiles.length); i++) { colours[i*4+ 0] = 0xff00ff; colours[i*4+ 1] = 0x0000ff; colours[i*4+ 2] = 0xffff00; colours[i*4+ 3] = 0xffffff; } The For-Loop at the start is generating groups of four colour entries based on how many tiles you have. It's a little convoluted to read at a glance and given choice I'...


0

Usually 3D Perlin noise would look a bit like this: float PerlinNoise(Vector3 point) { Vector3Int root = new Vector3Int( FloorToInt(point.x), FloorToInt(point.y), FloorToInt(point.z)); for(int i = 0; i < 8; i++) { Vector3Int corner = root + cornerOffset[i]; Vector3 gradient = GetPerlinGradient(corner); ...


1

First, we divide the x, y, and z coordinates into unit cubes. In other words, find [x,y,z] % 1.0 to find the coordinate's location within the cube. What that means is you perform the value % 1.0 operation for each member of the [x,y,z] vector (the position): [x', y', z'] = [x % 1.0, y % 1.0, z % 1.0] x', y', and z' are the remainders of dividing each ...


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

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


Top 50 recent answers are included