Hot answers tagged

18

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


12

Implementing logic by threads is almost always a very bad idea. Multi-threaded programming is difficult! You will run into race conditions and deadlocks resulting in impossible to reproduce bugs. There is usually only one justifiable reason to use multithreading, and that's performance: A program can sometimes be made faster by sharing work between CPU ...


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


9

Modular arithmetic can help you here. % is the modulus operator in Java, and the expression X % Y returns the remainder of the division operation X / Y. This is useful for making numbers "wrap around." Based on your sample code, a full cycle of your day is 200 units of Statistics.duration. The first 50 are the day portion, the second 50 are the noon ...


9

It won't hurt performance. It might in fact be (very, very negligible) faster because you save the overhead of passing these objects to the game objects. The reason static classes are often frowned upon is that their static properties are global variables and globals cause all kinds of problems architecture-wise. For example, when you ever decide you might ...


8

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.


8

You can accomplish this with bitmasking. Each tile determines if it is an edge tile, based on its neighboring tiles. From the image above, we would assign a value to each neighbor. 1, 2, 4, or 8 based on its location. If the neighbor is a different tile Type than the one in the middle, you add the corresponding value. These values map out as shown ...


7

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


7

Create a thread for each player is an overkill, 5000+ threads will trash your server performance. My suggestion is to create a job queue where you put all your 5000 players state then you can launch a small number of thread, depending on your server architecture, that will execute a simple loop like this. while(true){ dequeueAIState(); ...


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

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

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


5

Build a 2D array of enum Relations, where row and column are the Factions. You can then check using a simple array lookup: public boolean checkIfHostile(Faction faction1, Faction faction2) { return relations[faction1.ordinal()][faction2.ordinal()] == Relations.Hostile; } Fill it in making sure [x][y] == [y][x] and that the diagonal [i][i] is ...


5

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


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

Disclaimer: artemis-odb dev here. -Changing the Entity System, i know of Artemis, but it would be great if you could point me at something else for Java if you know a library that does it better. I'm not sure whether you're referring to vanilla artemis or artemis-odb, but the latter improves on performance considerably with regards to mutating ...


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

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

I found the solution, so I think I should write here for other ones later. First I download the source code of box2dlights. Then open BaseLight.java and find "segments" member variable. This variable contains all information about what I was finding. This code below is just for debugging purpose: rayHandler.setCombinedMatrix(camera.combined); ...


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

If you want to write a fully functional physics engine I'd recommend learning some basic newtonian physics. Wikipedia is a good starting place for those kind of things. That being said I'll try to provide some information about your "problem" and beyond that. Physical explanation: At every point in space you have a local gravity, usually named g. g is an ...


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



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