Tag Info

Hot answers tagged

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

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

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


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

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

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

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

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

This might be too late for you, but for the benefit of web searchers, I'll answer: Create an empty canvas (AWT). Set the size of the canvas to be equal to the LWJGL Display. Add the canvas to the Java Swing form. (There's a reason for this). Set the canvas as parent of the LWJGL Display using Display.setParent(canvasName);. (Remember you might also need to ...


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


4

It would be nice if I could retrieve the values from memory after the the shader has calculated them but it doesn't seem possible - or advisable But, it IS possible, and I would advise it: https://www.opengl.org/wiki/Transform_Feedback


4

You probably have object leaks. Objects that are still referenced somewhere in an array or list, creating more and more objects for the garbage collector to process as the game advances. Or more and more AI objects that are off-screen but still active and processing on every frames.


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

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


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


3

why not create a list of enemies in the level so the draw becomes: List<GenericEnemy> enemies;//filled during construction Render(){ //Render elements common to all levels draw(background); draw(playerSprite); for(GenericEnemy enemy : enemies) { draw(enemy); } } where GenericEnemy is a superclass of all enemy ...


3

Basically, you'll need some kind of container or collection to hold all entities. Then create some spawn or factory function to actually add them. When drawing (or updating) your game entities, you'll just iterate through this list and modify them accordingly. Here's some pseudo-code example: List<Entity> entities; function spawnEnemy(position pos) ...


3

In my experience with android, it is the garbage collection the kills the performance, not the allocation, although these two are tied hand and hand. As mentioned on the comments, pre-allocation is a way to deal with this issue. This is known as a memory pools. Another similar solution is object pool pattern. An object pool allocates as needed, but does ...


3

You don't need to call glVertexAttribPointer for the indexes; the indexes are found from the bound GL_ELEMENT_ARRAY_BUFFER during the drawElements call (which is saved in the VAO state IIRC). However indexes start from 0 so the contents of your index buffer are flawed they should be: {0,1,2,2,3,0}



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