Tag Info

Hot answers tagged

2

How many milliseconds since Jan 1 1970? About 1425579436439. That's more than fits in a integer. You need to use a long.


2

It's a bit inconvenient: You have to create each array manually, along each dimension: Create an object array with size sizeX, with element type [[I (a 2D int array) At each entry of this array: Create an object array, with size sizeY, with element type [I (a 1D int array) At each entry of this array: Create an int array, with size sizeZ Here is an ...


2

First your use of the aspect ratio is nonsense. The aspect ratio is the relation of width to height. So if you have float aspectRatio = (float)myGameHeight / (float) myGameWidth; This means that the the following is true: myGameHeight == aspectRatio * myGameWidth If you want to preserve the aspect ratio of the screen you need to do the following: ...


2

After days of stress, I've finally fixed the problem. After performing a backtrace on the main thread I discovered the program came to a halt when trying to load the Google Analytics trackers. This is the thread backtrace: at com.google.android.gms.analytics.ae.getLogger(Unknown Source) at com.google.android.gms.analytics.ae.W(Unknown Source) at ...


2

I think the fastest method will be by not generating the numbers at board generation (I know it's almost cheating). It's most likely fastest to only generate the number when the player clicks on a square rather then during board generation. Secondly consider how you are going to generate mines, is each place on the board going to pass a check (loop over ...


2

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


1

Because of type erasure you lose the compile time type information of generics when transmitting data over network. If you need it on the receiving side again, you have to put the type information back yourself somehow. It's impossible to say how you should do this, but typically it involves either enums or class names and some type casting.


1

Create two dimensional array Randomly place mines and place mine location to list Foreach mines and add +1 to adjacent cells Mine creation int x = random.next(min, max); int y = random.next(min, max); mineList.add(new XYClass(x,y)) Number calculation Foreach(XYClass xy : mineList) addPlusOneToAdjacentCells(xy); This way, you don't even have to ...


1

Are all coins doing the same animation? You could make a method in the Animation class that takes a coin as an argument, then performs the animation on that coin. Then, on another class, you make a loop that traverses the coin list and calls the method in your Animation class, therefore animating each coin as you go through the list. You can also add delay ...


1

Your basic OBJ, or Object Wavefront file only contains geometry data - vertices, normals, texture co-ords, and optionally material data in an second file. It does not contain any sort of skeletal structure or motion data. Collada on the other hand contain both geometry data and optionally skeletal structure and motion data, along with scene information (eg ...


1

Calculating the vector that points from a spring at point A = (x0, y0) to a spring at point B = (x1, y1) is simply: v = (x1 - x0, y1 - y0) Assuming no other forces acting on the player, then changing the player's velocity to some scalar multiple of v when they hit spring A would direct them to spring B. If another force like gravity is involved, then, ...


1

That is right idea for reading/writing images but you'll want to get your "ImageLoader" class from a library, which will then give you a regular bitmap in memory to work with. The layout of that bitmap class is going to depend on the library you use. To see why, or what you need to handle if you want to write your own, see the W3C PNG Specification.


1

first you transform the cannon ball into the coordinate space of the ship. Then you act as if you want to add the ball's model to the octree and step down through the nodes. If the ball straddles a boundary line then go through both sides. Once you get into a leaf not then there is the bucket with faces to test with.


1

There are a few steps that you need to follow to accomplish this goal, they are as follows: Get the distance that the player has traveled (ie the amount of time the w key jas been pressed times some sort of speed multiplier) Calculate the length of each of the sides of the right triangle that's formed by the relation of your mouse cursor to the position of ...


1

The issue is the else condition after you check the A and D keys, since if no key is pressed it will reset the direction to 0, 0 every time the update() method is called. Instead of calling moveLeft() and moveRight() in the touchDown and touchUp you should keep track of each pointer passed by the touchDown and touchUp methods and check whether the pointers ...


1

Yes, you'd essentially create a bridge - no wrapper - but that's terminology. The basic idea is to use two network connections. You've got one listen port that will act to the actual game as if it was the actual game server. The bridge will also establish a connection to the real server and pretend to be the actual game client. The rest is pretty ...


1

If you're also working with box2D, you could try box2Dlights, it's a pretty nice wrapper and it's easy to implement as well.


1

There are ways to do dynamic lighting without shaders, although they're usually not as efficient. They often involve raycasting. The link below has some links to useful resources regarding dynamic lighting. http://www.java-gaming.org/topics/2d-dynamic-lighting/27012/view.html


1

Game states can be synchronised by sending "deltas"—messages that describe how to get from one game state to the next, rather than sending the whole state. You seem to have figured out that this is possible. To get you started on the right path of thinking, here's a more concrete (but naïve) way that could be implemented: In server code, store a boolean ...


1

Crashing? Does not make sense. You can send a lot of data nowadays. There is no reason using a lot of bandwidth would crash a properly implemented client. If it is literally crashing, you may need to debug some more. What to send: You don't need to send everything. Remember the client program is only used (normally): To accept input from the user, parse ...


1

NPC on a path only need to be sends periodically. However instead of only the position you also send the speed and direction the NPC is going. That you only need to send the data a few times a second and the client can extrapolate the current position of the NPC. Health should only be sent when it updates and once every few seconds as a sanity update.


1

A simple approach might be to first resolve the movement in the X axis and after that in the Y axis. This way you'll always know which component of the movement caused the collision, and you can resolve the collision for that component without even having to touch the other one. For instance: This will make sure we don't pull movement out of nowhere. Keep ...


1

The way I solved this a long time back (I forgot about this question entirely until now), was that I just basically checked if the boxes intersected, because the rotation was just for a first person camera. So it only would have effected the viewport and movement code, the actual collision was just checking for an intersection. Basically, it was just me over ...



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