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


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


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

Here's a vector-based solution. I haven't tried it, but it seems fine conceptually. Theory I gather you've stored the shape as line segments. Here's the letter A represented with three line segments. I've assumed that paths in the user's drawing are stored as lists of points. We can "inflate" those line segments to allow an error margin when checking ...


6

This is actually really simple. All you have to do is add another ClickListener which listens for Right Clicks (the default only listens to left clicks). To do this all you have to do is this: someButton.addListener(new ClickListener(Buttons.RIGHT) { @Override public void clicked(InputEvent event, float x, float y) { //do whatever } ...


5

The new project generator comes with autogenerated .gitignore file like: ## Java *.class *.war *.ear hs_err_pid* ## GWT war/ html/war/gwt_bree/ html/gwt-unitCache/ .apt_generated/ html/war/WEB-INF/deploy/ html/war/WEB-INF/classes/ .gwt/ gwt-unitCache/ www-test/ .gwt-tmp/ ## Android Studio and Intellij and Android in general android/libs/armeabi/ ...


5

Alright, so you're working with two rectangles here. A larger static one (the map) and a smaller moving one (the camera) inside of it. What you want is to not let the bounds of the smaller rectangle move outside the inner bounds of the larger rectangle. // These values likely need to be scaled according to your world coordinates. // The left boundary of ...


5

If you are using LibGDX, you need to forego the concept of Activities and Views, since your entire game will now just be a single Activity. To have a main menu when you game starts up doesn't switch the Activity, but just presents a different set of objects to be rendered to the same Activity. The easiest way to accomplish this would be to do the following. ...


5

It's easy: Fonts do not need to match resolution, they need to match pixel density. Pixel density is measured as pixels per inch(PPI), or pixels per centimeter. There's also a measure unit called density independent pixels(DP). 1dp is the size one pixel has on a 160 PPI screen. Now coming back to fonts, try to make this test: put your laptop to run on ...


5

There are three main ways (that I know of) to obtaining input in LibGDX. The first is as you said, changing the ClickListener, the second will be setting the setting the current screen as an implementation of InputProcessor , and the third will be obtaining the mouse click through a new class, or a sub-class to get the input. I'll elaborate on each: The ...


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

I assume this is because in these cases the grid lines are not exactly on screen pixels, but somewhere in between. Is this correct? Yes, this is correct. The camera in LibGDX is based on a vector, which is made out of floats. When your camera is in between pixels (like at (1.2f, 63.5f)), then you will start to see that blur you mention because the ...


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

It's because you're doing integer math in the first case, but not in the second. First, a quick look at the documentation getWidth int getWidth() Returns: the width in pixels of the display surface. < getHeight int getHeight() Returns: the height in pixels of the display surface So now we know that the two methods return integer ...


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

What's happening First of all, note that this behavior is not specific to oblique collisions. Below is an example of two balls colliding head on with a wall. All fixtures have m_restitution = 1.0, and m_friction = 0.0. The ball on the left is traveling with v = 0,1 and the ball on the right has v = 0,1.01. I found three similar questions asked on the ...


4

At the moment, you're moving the piece with a linear interpolation. That means that every timestep, the tile's position changes by the same amount. position = position + translation * timestep You could use any function there: position = position + translation * f(timestep) Then the position changes by an amount determined by the function f. There ...


4

I tried it out in RUBE and the Prismatic joint works fine for me: What you may not have realized is that you can set joint limits on the prismatic joint, which makes this a lot easier to set up. You can tune this by playing with the mass of the block, and the linear damping. You might also want to set the coefficient of restitution to zero.


4

The particle system solution is likely the one you want as creating and maintaining 100+ sprites with varying positions and gravity is exactly what a particle system does. Only it will handle object re-use for you automatically which will help make it as efficient as possible. Just create a line emitter that covers the entire width of your viewport. ...


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

I don't know if it is because of a poor component that causes the false readings or a extremely precise component that registers the spinning of the earth, as it orbits the sun, as our solar system spirals through the galaxy. Either way, this is a common problem. The solution is to use some type of filter to smooth out the "extra" readings. There are ...


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

There are several different options for handling what you are attempting: These are not all or nothing solutions, you can mix and match them to balance the workload between programming and creating animations. Option 1 Can be used on a case by case basis. Obscure it. The transition between animation states can simply be hidden behind various effects. Blood ...


4

The artifacts are caused by scaling the images using point sampling / nearest neighbourhood filtering, which effetively doubles some of the pixels from the original image. To get better results, switch to bilinear filtering which uses weighed average of multiple pixels. The result will be a little blurry, but should look a lot better than the current one. ...


4

Alpha mask texture approach In case your circle would always be the same size, using a second alpha mask texture would be the way to go. You would make it a grayscale mask texture and use its value as the alpha value while drawing. Using a texture had the benefit of having anti-aliasing built into the mask (ie. at the borders of your circle, the pixels can ...


3

While rendering the two scenes, the first one over the target one, you can just make a fade effect on opacity on the first one. Here is what i suggest : Create a "TransitionScene" wrapper that take the two scene as parameters and have them rendered and updated (override act and render) Apply a color action to have the first scene opacity move from 1 to 0 ...


3

Without any further information (and you don't provide enough for us to give a positive answer for sure), the most likely solution for your problem is that you're introducing some granularity you don't realise. For example the line: offset += 400 * Gdx.graphics.getDeltaTime(); Gdx.graphics.getDeltaTime() will return a float, and it will likely be a very ...


3

You need to interpolate between the camera's position and the target position. It looks like libgdx has a Vector2.lerp() linear interpolation method that you can use, however if you want something that has a smoother ease in/out you'll need to use another method, which it seems you can do using Vector2.interpolate(). Call one of these methods every frame and ...


3

The lerp method from Vector2 seems to be what you are looking for. From the documentation: Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored in this vector. So basically, you need to calculate where the player should be at the end of the movement: targetPosition = new ...



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