Tag Info

Hot answers tagged

33

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

Storing the completion information in a local file is a simple and perfectly acceptable method of doing so. Fundamentally, this is what every game will do to track progress (in some fashion, although the specific formats used for the data and the storage mechanism will differ). Protecting the file from tampering is more difficult. If there's no compelling ...


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


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

You can create a replay file as proof of work while the player is playing. Start the game, save the starting conditions including the name of the level and the pseudorandom seed, record the exact timestamped input states (mouse movements, key or button presses, etc.) that your game's input layer passes to its logic layer, and stop recording once the ...


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


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


7

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


7

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


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

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


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

in your keyPressed and keyReleased you can use a Map to map the KeyEvent.VK_* to GameInput make a new enum with the actions you want to be controllable enum GameInput{ FORWARD, LEFT, RIGHT, BACK,PAUZE,... } and in Controller you have a Map that you use: public void keyPressed(KeyEvent e) { game.setKeyDown(keyMap.get(e.getKeyCode())); } public void ...


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


5

The problem is you need to close the loop, to make sure the lasso is complete (based on the behavior of the video). You do that by testing if one of the segments intersect with another segment, thus closing the loop. It might look something like this (note I don't use libgdx, so this is untested): Array<Vector2> path = p.getPath(); // Look for an ...


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

You seem to want to keep the same textsize/screensize ratio. Basically what you do is develop at one resolution and let that be scale 1.0. Then you divide the new screen width by the old width and that is your scale factor. For example. Developing on 2560x1440 with font size 16 and running on 1920x1080. Font size will be: 1920 * 16 / 2560 = 12 I do the ...


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


5

Sarting with the clouds, a simple method is to draw them as three layers: Layer 1 is the bottom layer, and is drawn first. It just contains the cyan background. Layer 2 is the middle layer, drawn between the other two, and it represents the 3D highlights. The background in this layer would again be transparent (represented by a purple colour in the ...


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


4

Before addressing the specifics of your question, I do want to point out that I disagree with your approach to your inheritance model. A Game generally does not implement a Scene but instead a Game consists of one or more active Scenes that are being rendered and updated in a main loop. It's important to think about whether a class relationship can be ...


4

If you use an algorithm like Bresenham, where the two lines can be different, depending on their start- and end-position, you then have to either: Plot both lines and use the result of both plots for your LoS calculation. Plot only one line (for example always from Player to Enemy) and use this one LoS calculation for both entities.


4

Short answer: no. Long answer: Game Maker's performance are really bad. If you are a good programmer, you will find yourself hitting the performance wall more than once or pay for the YYC (Yoyo COmpiler) which unlocks decent performances at a price. Libraries like libGDX, slick2D, LWJGL or any other will beat GameMaker by a lot. Object oriented patterns in ...


4

So in general, JSON works really well for storing parameters and settings, but for storing big blocks of data like tile maps, you'll probably want to use your own format. JSON can be really repetitive, storing 256K copies of the string "GRASS_TILE", and that could be part of what's causing the slowdown. Using a SQL database probably isn't what you want to ...


4

If I understand correctly, you have three points A, B, C, and three points P, Q, R and you would like to know the affine transform (i.e. preserving distances) that transforms the first set into the second set. Finding the transform is straightforward; you just need to create two orthonormal bases from your sets of points, fill matrixes with the basis ...


4

You should consider using a plain 2d-array or alternatively an array of rooms, where each room is a 2d-array or a grid. A grid would looks something like this: The player is the yellow dot and the blocks are the green ones. if the player is the light gray square, you only need to check for blocks that around that square area. This saves you the time of ...


4

A common way to implement states and branching in a quest is through quest variables. I have witnessed this technique in many RPG titles from companies like Bioware or Bethesda. This is also what I am doing in my current project, and so far it works really well. Just add a script binding which allows scripts to store values in variables and later retrieve ...


4

This is actually quite well-detailed at this page. Please note that I am going to detail the common protocol introduced in version 1.7. Additionally, a new protocol was introduced in 1.9pre4 that contains additional information not found in the previous protocol. Let me detail how to get the basic server information in 1.7+: Send a "handshake" packet with ...


4

As already pointed out in the comments and answer: This can be arbitrarily complex. Particularly, depending on the exact use case and performance requirements, you can employ some rather sophisticated data structures in order to make these tests fast. The bounding box test is the simplest one that should be done in any case (and in fact, could already be ...


4

EDIT Actually, Timer's schedule method should work in this case - maybe it's running straight away because you have 100ms as your delay time instead of 1000 (from your code above that is). If you're working in a multi-threaded environment, then make sure you handle possible concurrency issues. A possible alternative would be to use System.nanoTime() ...



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