Tag Info

Hot answers tagged

3

In the second case it is not drawing because the constructor with no arguments doesn't set a width and height for the image, however the constructor that takes the drawable obtains the values from it. To fix in your case: Texture texture = new Texture(Gdx.files.internal("cookie.png")); Image itemImage = new Image(); itemImage.setPosition(10, 10); ...


2

You can use pendulum physic to approximate your rope swing. Calculate the fluctuation period (this is true for small fluctuations) T = 2*PI*SQRT(L/g) where: PI = 3.14 g = 9.8 (if I remember) the earth gravity acceleration L : the rope length, or better the length from rotation fulcrum to the character hands. Then you get the fluctuation angle as ...


2

Two very general suggestions -- Often in board games a good human player runs through a list of rules or if-this-then-that mentally. If you can understand what a good human player in your game would do, then it's just a matter of translating that into code. This is generally referred to as "rules-based AI". If the game is strategically simple, then ...


2

A lot of great Libgdx extensions have been added to the maven repository such as freetype, tools and many other great libraries. This means you can add extensions in a blink of an eye, at least if you used the gradle LibGDX setup. In your case you want to add freetype, look it up in the link above and select the version you need. Now select the tab Gradle ...


1

I personally never calculate an angle like that. I like to work with vectors, it might be slightly less efficient but this way you can do it step by step, it gets more readable and easier to understand. So what is a vector? A vector is essentially a direction and a magnitude together. Often in games it is used as a position data structure too but ...


1

at the base of some perlin noise implememntatio there's a perturbation array private static int[] p = {151,160,137,91,90,15, 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 88,237,149,56,87,174,20,125,136,171,168, ...


1

The glGenVertexArrays() interface was added to OpenGL core contexts in version 3.0, the same version in which immediate mode rendering was removed from OpenGL (although it had long since been deprecated, 3.0 is where it finally absolutely went away) So you are correct. If immediate mode drawing works, then you are using an OpenGL context old enough that ...


1

As Menno Gouw mentioned, you could use a noise function although you can actually use any PRNG. You will need to seed it every frame though, based off some predictable, relative value, such as the player position. If the player only moves horizontally, then this is simple. seed = player.x I don't suggest a noise algorithm in this case, since the ...


1

In the first function, the division will be integer division and the result of the division will be casted to double. It is thus equivalent of return (double)(System.nanoTime() / 1000000000); So for example if the System.nanoTime() gives a value of 142154, the getTime() will return 0, because in integer division the fractions are ignored. 142154 / ...



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