Tag Info

Hot answers tagged

32

It will cause one CPU core to always run on 100%. This usually doesn't cause any harm to the system. CPUs are designed to run on 100% for hours. But on a mobile device it will drain the battery quickly and heat up the device, which will likely cost you about a stars in your store ratings. On a desktop computer this is less of a problem, but it will consume ...


18

Demo GameDev Meta: Henshin Main!! :D The code uses a canvas clip region and requestAnimationFrame for maximum quality and efficiency. (It's better live.) I assumed you meant HTML canvas! Even if you didn't, other rendering engines (such as Android's 2D rendering pipeline, which you might have meant) also support hardware-accelerated clip regions. The ...


15

Think of the problem like this: How does a snake move in the original game? The snake moves towards its current direction. The behavior looks like the head appears out of nothing, and the last tail part disappears. You can have a list of snakeparts. What you want to do is remove the last item in the list which represents the last tail part. Then you want ...


12

The get methods do not take so much time, so you're right - this isn't the reason. What's probably happening is that the KeyEvents aren't executed every tick, but are showing the same behaviour as you expect in a browser or anywhere else - when writing something and you move the cursor with the arrow keys, it first moves one space, then stops, and only after ...


10

The PNG files are small because they are compressed. When the images are loaded into memory they are uncompressed and therefore take up more space.


9

What I would do is make the factions be simple symbols which represent their information regardless of members (name, description etc), and keep some sort of dictionary for each match, which keeps track of which players are in which faction. Dictionary<Faction, List<Player>> This also allows you to do more exotic stuff like players betraying ...


8

Conceptually, you can do that by animating the rotation of the cube (or as in Bloxorz, a cuboid) 90 degrees around one of its edges. You don't need move() at all! Side-on view of one rotation: Here's a seriously good JMonkeyEngine tutorial showing you how to rotate Boxes around pivot Nodes. It explains everything step-by-step. These are the important ...


8

Talking about the "best choice" is always difficult, as long as you did not specify the task that you intend to perform in all detail. But here are several aspects to consider. First of all: Java is not C. The memory management is completely different, so one has to be very careful when trying to apply insights from one programming environment to another. ...


7

In order to get a server list, you will need a central matchmaking server to which all game-servers connect and announce that they are online and to which all game-clients connect to obtain the list of currently online servers. How many servers are you going to have? For comparison, I remember that during the high-times of the original Counter Strike, the ...


6

The first method relies directly on the key presses. It's a standard behavior ( probably coming from the operating system ) for there to be a delay before it starts repeating itself. That's why it moves, then stops and then keeps moving afterwards. The second method sets a value for the velocity which is then applied to the x position. It's not exactly ...


6

The formula returns a scalar (the height of the water surface at coordinates x,y), not a vector. It is hard to tell what the authors had in mind, because the paper is very confused, but my guess is that it should have looked like this: Y(x,y,t) = A * cos(w * f(x,y) + wt * t + FI) Where f is a function that controls the shape of the wave. This function ...


6

Well, technically speaking you can generate textures using any language. Even if you don't have any output on screen, as far as your language can represent integer/float (could get away with integers) and arrays, you are good to go. The problem though is that not every texture could be generated procedurally. You usually need a formula as a stating point to ...


6

It's definitely possible, you would just need to create a thin layer wrapping the Steam SDK (or part of it) to java via the Java Native Interface I'm not aware of any efforts to have an opensource library for this.


6

Sphere-Sphere Intersection Let's start with the more obvious one - sphere-sphere. It's almost identical to the circle-circle case in 2D. We can project down on any plane containing the line between the sphere's centers to get an identical 2D picture: Here the first sphere has center c_1 and radius r_1, the second c_2 and r_2, and their intersection has ...


6

The simple solution would be to just discard and recalculate the power distribution in the whole grid whenever you make a change. Considering that your grid is only 18x18, it shouldn't be too computationally intensive to do so. Inverters might be problematic, though. What do you want to happen when the player connects the output of an inverter to its input? ...


6

I have good news and bad news for you: The Bad News: I don't know or remember any Java library that does what you want The Good News: It's really easy to implement this type of algorithm yourself! Here's a couple, you can mix them to optimize your collision detection depending on the type of shape. BB Collision Detection You can imagine a box around ...


6

How are you passing your normals to the vertex shader? It looks like those are the normals for each of the six faces of a cube, but the vertex shader operates on vertices, not faces. Unless you're doing something unusual, you need to specify a normal for each vertex. In addition, if you want a cube to look right, you will need 24 vertices rather than 8, so ...


5

Checking the surrounding tiles is pretty simple. You can do it pretty easily in a nested for loop: for(int i = x-1; i < x+1; i++) { for(int j = y-1; j < y+1; j++) { if(i != x && j != y) { //ignore the center tile //process tile (i,j) } } } This will loop through each tile surrounding tile (x, y). You'll ...


5

The way I do it, not in java but in some sort of c#/c++ hybrid, is I have an engine class (similar to your main class), which holds a Screen object. The screen object is an abstract class with two main functions, update and draw. The engine has one screen which it just calls the Update and the Draw functions. While I have no experience with it, I imagine ...


5

You have incorrectly implemented the formula as a function. The function is missing + 1 after the call to Math.sin(), which moves the wave to the range [0, 2]. Regarding your second problem, I don't see anything wrong. In fact the screenshot looks exactly like it should and seems to match the plotted curve. Try with k=10 and you should see the difference ...


5

Disclaimer: I have not used libgdx or Java before, this answer borrows syntax from the question and official documentation, and the code is untested To make the bodies 'fall' under the influence of gravity in box2d, you must first pass a non-zero gravity vector to the b2World when constructing the world World world = new World(new Vector2(0, -10), true); ...


5

I assume you really want to know two things: Will Steam accept my Java game? What do I need to do to make it work on Steam? The answer to #1 is "yes." Steam hosts other Java games (like Spiral Knights). For #2, I suggest you package your game using launch4j. This will provide you with native (Windows, Linux) wrappers around your application. Other ...


5

As others have said, the first step is separating logic that's shared from logic that's not. While it's great to draw that line wherever it's clear, your addendum illustrates that sometimes you don't have a clean line to split the code down. So, how do we solve cases where the client and server want to do semantically the same thing (play a sound), but take ...


4

If you are looking to use any 3D objects (lets say a chessboard with 3d pieces), you could make a series of quads, then manipulate the camera's position and target to get the angle/perspective that you want.


4

I'm guessing you have 64 bit java installed. The ParticleEditor.jnlp fails to run on a 64 bit JRE. What you would want to do is: Download a 32 bit version of JRE. Here is the Oracle link for that: http://www.oracle.com/technetwork/java/javase/downloads/java-se-jre-7-download-432155.html Just make sure you select a "x86" version of the JRE from the list, ...


4

You do not divide a screen into tiles, you create a field that renders tiles in a grid sequence. Those are usually some sort of bitmaps that are stored in memory and are placed one after another to form a bigger picture - the tile grid. For a 2 dimensional grid, you'd use two for..loops (one inside another) to render rows and columns. for(int i=0; ...


4

You need to create a new instance for each item in the array. String[][] blankM = new String[arraySize][]; for (int i = 0; i < arraySize; i++) { blankM[i] = new String[]{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"}; }


4

You should create a priority queue binary heap to keep track of burning tiles. The priority here is determined by the amount of time left until the event of interest occurs, in this case from what you asked I presume that is the time when the neighbouring tiles will be set ablaze. You shouldn't loop and decrease the delta from each of them. You should ...


4

What you are looking for can be found in this very good explanation: http://www.songho.ca/opengl/gl_transform.html But since I found it sort of confusing without hand holding I will try to explain it here. At this point you need to consider 5 coordinate systems and how they relate to each other. These are the window coordinates, the normalized device ...


4

Java defaults to using GDI (AWT, Swing). JavaFX supposedly will be able to make use of OpenGL in future. Java + LWJGL (an OpenGL wrapper that accesses native opengl32.dll via JNI) provides more direct hardware-accelerated support for Java. Flash Player 11 onward made use of OpenGL via Stage3D. Without using Stage3D, it is using a software renderer built to ...



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