Tag Info

Hot answers tagged

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


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


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


3

This should do the trick. Split coords using "whitespace" Foreach resulting array Split the pairs to x y Parse strings to int Create point Add to list String coords = "0,0 0,1 5,2 7,4 10,5" String coordsArray[] = coords.split("\\s+") // Results "0,0","0,1","5,2","7,4","10,5" List<Point> points = new ArrayList<Point>(); for(String s : ...


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


2

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.


2

Collision detection like this can be tricky. However - I do see a way around your problems. First, you definitely want to round off your "collision" position. In most cases, decimal numbers will cause collision problems when you're working with pixels (which are measured in whole numbers, usually). Here are two methods I thought up, in image form: (sorry ...


2

You have to return true from touchDown. Documentation says: The GestureListener can signal whether it consumed the event or wants it to be passed on to the next InputProcessor by returning either true or false respectively from its methods. So, if you return false from touchDown, that is the first even raised in all cases, it stops event handling. If ...


2

You could try to render the font to a texture, and lay that texture onto an deformed strip of triangles. But maybe somebody knows an easier way, idk


1

The best solution is to re-create project with libGDX setup tool and copy all source code and asses into it from old project. .project file is file that contains information about project Eclipse should know. Do you use Gradle? If so, do you import project into Eclipse as Gradle Project (right) or as Eclipse Project (wrong)? And it's pretty bad idea to use ...


1

In Bob's update method you do nothing with his velocity. He has no way of actually moving, with the code you have shown. You should do something along the lines of this before you reset the bounds: position.add(velocity.x * deltaTime, velocity.y * deltaTime);


1

In LibGDX Doc Gdx.gl.glClearColor(0, 0, 0, 1); and batch.setProjectionMatrix(camera.combined); is setting in render() method at a time. I use this definitions in create() method at once, and it is running perfect. So why should i use this definitions in render() method? is't it a performance loss? The clear color is part of your OpenGL ...


1

You can create a Cell and fill that with a tile from the TileMapTileSet, then set that cell at (x, y) coordinates in a particular Layer. For example, the following code sets the tile at (32, 64) in a layer to tile 42 from tile set tileset_name; TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get("some_layer_name"); Cell cell = new Cell(); ...


1

The easiest way to side-step this is: x = (int)x; y = (int)y; or x = round(x); y = round(y); Are either of these acceptable, visually? Edit: Diagram of modified SuperDoggy "Method 1" using floats: Precise overlap amount given by colliders Since you have so many cases, it may be helpful to make a helper for jiggling the rect: class CollisionHelper ...


1

As I understand it, now you are making some transforms and pass the matrix as a uniform which is the same for all meshes. What you should do, is send different matrices for each mesh, which could be for example members of the mesh class. Then send the uniforms before rendering each mesh. Something like this: void Update(){ mesh1.transform = ...


1

First, although I would side with option 1 ("more OO"), both options are fine in practice; since normal boards are small. BUT, this sounds like the classical application for the observer pattern. The idea here is that your UI has it's state, which is initially derived from the initial state of the board. The UI registers a change handler on the game's model ...


1

A nice way to implement what you are trying to achieve would be to use a SequenceAction and built in libgdx actions : tooltip.addAction(Actions.sequence( Actions.show(), Actions.fadeIn(1f), Actions.delay(4.5f), Actions.fadeOut(1f), Actions.hide()) ) Actions.show() basically call setVisible(true) on your actor and Action.hide() call ...


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

I managed to implement a pause funcionality that works perfectly well in my game, based on this tutorial: Create a volatile boolean variable in StartingClass private volatile boolean isPaused = false; Inside the run() method, use wait() surrounded by a try-catch. // GAME IS PAUSED try { if (isPaused) { synchronized (this) { ...


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

I thought this was a good solution for a similar problem, from a question (and answer) by me here on SO. Abilities here are essentially AI if they are tickable. I have a runnable that just runs through all Actors and their abilities and tries to tick() them. interface for manipulating abilities: public interface ActorAbility { // doesn't work, but ...


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