Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (753)
Games in Android Showcase (228)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Discussions / Miscellaneous Topics / Re: What I did today on: 2018-02-07 09:10:03
I finally found my bug in my android game... I was totally clueless what caused this weird stuff.

My characters in game perform Actions. In code it's an object, with three methods:

1  
2  
3  
public abstract void setup();
public abstract void process();
public abstract void finalize();


Now finalize got called when the characters finished casting a spell for example, then it substracted the mana cost.
When I turned off the screen on my device sometimes I lost a little bit of mana randomly.

I have overridden the finalize method which gets called by the GC... Took me a whole day to find this...
2  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [LibGDX] Interpolation on: 2018-02-02 21:19:35
Thanks for the explanation! I think I got it now Smiley
3  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [LibGDX] Interpolation on: 2018-02-02 16:31:43
Look at how the interpolation you are using (Swing) is implemented:
https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Interpolation.java#L156
https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Interpolation.java#L400-L406

Using an interpolation argument `a` of 0.1f with a default scale of 1.5f results in an interpolation factor of -0.02f when running that code.
That "Swing" interpolation curve looks like this:

0.0 -> -0.0
0.1 -> -0.02
0.2 -> -0.04
0.3 -> 0.0
0.4 -> 0.16
0.5 -> 0.5
0.6 -> 0.84
0.7 -> 1.0
0.8 -> 1.04
0.9 -> 1.02


Thanks for the insight and the links!... I'll stick to linear for now, until I properly understand interpolation Cheesy (I had the assumption, that nearly all of the interpolations do the "same" thing, but with different "speed" matching the curves posted on the libgdx wiki.) It seems I was totally wrong Cheesy
4  Java Game APIs & Engines / Engines, Libraries and Tools / [LibGDX] Interpolation on: 2018-02-02 11:18:42
Hello, it's me again... I never had such a headache using LibGDX in the past few months, as I ran into another weird behavior Cheesy

I want to use Interpolation between two vectors. The thing is, they dont work so far.

I use the following code to do the interpolation:

Initialization
1  
2  
3  
4  
5  
realPos = new Vector2();
targetPos = new Vector2();
realPos.set(80.0f, 80.0f);
targetPos.set(280.0f, 80.0f);
interpolation = Interpolation.swing;


Update code
1  
2  
3  
4  
if (interpolation != null) {
            realPos.interpolate(targetPos, 0.1f, interpolation);
            Gdx.app.log("Position", realPos.x + "/" + realPos.y + " - " + targetPos.x + "/" + targetPos.y);
}


And this is what I get with logging... The first one is the real position vector, the second after the "-" mark is the target.
I basically goes to negative infinity...
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
Position: 71.200005/80.00001 - 280.0/80.0
Position: 62.01281/80.000015 - 280.0/80.0
Position: 52.42138/80.00002 - 280.0/80.0
Position: 42.40792/80.00003 - 280.0/80.0
Position: 31.953873/80.00004 - 280.0/80.0
Position: 21.039845/80.000046 - 280.0/80.0
Position: 9.645598/80.00005 - 280.0/80.0
Position: -2.2499952/80.00006 - 280.0/80.0
Position: -14.668996/80.00007 - 280.0/80.0
Position: -27.634434/80.00008 - 280.0/80.0
Position: -41.17035/80.000084 - 280.0/80.0
Position: -55.301846/80.00009 - 280.0/80.0
Position: -70.05513/80.0001 - 280.0/80.0
Position: -85.45756/80.00011 - 280.0/80.0
Position: -101.53769/80.000114 - 280.0/80.0


I must do something very stupid here  Huh
5  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [LibGDX] Weird texture scaling on: 2018-02-01 07:43:51
Wow, I didn't imagine totally transparent pixels can cause such trouble. I filled the transparent areas as you said, and there is no problem now  Smiley
Million thanks!!!
6  Java Game APIs & Engines / Engines, Libraries and Tools / [LibGDX] Weird texture scaling on: 2018-01-31 19:53:45
Hey everyone!

I have a small issue with texture scaling in my game... There is a particular texture, this is a 40*40 TextureRegion from a 256*256 Texture:



When it gets drawn on the screen, it looks the same, but when I resize the window to basically any size other than the normal (I have 880*520 resolution) I get this "behavior"



Notice the "inconsistent" pixels, especially at the bottom right of the image.
I use FitViewport to handle the scaling of the window. Relevant codes:

Texture creation:
1  
2  
3  
systemTexture = new Texture(Gdx.files.internal("system.png"));
systemTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
region = new TextureRegion(systemTexture, 0, 0, 40, 40);


The camera and viewport that I use
1  
2  
3  
4  
5  
worldCamera = new OrthographicCamera(Anais.SCREEN_WIDTH, Anais.SCREEN_HEIGHT);
worldCamera.setToOrtho(true);
worldCamera.update();
worldViewport = new FitViewport(Anais.SCREEN_WIDTH, Anais.SCREEN_HEIGHT, worldCamera);
worldViewport.apply(false);


Resizing:
1  
2  
worldViewport.update(width, height, false);
worldViewport.apply();


Rendering code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
worldCamera.update();
batch.setProjectionMatrix(worldCamera.combined);
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.setColor(Color.RED);
batch.draw(region, x, y);
batch.setColor(Color.WHITE);
batch.end();


Now I dont have a problem with blurriness, as I intend to use Linear interpolation. But I expect something like this:



This image is blurry, but the semi transparent pixels are consistent. (I hope you understand what I mean)

What am I doing wrong? Or is this an expected behavior with libgdx and resizing?
I use libgdx 1.9.8
The image is red on purpose, (its in the code)

Any help would be appreciated  Smiley
7  Game Development / Newbie & Debugging Questions / Re: [SOLVED] Collision detection crash on: 2014-04-14 05:29:52
Just a sidenote: you should not make a new Rectangle object on every collision check, that will kill the performance. Try to reuse one rectangle object (changing its parameters before passing to the isBlocked function).
8  Games Center / WIP games, tools & toy projects / Re: Graveyard Invasion on: 2014-03-31 09:12:44
Reminds me of crimsonland... I love these kind of games! It took me a few seconds to realize that shooting is done using the cursor keys... (It would be a good idea to print the controls on the screen, before starting the game).

I survived for 7 nights. (and killed 123 enemies)
9  Game Development / Newbie & Debugging Questions / Re: LibGDX yDown and text problem on: 2014-01-15 07:22:12
If you use Y axis facing down, you need to flip the texture of your BitmapFont too. You can achieve this by calling the proper constructor when creating your font.

1  
2  
3  
4  
5  
6  
   /** Creates a BitmapFont from a BMFont file. The image file name is read from the BMFont file and the image is loaded from the
    * same directory.
    * @param flip If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner. */

   public BitmapFont (FileHandle fontFile, boolean flip) {
      this(new BitmapFontData(fontFile, flip), (TextureRegion)null, true);
   }
Pages: [1]
 
nelsongames (19 views)
2018-04-24 18:15:36

nelsongames (17 views)
2018-04-24 18:14:32

ivj94 (608 views)
2018-03-24 14:47:39

ivj94 (53 views)
2018-03-24 14:46:31

ivj94 (402 views)
2018-03-24 14:43:53

Solater (66 views)
2018-03-17 05:04:08

nelsongames (111 views)
2018-03-05 17:56:34

Gornova (176 views)
2018-03-02 22:15:33

buddyBro (747 views)
2018-02-28 16:59:18

buddyBro (94 views)
2018-02-28 16:45:17
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!