New answers tagged

1

Alternatively, you could decouple the button push and the delta move. In the key events, you can always set the button state if (key == KeyEvent.VK_LEFT) { leftPressed = true/false; // depending on press/release } ... Then later set deltas in the move method or a controls handler method (this will stop x movement if both left and right are pressed -1 ...


0

Welp, seems a bunch of RegEx works... if (Pattern.matches("[A-Za-z0-9\\s_\\+\\-\\.,!@#\\$%\\^&\\*\\(\\);\\\\/\\|<>\"'\\[\\]\\?=]", String.valueOf(Keyboard.getEventCharacter()))) { value += Keyboard.getEventCharacter(); }


0

Add this where you add the code to the string: value += String.valueOf(Keyboard.getEventCharacter()); value = value .replaceAll("[^\\w\\s\\]","");


0

You need to check for Character.isLetterOrDigit(char), and if it returns false, skip it.


0

the steps to do this are: generate a list of N random heights int h[]; generate a list of N-1 distances where distance is the difference between the 2 heights dist=abs(h[i] - h[1]) use this information do draw your line segments with the desired amount of noise where the number of segments between points is <= distance. this will ensure that the ...


0

If you know the boundingbox size (you should), the character position would be: character.y=floorBoundingBox.y - characterBoundingBox.height You don't actually directly calculate the difference between the floor and the character, you calculate the position of colliding objects by pushing them their height or width outside the floor.


1

Yes. You were able to see the sprites when Angry Birds Chrome was available to play and they looked like this:


0

Judging from the documentation on the Animation class in slick, it looks like some of your parameters are incorrect. frames - The sprite sheet containing the frames x1 - The x coordinate of the first sprite from the sheet to appear in the animation y1 - The y coordinate of the first sprite from the sheet to appear in the animation x2 - The x ...


0

If it's the allocation of the Vector3 you're worried about you might consider keeping an instance as a private member of the class and re-use that; private final Vector3 v3 = new Vector3(); public void yourMethod() { if(cam.frustum.pointInFrustum(v3.set((float)posX, (float)posY, 0))) { } } Another way, if you have many of these instances you could ...


0

Take a look as using a different type of ViewPort (this page shows the different types). Based on what you have described I would recommend using a StretchViewport, which would upscale (or downscale) your 480x320 camera to whatever resolution you needed it to be. Note that if you changed the aspect ratio you might get some ugly stretching artefacts.


1

I've thought about this, that is, creating matching heightmaps using diamond-square. I don't know how well this will work, as I've never tried implementing it, but here's my theoretical postulation: For every point along an edge, if the adjacent map portion exists, make the point equal to the adjacent edge point. What it looks like right now is that ...


0

In my own bit of code (just to learn procedural terrain generation), instead of trying to stitch together two maps (eg. two 64x64 maps), I create one larger map (eg. 128x128, which wraps), and then throw away the bottom portion. This leaves me with a 64x128 map that wraps horizontally but not vertically (which is what I want).


1

Create the menu in one Activity, and let that Activity be a "normal" Android activity, then have that Activity launch the libGDX game Activity. That sort of approach would allow you to use Android layouts for the menu but libGDX for the actual game.


0

You can use the filter on the FixtureDefinitions to define what type of objects can collide with what. You define a category bit-pattern, this describes what the fixture is. Then you define a set of categories that the fixture collides with. For example; class PhysicsConstants { // Categories public static final int CAT_SHIP = 1; public static ...


1

Have a currentRotation and a desiredRotation you will also want some helper function to give you the shortest angle distance, so let's just call that angleDist or whatever. (You want that because sometimes going clockwise is shorter or vice versa). Then all you need is to interpolate between them somehow. currentRotation += expFactor * ...


1

First of all if you don't already know the basics of Java, you should learn them first. :) When you have, you will need some kind of graphics library. I know that LWJGL is a good graphics library. LWJGL Link :) According to some people over at stack overflow, Minecraft was made with this. But, as I said it's probably best (if you don't already know ...


17

To answer your question directly, no Steam doesn't notify the purchaser that the game needs Oracle's Java Runtime Environment installed to play the game. That's because there shouldn't be any need to, any game that has a dependency on the JRE will download and install it as part of the normal Steam installation procedure. This is no different than games that ...


0

forge_1710_src/src/java <--this is where your code lives, possibly inside more directories forge_1710_src/src/resources/assets/[MODID]/textures/blocks <--where block textures go http://www.minecraftforge.net/wiki/Icons_and_Textures


0

Why not store fhem inside the jar file? Then you could reference them as YourMainClass.class.getResourcesAsStream(new File(path fo your file))


6

This related question recommends using launch4j. Based on 3 Ring's code page, it looks like they use getdown for Spiral Knights. You might consider reaching out to Puppy Games to see if they're willing to share any insights. Similarly, there are some devs on java-gaming.org that have some experience with this.


13

This is by no means an answer, but some points to consider. It did not fit in the comments box. I would think that even if you were to use c++, you would need to ship your game with a bunch of Redistributable, at least on Windows. Unless you can manage to not use Visual Studio tools and such. I don't know what happens for Mac users. And if you go with ...


0

The solution is simple as that: P = Circle center r = radius or the circle You get the closest point from the circle center to the polygon (C) (I assume you got that already) Get the distance from the closest point to the circle center (D) = C-P Normalize that distance to get the unit vector (N) Get the signed distance to the edge/vertex and take the ...


0

So if I understood, you want to get the cell that is clicked so you can color it. private void fillTouchedCell() { if (Gdx.input.isTouched()) { Cell c = getCellAtTouch(); if (c != null) { //cell clicked, we cant fill it with color c.fill(Color.RED); } } } private Cell getCellAtTouch() { unpojectedTouch.set(Gdx.input.getX(), ...


1

If you're not in need of a very fancy way to deal with this problem you could just brute-force it by doing these steps: Randomize the circle coordinates. Check if the distance vs all other circles that you have drawn. If it is greater than the sum of the radius of the two circles (40, in your case) you can go ahead and draw the circle. If it is equal to or ...


3

You seem to lack some insight on your issue. A couple of things to consider: Is your true maximum frame rate on your PC really 60 or is it more? NVida drivers limit the frame rate to the maximum draw rate of the monitor, typically 60 Hz; this is due to the fact that there is no need to ask to draw faster than what the monitor is able to process. By ...


0

Try setting the position on the FixtureDef. I'll assume that you already converted the units to Box2d: public static Body createCarBody(Vector2 position, float sizeX, float sizeY, float density, float friction, float restitution, float linearDamping, float angularDamping){ System.out.println("position createCarBody " + position); Body body = ...


0

Instead of applying the position to the Shape if the FixtureDef, apply the position to the Body. Something like this might work for you; public static Body createCarBody(Vector2 position, float sizeX, float sizeY, float density, float friction, float restitution, float linearDamping, float angularDamping) { System.out.println("position createCarBody " ...


0

Ok this is how i would do it. public void handleInput () { mouse_x = Gdx.input.getX(); mouse_y = Gdx.input.getY(); rou_mouse = new Vector2(mouse_x/cellWidth, mouse_y/cellHeight); set_px (rou_mouse, new Element_stone()); } The new vector2 arguments should give what cell number ...


0

You can use also container reference, getInput and check if a key is pressed, down, etc.. For example: container.getInput().isKeyPressed(Input.KEY_SPACE) see more details on javadoc


0

I assume your are using 'java.awt.*' to do this and you wanted this solution to be similar in nature. In that case I think the easiest solution would be to simply be extending the Rectangle class with a field for your BufferedImage and draw using that. RectangleImage.java: import java.awt.Rectangle; import java.awt.image.BufferedImage; public class ...


3

You did not specify whether you will have many circles or just a few. However, by the measures you mentioned I assumed it's just a few (by the way, if the measures you are thinking of are correct, only 4 circles will fit perfectly into the rectangle...). So, if you have just a few circles, you can opt for a very naive solution: save each new valid circle in ...


0

You can use setAngularVelocity(float omega) LIBGDX API for angularVelocity


0

I suggest to check this project, Shade. There is real-time lighting and moving shadows, I think could be useful for you


1

I don't know if this could help you, but this is everything I do for good MipMapping: public int loadTexture(String fileName){ Texture texture = null; try { texture = TextureLoader.getTexture("PNG", new FileInputStream("res/textures/"+fileName+".png")); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); //I preffer LINEAR_MIPMAP because ...


0

Solved. You need to download "Google Repository" from Android SDK.


0

Your code is a little bit confuse. Also, I tried cloning it and the project is incomplete, so I can't import it. If I understood your code, you're using box2d bodies but you're not setting the sprite position taking in consideration the Box2d units. Box2d works with meters, so you have to convert pixels to meters and take in consideration the fact that box2d ...


0

The issue is due to memory usage, wasted memory bandwidth and/or the time it takes to rescale it to the proper size at load time. In the case of Android using the 2D UI the image will be scaled once to the proper size at load time but this takes a bit of time and the larger original will be kept in memory if a reference to it is kept. In the case of direct ...


0

You can set vertical moving cost to X and horizontal moving cost to X+1.


1

If I understand you correctly you are having problems going left and right. First off currentFrontSpeed should never be negative since it's speed not velocity. Speed is a scalar and as such should not capture any direction and will always be positive. To move in different directions you should modify the angle instead where for example right is -90 from ...


1

Don't get caught up in the exact numbers used in the example. Those are not the main point. It's how they are relative to each other. You see that xhdpi 200x200 is twice as big as mdpi 100x100. Notice the if in the example. List of densities: xxhdpi: 3.0 xhdpi: 2.0 hdpi: 1.5 mdpi: 1.0 (baseline) ldpi: 0.75 Sample example but with different numbers: ...


1

One way to do this would be to clamp (limit) the x and y values of the camera to your width and height of the game. It may look something like this: Clamp method: public int clamp(int var, int max, int min) { if(var > min) { if(var < max) { return var; } else return max; } else return min; /* * var = your variable ...


0

Incidentally, I have done exactly what you are trying to do. The only catch is I was using Jbox2d so the code is in Java, but you should still be able to figure it out if you are using C++ You basically need to use joints/motors and all that fun stuff if you want to do swinging action. Here's a snippet of what my code looks like based on the key input: ...


0

I had made a game similar to yours with almost similar logic ,I had moved camera,instead of moving each element individually as moving camera is easier and saves lot of logic's. I had a class cameraHelper that gets and sets all necessary details about camera import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.math.Vector3; public ...


3

You load your images like this: texture = TextureLoader.getTexture("PNG", new FileInputStream("res/" + fileName + ".png")); However if you read through the source code of slick you'll see that internally it is represented as TextureImpl which was the following documentation. A texture to be bound within JOGL. This object is responsible for keeping ...


0

Try this instead: Matrix4f modelMatrix = new Matrix4f(); modelMatrix.m00 = 2.0f / (float) Display.getWidth(); modelMatrix.m11 = -2.0f / (float) Display.getHeight(); modelMatrix.m30 = -1; modelMatrix.m31 = 1; I have no idea what gui.getSize().getX() / Display.getWidth() was suppose to do, so I left it out from above. But ...


0

The is no problem with your repaint() method. The problem here is that the Sparx you update and move is a different Sparx then the one you render/paint. In your Board class you create a new Sparx instance and this is the one you render out. This is a different instance from the one you create in your StartingClass and update the position of. Simply ...


2

You shouldn't call dispose directly on a Texture loaded by an AssetManager, they are disposed the the AssetManager is cleared or disposed or if you call unload on the AssetManager and pass the Texture. The reason you shouldn't dispose assets from an AssetManager is that they can be shared between many other assets (two fonts may use the same texture for ...


2

It depends on what you need to store. If you just want the positions of the tiles, a 2D array is probably the easiest way to store it (unless you have a dynamic world size). If you want the connections (for movement costs, etc.) then a Graph is probably what you want to use.


1

Usually a single one dimensional array would work fine, just remember that, to get the tile you want you have to use the formula tile[x +(y*tiles_in_row)]


1

I reccomend you delete and load smaller pieces (~50m) at a time to keep a more stable (if not lower) fps.



Top 50 recent answers are included