Hot answers tagged

18

You're moving the circle by one pixel per frame. It should not come as a big surprise that, if your rendering loop runs at 30 FPS, your circle will move 30 at pixels per second. You basically have three possible ways to deal with this issue: Just pick one frame rate and stick to it. That's what a lot of old-school games did — they'd run at a fixed ...


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


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


10

You do it with math. private static const int maxBarWidth = 128; //... float ratio = (float)curTime / maxTime; float barProgressInPixels = ratio * maxBarWidth; Unless you're looking at figuring out how to render this information to the screen.


9

TextureAtlas#findRegion(String) returns a region with a name that matches the name specified. It does not copy the region, therefore any changes you make to the region will be reflected in the TextureAtlas. To overcome this issue, simply instantiate a new TextureRegion object and pass it the region found inside your TextureAtlas: background1 = new ...


9

Yes, some parts need to be really fast. Now are these part written in Java slow? Did you measure and considered that it would really be an improvement to figure out how to plug everything that needs to go fast in native language? This seems to me like it's premature optimization. Unless you realize that these parts are really a bottleneck and that the only ...


8

Your code is currently running each time a frame renders. If the frame rate is higher or lower than your specified frame rate, your results would change as the updates don't have the same timing. To solve this, you should refer to Delta Timing. The purpose of Delta Timing is to eliminate the effects of lag on computers that try to handle complex ...


8

There was a post explaining the changes, but is not easy to find. The link was on the 1.5.6 release changelog: http://www.badlogicgames.com/wordpress/?p=3666 And the link about changes in fonts was: http://www.badlogicgames.com/wordpress/?p=3658 private static GlyphLayout glyphLayout = new GlyphLayout(); private BitmapFont fontA = new BitmapFont(), fontB = ...


7

The obvious answer to this question is to sit down and watch through the entire archive of Handmade Hero. It is exactly what you are after. It is literally a tutorial on how to make a game from scratch, without engines or libraries. Obviously it is very long.


6

This is flawed. Some reasons here The goals in game development: Keep development costs down. Developing with threads is more costly, it requires more developer hours. Indies can't afford it and big companies only use it when there is a proven benefit. Do not complicate maintenance more than needs be. Debugging and even sometimes reading code that uses ...


6

To put it bluntly, you can't. Java does not allow the user to define operator overloads. You will have to continue to use the Vector3::add(Vector3) method that you have already created. Java is Java, Python is Python (C++ is C++, and C is C); they are all different languages that do different things. You shouldn't expect one thing to work because it works ...


6

As someone who has recently released a libGDX game on Steam, unlike .NET and DirectX, Steam does not provide an option with your application to automatically check and download the version you need of those libraries. It's obtrusive to the user to make them install Java as a system library, as most still view the JRE, especially Oracle's, as some kind of ...


6

Before Diamond-Square begins, you'll have to make sure the outermost boundaries (and the maximum number of potential midpoints generated therein) are set equal on either side of the map (in x and y). Only then can you begin full generation of the centre with something approaching a seamless wrap. What they meant by "consistent" is "all outermost corners and ...


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.


5

That's because you limit your frame rate, but you only do one update per frame. So let's assume the game runs at the target 60 fps, you get 60 logic updates per second. If the frame rate drops to 15 fps, you'd only have 15 logic updates per second. Instead, try accumulating the frame time passed so far and then update your game logic once for every given ...


5

Don't keep newing up TextureRegions, try re-using one and just change the parameters of that. private TextureRegion bgRegion; public void create() { bgRegion= new TextureRegion(bgTexture, -1 * (int)bgObj.getX(),0,256,240); //bgObj is a scrollable object where in each update changes X value of position(Vector2): moves left. } public void draw() { ...


5

I'm not entirely sure what the specific issue is with your setup, but there is a fairly in-depth explanation here of using a genetic approach to training neural networks. One possible theory: generally in situations like games, NN's ability to learn patterns across long periods of time is limited. One way some people (like the author of the blog linked ...


5

You can check every block if it is exposed to air (=no other block) on any side or completely enclosed. Those which are completely enclosed shouldn't be rendered as they are not visible anyways. This shouldn't be done during every render call, you should only perform such checks if they are necessery. A possibility is that every surrounding block is checked ...


5

Every time you call readLine() it moves ahead in your file. So on every loop you're actually reading 4 to 8 lines instead of 1. Once you run out of lines to read, readLine() returns null which causes the NullPointerException. change your loop to: while(true) { String str = bf.readLine(); if(str == null) { break; } ...


4

If a chunk is C world units along an axis, you can convert a world unit W along that axis to a chunk index along that axis by floor(W/C) (or simply rely on integer division to drop the fractional part of the result). Now, you have to be careful since you can't actually have "negative" indices into the chunk array, which is what you'd get if you have a ...


4

JNI is a way to go if you want full access, but the Steamworks Web API might be an easier way to go. It's basically an HTTP/HTTPS-based channel to the Steamworks functions, designed to be instantly compatible with access from Java, Python, Ruby, and really anything that isn't intrinsically C/C++. Of course you know that the issue with JNI is that you would ...


4

Yes, generally, games are a single main loop. Games in Java may have a separate main loop for each menu/screen/mode due to Java's idioms, but that of course does not solve your animation wait problem. For things like the problem you are running into, consider using events. e.g., when your animation system finishes playing an animation, it can send out an ...


4

There is a nuance here. You asked: So I am wondering, why not just do something like: while(running){ Update(); } I believe this would call every frame. This is false. If you place your Update() method inside a simple while(true) loop, it will be called as much times as the processor can handle. If your processor can run it 123456 times a ...


4

In very broad strokes, you can accomplish this by: Yes, using shaders Binding three textures to the shader program before drawing On your polygons, have the usual UV vec2 for each vertex. This is used by any of the textures Have another attribute which is "weight of each texture at this vertex". It could be a vec3 or three separate floats. For the ...


4

The problem you are facing is conversion between two different coordinates systems: the graphical one and the input one. Graphics coordinates Like you said, libGDX uses a 1 to 1 ratio between space coordinates and pixels, and starts in the bottom left corner. But it can be anything, really. That is just the default behavior of libGDX. You could change the ...


4

Each time the loop executes, nextGameTick is incremented by 1000 / TICKS_PER_SECOND. This puts an upper limit on the framerate. In this case, it caps the framerate at a maximum of 60fps, because if a frame takes less than 16.67ms (1000 / 60) to execute, it waits until 16.67ms has passed from when the last frame started. By combining it with the loops ...


4

Try adding in a Velocity variable. But more importantly, you need to keep track of your deltaTime, which is the time that elapsed since your last frame. More than likely the framework you are using has this, if not you will need to implement one. float Velocity; float Speed = 3; //Your speed could vary here if(gas){ Velocity += Speed * deltaTime; ...


4

First, a side note: you seem to need the speed, not the velocity. And since it's constant, you don't need the average speed, since that's the same as the speed. Second, an advice: per your question and responses to comments, it really seems that you should be re-factoring the code of your game. There is almost always a way back from a messy setting, and not ...


4

Not sure if this is really the right question for this site. But I still personally uninstalled and reinstalled my Android Driver to install it again. It's not in English but all buttons should be placed the same. Make sure you have the right driver for your devices. Some might require special drivers. Select show all units. Make sure you select the ...


4

I had some time to read up on this and decided to share. In "serious" ray-tracers that grown-ups use, cones and other similar shapes such as cylinders are usually represented as either tesselated surfaces or as quadric shapes. There exists pure cone-only intersection code that may or may not be more optimized, but implementing the more general quadric ...



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