Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
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] 2 3 4
1  Game Development / Networking & Multiplayer / Re: What I need to host a java server on: 2015-12-16 19:35:27
I know I can use my PC, I know I can host my own Server and I already did using kryonet and libgdx (this community helped by the way)

I was trying to ask about hosting online in 3rd, what I need ? something similar to Tomcat? dedicated server? VPS ?(thanks for the VPS suggestion, I'm testing some stuff here).
I know I didn't ask clearly, I could have been more specific.

@noctarius
This is what you say when someone is trying to understand or learn something?

https://www.youtube.com/watch?v=TAryFIuRxmQ
2  Game Development / Networking & Multiplayer / What I need to host a java server on: 2015-12-12 20:37:00
To host an app online, I can deploy with Apache Tomcat. But to host a java server, what I need?
3  Game Development / Newbie & Debugging Questions / Re: What is the best 'simple light' effect for 2D Android Games? on: 2015-10-06 16:43:44
Hello and sorry for the long wait, I was working on a project from my job.

--

Using the Shader technique:

Shader:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
public class LightShaderBatch
{
   public static final float DEFAULT_LIGHT_Z = 0.084f;
   public static final float AMBIENT_INTENSITY = 0.42f;
   public static final float LIGHT_INTENSITY = 0.9f;
   
   public static final Vector3 LIGHT_POS = new Vector3(0,0,DEFAULT_LIGHT_Z);
   
   //Light RGB and intensity (alpha)
   //public static final Vector3 LIGHT_COLOR = new Vector3(1f, 1f, 1f);
   public static final Vector3 LIGHT_COLOR = new Vector3(0.5168301f, 0.6015233f, 0.78029454f);
 
   //Ambient RGB and intensity (alpha)
   public static final Vector3 AMBIENT_COLOR = new Vector3(0.9f, 0.9f, 0.9f);
 
   //Attenuation coefficients for light falloff
   public static final Vector3 FALLOFF = new Vector3(0.4f, 0.5f, 0.2f);
   
   
   public static final String VERT =  
         "attribute vec4 "+ShaderProgram.POSITION_ATTRIBUTE+";\n" +
         "attribute vec4 "+ShaderProgram.COLOR_ATTRIBUTE+";\n" +
         "attribute vec2 "+ShaderProgram.TEXCOORD_ATTRIBUTE+"0;\n" +
         
         "uniform mat4 u_projTrans;\n" +
         " \n" +
         "varying vec4 vColor;\n" +
         "varying vec2 vTexCoord;\n" +
         
         "void main() {\n" +  
         "   vColor = "+ShaderProgram.COLOR_ATTRIBUTE+";\n" +
         "   vTexCoord = "+ShaderProgram.TEXCOORD_ATTRIBUTE+"0;\n" +
         "   gl_Position =  u_projTrans * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" +
         "}";
   
   public static final String FRAG =
         //GL ES specific stuff
           "#ifdef GL_ES\n" //
         + "#define LOWP lowp\n" //
         + "precision mediump float;\n" //
         + "#else\n" //
         + "#define LOWP \n" //
         + "#endif\n" + //
         "//attributes from vertex shader\n" +
         "varying LOWP vec4 vColor;\n" +
         "varying vec2 vTexCoord;\n" +
         "\n" +
         "//our texture samplers\n" +
         "uniform sampler2D u_texture;   //diffuse map\n" +
         "uniform sampler2D u_texture1;   //diffuse map\n" +
         "uniform sampler2D u_normals;   //normal map\n" +
         "\n" +
         "//values used for shading algorithm...\n" +
         "uniform vec2 Resolution;         //resolution of screen\n" +
         "uniform vec3 LightPos;           //light position, normalized\n" +
         "uniform LOWP vec4 LightColor;    //light RGBA -- alpha is intensity\n" +
         "uniform LOWP vec4 AmbientColor;  //ambient RGBA -- alpha is intensity \n" +
         "uniform vec3 Falloff;            //attenuation coefficients\n" +
         "\n" +
         "void main() {\n" +
         "   //RGBA of our diffuse color\n" +
         "   vec4 DiffuseColor = texture2D(u_texture, vTexCoord);\n" +
         "   \n" +
         "   //RGB of our normal map\n" +
         "   vec3 NormalMap = texture2D(u_normals, vTexCoord).rgb;\n" +
         "   \n" +
         "   //The delta position of light\n" +
         "   vec3 LightDir = vec3(LightPos.xy - (gl_FragCoord.xy / Resolution.xy), LightPos.z);\n" +
         "   \n" +
         "   //Correct for aspect ratio\n" +
         "   LightDir.x *= Resolution.x / Resolution.y;\n" +
         "   \n" +
         "   //Determine distance (used for attenuation) BEFORE we normalize our LightDir\n" +
         "   float D = length(LightDir);\n" +
         "   \n" +
         "   //normalize our vectors\n" +
         "   vec3 N = normalize(NormalMap * 2.0 - 1.0);\n" +
         "   vec3 L = normalize(LightDir);\n" +
         "   \n" +
         "   //Pre-multiply light color with intensity\n" +
         "   //Then perform \"N dot L\" to determine our diffuse term\n" +
         "   vec3 Diffuse = (LightColor.rgb * LightColor.a) * max(dot(N, L), 0.0);\n" +
         "\n" +
         "   //pre-multiply ambient color with intensity\n" +
         "   vec3 Ambient = AmbientColor.rgb * AmbientColor.a;\n" +
         "   \n" +
         "   //calculate attenuation\n" +
         "   float Attenuation = 1.0 / ( Falloff.x + (Falloff.y*D) + (Falloff.z*D*D) );\n" +
         "   \n" +
         "   //the calculation which brings it all together\n" +
         "   vec3 Intensity = Ambient + Diffuse * Attenuation;\n" +
         "   vec3 FinalColor = DiffuseColor.rgb * Intensity;\n" +
         "   gl_FragColor = vColor * vec4(FinalColor, DiffuseColor.a);\n" +
         "}";
}


Initialize:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
   public void initializeShader()
   {
      ShaderProgram.pedantic = false;
      shader = new ShaderProgram(LightShaderBatch.VERT, LightShaderBatch.FRAG);
      if (!shader.isCompiled())
         throw new GdxRuntimeException("Could not compile shader: "+shader.getLog());
      if (shader.getLog().length()!=0)
         System.out.println(shader.getLog());
     
      shader.begin();
 
      shader.setUniformi("u_normals", 1);
      shader.setUniformf("LightColor", LightShaderBatch.LIGHT_COLOR.x, LightShaderBatch.LIGHT_COLOR.y, LightShaderBatch.LIGHT_COLOR.z, LightShaderBatch.LIGHT_INTENSITY);
      shader.setUniformf("AmbientColor", LightShaderBatch.AMBIENT_COLOR.x, LightShaderBatch.AMBIENT_COLOR.y, LightShaderBatch.AMBIENT_COLOR.z, LightShaderBatch.AMBIENT_INTENSITY);
      shader.setUniformf("Falloff", LightShaderBatch.FALLOFF);
     
      Texture a = new Texture("data/images/maps/pixel_test_shader.png");
      Texture b = new Texture("data/images/maps/pixel_test.png");
      a.bind(1);
      b.bind(0);
     
      shader.end();
      game.batch = new SpriteBatch(1000, shader);
      game.batch.setProjectionMatrix(camera.combined);
     
      Gdx.input.setInputProcessor(new InputAdapter() {
         public boolean scrolled(int delta) {
            LightShaderBatch.LIGHT_POS.z = Math.max(0f, LightShaderBatch.LIGHT_POS.z - (delta * 0.005f));
            System.out.println("New light Z: "+LightShaderBatch.LIGHT_POS.z);

            //camera.zoom = Math.max(0f, camera.zoom - (delta * 0.05f));
            return true;
         }
      });
   }


Logic:
1  
2  
3  
4  
5  
      LightShaderBatch.LIGHT_POS.set(
            lightPos.x/viewport.getWorldWidth(),
            lightPos.y/viewport.getWorldHeight(),
            LightShaderBatch.LIGHT_POS.z);
//viewport.getWorldWidth/Height is to set the correct position padding.


Draw:
1  
shader.setUniformf("LightPos", LightShaderBatch.LIGHT_POS);



------

Using the Mask technique:

Initialize:
1  
2  
3  
4  
5  
6  
7  
8  
      //FrameBuffer
      lightSprite = new Texture(Gdx.files.internal("data/images/sheet/light.png"));
     
   if (lightBuffer!=null) lightBuffer.dispose();
      lightBuffer = new FrameBuffer(Format.RGBA8888, resW, resH, false);
      lightBuffer.getColorBufferTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
      lightBufferRegion = new TextureRegion(lightBuffer.getColorBufferTexture(), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
      lightBufferRegion.flip(false, true);


Draw:
1  
2  
3  
      drawGame();
      drawFBO();
      drawUI; //stage user interface


drawFBO:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
   public void drawFBO()
   {
      //LightBuffer
        lightBuffer.begin();
         Gdx.gl.glClearColor(0f, 0f, 0f, 1f); //bg
         Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
         game.batch.begin();
            game.batch.setBlendFunction(-1, -1);
            Gdx.gl.glBlendFuncSeparate(GL30.GL_SRC_ALPHA, GL30.GL_ONE_MINUS_SRC_ALPHA, GL30.GL_ONE, GL30.GL_ONE);
            game.batch.setColor(1f, 1f, 0f, 1f); //Light 1
            game.batch.draw(lightSprite, resW/2-radius-150, resH/2-radius, diam, diam);
            game.batch.setColor(0f, 1f, 1f, 1f); //Light 2
            game.batch.draw(lightSprite, resW/2-radius+150, resH/2-radius, diam, diam);
         game.batch.end();
      lightBuffer.end();
     
      Gdx.gl.glBlendFunc(GL30.GL_DST_COLOR, GL30.GL_ZERO);
      game.batch.begin();
         game.batch.setColor(1f, 1f, 1f, 1f); //FBO to texture.
         game.batch.draw(lightBufferRegion, 0, 0);  
      game.batch.end();
   }


---------

Notes:
- Shaders: I was using the light to follow the front of a car (car headlight).
- Mask: I'm using in pre-defined positions, light from sources (lamps). I'm using only two BIG lights in the code above only to show, but I'm testing 10+ with different sizes, colors.
- The Car example is just my old game, but I tried the same code.
- Screens:
http://s9.postimg.org/d0yr53em7/car.png
http://s18.postimg.org/lri2fxqsp/light.png

As you can see, the lights work perfectly, but I'm not confident that I'll can use them as adding more lights. The mobile version loses some frames (and I have not tested it yet using all the objects and enemies of the game at same time), maybe because I need to call batch.begin/end a lot of times for FBO?

How games can have glow/light effect on tons of bullets or on each enemy without losing performance. =S
4  Game Development / Newbie & Debugging Questions / What is the best 'simple light' effect for 2D Android Games? on: 2015-09-30 21:45:11
Hello.

My game is almost finished and I'm trying several ways to deal with light effect in my game, my focus is for Android, so I need optimization.
I don't want shadows or complex light effect, I only want a circle light with fade in the corner to position in different places (chandelier, table lamp, lamp post..)

I'm just following these tutorials:
- Shaders: https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson6
- Shader + mask: http://www.alcove-games.com/opengl-es-2-tutorials/lightmap-shader-fire-effect-glsl/
- Mask with framebuffer: http://techblog.orangepixel.net/2015/07/shine-a-light-on-it/

Testing 10 lights in my screen (and one following the character), works perfectly in desktop version, testing without vsync and FPS Lock I have something like 3500-4500FPS.
Testing the same thing in different Android devices, the game run almost smooth, when I have more than 7-8 lights in the screen and moving the character I have some 15-30FPS drop.

So, what is the best and optmized way to make simple circle light effect for 2D Android Games? I'm also curious to understand how various games on google play have so many lights at the same time without drop frames.

Note: I have a 'test project' without all my game logic (map, enemies, weapons..), so I can test more precisely.
5  Discussions / General Discussions / Re: small 120hz display? on: 2015-08-19 00:06:20
No, I think: http://www.blurbusters.com/faq/120hz-monitors/
6  Game Development / Newbie & Debugging Questions / Re: Appropriate way to show damage numbers on: 2015-08-18 00:42:25
Now I understand, instead of use .remove(i) for each "dead" entity, I just leave the "dead" entities in the first Array and remove with a single .clear(), then I swap to return all the entities to the first array again.

Thank you.
7  Game Development / Newbie & Debugging Questions / Re: Appropriate way to show damage numbers on: 2015-08-18 00:26:33
If the upward motion is of a constant speed then the sprites will be expiring in FIFO order, aka use a queue/deque:

1  
2  
3  
4  
5  
while queue.peek().shouldExpire() // y > max
    queue.pop(); // constant time

foreach sprite in queue
    draw_and_incrementY(sprite); // assorted processing


If you use an Array, then iterate in reverse to have correct removals, currently you're skipping sprites.
Also, don't removeValue, that's a linear search. Just remove the current index.
There's also the double buffer technique, iterate over array placing non-expired entries into 2nd array, then process 2nd array and clear old one, and swap.
Hello,

Thank you so much, the first and second tip solved my "ghost" issue, I was skipping sprites.

I'm trying to understand the "double buffer technique", so I create a variable to store a conditional value to know when I can swap arrays. Pseudo-code below.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
//Max
int maxArraySize = 10;


//-------


//When HIT
array1.add(new Damage(damage, x, y))


//-------


//Swap 1 --> 2
if (array1.size > maxArraySize)
{
   changeToArray2(array1);
}

//Draw
if (array1.size > 0)
{
   n = array1.size;
   for(int i=n-1; i>-1; i--)
   {
      Damage damage = Array1.get(i);
      //Draw and Increment y code...
      if (damage.y > damage.max)
         array1.removeIndex(i);
   }
}
if (array2.size > 0)
{
   n = array2.size;
   for(int i=n-1; i>-1; i--)
   {
      Damage damage = array2.get(i);
      //Draw and Increment y code...
      if (damage.y > damage.max)
         array2.removeIndex(i);
   }
}


//--------


//Methods
public void changeToArray2(Array<Damage> array)
{
   array2 = array;
   array1.clear();
}
8  Game Development / Newbie & Debugging Questions / [SOLVED] Appropriate way to show damage numbers on: 2015-08-17 22:23:58
Hello.

In my game I have bullets, when the bullets hits some enemies I want the show the damage on top of the enemy.

I created a logic but I don't know if it is the best choice, since sometimes I have a lot of bullets and damage in the screen.

- I'm Using libGDX, target is mobile.
- Bullet: I create bullets using Pool and Poolable.
- When the bullet hits the enemy, the enemy's HP is decreased and I add the current position and the damage received to an Array<DamageAnimation>.
- In draw() method I just draw the numbers and increase the Y position for some motion and if the Y position is bigger than the start position + 30, I remove from the list.

Everything is working fine, but what is the best way to deal with this values (position and damage) for each damage, since I have a lot of damage created everytime? I'm going to use Pool and Poolable again to re-use objs as I did with Bullets, but I'm here first to know if I'm doing right.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
public class DamageAnimation
{
   private int damage;
   private int x;
   private int y;
   private int max;
   
   public DamageAnimation(int damage, int x, int y)
   {
      this.damage = damage;
      this.x = x;
      this.y = y;
      max = y+30;
   }
   
   public int getX()
   {
      return x;
   }
   
   public int getY()
   {
      return y++;
   }
   
   public int getDamage()
   {
      return damage;
   }
   
   public int getMax()
   {
      return max;
   }
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
n = listDamage.size;
for (int i=0; i<n; i++)
{
   DamageAnimation damageDraw = listDamage.get(i);
   fontTest.draw(batch, String.valueOf(damageDraw.getDamage()), damageDraw.getX(),
         damageDraw.getY());
   if (damageDraw.getY() > damageDraw.getMax())
      listDamage.removeValue(damageDraw, true);
}
9  Game Development / Game Play & Game Design / Re: Article on pay to win games in Japan on: 2015-08-17 14:02:13
Puzzle & Dragons is a game blocked in several countries and still can make 1.3b$/year. Good job.
10  Discussions / General Discussions / Re: Windows 10 on: 2015-07-30 04:05:20
I install win10 today and just change all the effects, visuals, configs to my win7 setup.

Waiting for the DirectX12 now.
11  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LibGDX Resizing bug? on: 2015-07-23 12:20:27
Try viewport width and height:
1  
2  
viewport.getWorldWidth();
viewport.getWorldHeight();


Are you updating the viewport in your resize()?
1  
2  
3  
viewport.update(width, height);
..
stage.getViewport().update(width, height);
12  Discussions / General Discussions / Re: Resizing a picture but still keeping it look pixelated? on: 2015-06-25 20:03:38
There is a trick in Photoshop (sometimes it doesn't work).

- Alt Ctrl I.
- Change the last box to:Nearest Neighbor.

Here is the same image with 500x500:


http://s27.postimg.org/vyf8lipzn/asdasd.png
13  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Text Input listener. on: 2015-06-24 01:55:52
What do you want to do when the player hit "cancel" ?

In games, usually they just add an unknown name (if the player hits cancel unconsciously, he don't lose the score).

1  
2  
3  
4  
@Override
   public void canceled() {
      input = "Unknown Name"; //Or "Unknown Player"
   }
14  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Text Input listener. on: 2015-06-23 18:35:22
This is my returnText() in my Text input listener

   
1  
2  
3  
public String returnText(){
      return input;
   }


I'm also now trying to organize my High score names so that they drop down with their points too. Current problem is that if I get a 1st place high score and write my name, then get a 2nd place high score, the 1st place name still drops down to the 2nd place leaving the 1st place without a name. Sorry if I frankensteined your code, I'm going full on rage mode on it (plus im stupid).
No problem, I forgot about the other Highscore names xD.
By the way, in your Override input() method in your myTextInputListener you are setting input = text, right?

You need to check if(listener.returnText() != null), your input will only receive the string value after you hit "Okay", before that it always returns null. So, the screen will restart ONLY after you press "okay" button in dialog. Your current code is saving null in your scorePreferences.

I tested this and is working, you can write your name and after you click on "OK" button, the screen is restarted (now with your changing name code).
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
else if (!gameProcessor.player.isAlive() && isScoreSaved) //if score was saved
         {
          if(listener.returnText() != null)
          {
            if (scorePosition == 1){
                 HighScoreName3 = HighScoreName2;
                 scorePreferences.putString("name3", HighScoreName3);
                 HighScoreName2 = HighScoreName1;
                 scorePreferences.putString("name2", HighScoreName2);
                 HighScoreName1 = listener.returnText();
                 scorePreferences.putString("name1", HighScoreName1);
               }
             if (scorePosition == 2){
                 HighScoreName3 = HighScoreName2;
                 scorePreferences.putString("name3", HighScoreName3);
                 HighScoreName2 = listener.returnText();
                 scorePreferences.putString("name2", HighScoreName2);
               }
              if (scorePosition == 3){
              HighScoreName3 = listener.returnText();
                 scorePreferences.putString("name3", HighScoreName3);
               }
            scorePreferences.flush();    
            loopMusic.stop();  
            gameCore.setScreen(this);
         }
         }


BTW, This prints "null" in console before you click on "ok": System.out.println(listener.returnText());
15  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Text Input listener. on: 2015-06-23 17:56:53
There is still on thing that is bothering me though, the game is still restarting before asking for the input.
We have only two "setScreen".

The only way the game can change the screen before the input is here:
1  
2  
3  
4  
5  
      else //No highscore
      {
         loopMusic.stop();
         gameCore.setScreen(this);
      }

This only happens if the gameProcessor.asteroidsDestroyed <= HighScore3.

The second way, only executes if isScoreSaved == true AND if listener.returnText() != null.

Can you show your listener.returnText()?

Edit-
I tested here and is working (desktop version).
16  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Text Input listener. on: 2015-06-23 17:38:55
Quick question though, how does this work??? I thought you needed bracket for if statements
If you have only one instruction inside of if statement (works with other statements), you don't need to use brackets.  Cheesy

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
//One instruction
if (x > 0)
   x = 0;
else
   x = 1;
   
//Two or more instructions
if (x > 0)
{
   x = 0;
   System.out.println(x);
}
else
{
   x = 1;
   System.out.println(x);
}
17  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Text Input listener. on: 2015-06-23 16:24:20
This code is in your update() loop?

Because you need to set the scorePreferences and change the HighScore1, 2, 3 only once.
If "asteroidsDestroyed > HighScore1", your HighScore2 will receive the old HighScore1 value, so in the next loop the "asteroidsDestroyed > HighScore2" will return true and will create a listener again ("When I now reach the the top score all 3 score inputs get executed").
And the screen is restarted because after doing this, the code enter in the last Else. I think you can solve this with only one boolean variable to allow your save state to be executed once.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
//Global vars
private boolean isScoreSaved = false; //not saved
private int scorePosition = 0; //Only to know which Highscore was saved
private MyTextListener listener = new MyTextListener();


....................


   if(!gameProcessor.player.isAlive() && !isScoreSaved) //only if score not saved
   {
      if(gameProcessor.asteroidsDestroyed > HighScore1)
      {
         HighScore3 = HighScore2;
         scorePreferences.putInteger("score3", HighScore3);
         HighScore2 = HighScore1;
         scorePreferences.putInteger("score2", HighScore2);
         HighScore1 = gameProcessor.asteroidsDestroyed;
         scorePreferences.putInteger("score1", HighScore1);
         Gdx.input.getTextInput(listener , "New High Score!", "Input your name", "Your name");
         
         isScoreSaved = true;
         scorePosition = 1;
      }
     
      else if(gameProcessor.asteroidsDestroyed > HighScore2)
      {
         HighScore3 = HighScore2;
         scorePreferences.putInteger("score3", HighScore3);
         HighScore2 = gameProcessor.asteroidsDestroyed;
         scorePreferences.putInteger("score2", HighScore2);
         Gdx.input.getTextInput(listener, "New High Score!", "Input your name", "Your name");
         
         isScoreSaved = true;
         scorePosition = 2;
      }
         
      else if(gameProcessor.asteroidsDestroyed > HighScore3)
      {
         HighScore3 = gameProcessor.asteroidsDestroyed;
         scorePreferences.putInteger("score3", HighScore3);
         Gdx.input.getTextInput(listener, "New High Score!", "Input your name", "Your name");
         
         isScoreSaved = true;
         scorePosition = 3;
      }
         
      else //No highscore
      {
         loopMusic.stop();
         gameCore.setScreen(this);
      }
   }
   else if (!gameProcessor.player.isAlive() && isScoreSaved) //if score was saved
   {
      if(listener.returnText() != null)
      {
         if (scorePosition == 1)
            scorePreferences.putString("name1", listener.returnText());
         else if (scorePosition == 2)
            scorePreferences.putString("name2", listener.returnText());
         else if (scorePosition == 3)
            scorePreferences.putString("name3", listener.returnText());
           
         loopMusic.stop();
         scorePreferences.flush();
         gameCore.setScreen(this);
      }
   }
18  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Text Input listener. on: 2015-06-23 14:25:55
       So I made a little 3 rank high score system out of pure messines and that is working correctly for the most part. The part that I cannot figure out is how in the heck to get input from the android user.

Here is my full code sorry for the mess (It's 4:26 am) and I've been working on trying to fix this for the past few hours.
Ignore most of the dang nab nonsense, especially if its nonsense. It's just me trying to figure out how in the heck to get text input.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
   private String newText;

   @Override
   public void input(String text) {
      System.out.println(text);
      newText = text;
   }

   @Override
   public void canceled() {
      System.out.println("Canceled");
   }
   
   public String getText(){
      return newText;
   }

The input method is called after you press "okay".
The canceled is called after you cancel the dialog ("cancel", quit button, escape).

1  
2  
3  
4  
5  
6  
7  
8  
9  
            Gdx.input.getTextInput(listener, "New High Score!", "Input your name", "Your name");
            if (listener.getText() != null)
            {
               HighScoreName2 = listener.getText();
               System.out.println(HighScoreName2);
               ...
               ..
               .
            }


Or you can use TextField (txtField.getText()): http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextField.html
19  Games Center / WIP games, tools & toy projects / Re: [Android] Asteroid Encounter on: 2015-06-23 02:45:03
Working properly here, 480x800.
 Cheesy
20  Games Center / WIP games, tools & toy projects / Re: Brutal Fighters - 2D Competitive Action Game on: 2015-06-21 00:36:23
It looks really cool, I think you're using the assets from Little Fighter 2, right?
21  Discussions / General Discussions / Re: Need to get TAB key bind to Word Completion and have it insert TAB character. on: 2015-06-19 18:19:15
I don't know if this is the default key or I have customized, Ctrl + Space.
22  Discussions / Miscellaneous Topics / Re: What IDE colour theme do you use? on: 2015-06-18 14:30:55
Dark Gray background with flat colors: https://web3canvas.com/wp-content/uploads/2013/03/color-palettes-swatches-720x400.jpg

Few years ago I read an article about color tones that don't harm the vision, if I find I'll post here, It is very useful.
23  Game Development / Newbie & Debugging Questions / Re: Issue with sprite rotation distortion and need advice on speed of rotation on: 2015-06-18 02:53:40
To solve the "distortion" you can apply a filter to the texture, but you will lose the "pixel" style art.

1  
txt.setFilter(TextureFilter.Linear, TextureFilter.Linear);
24  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2015-06-15 13:59:16
It would be really cool if it had a single topic for this kind of thing, creating games for fun with some competitiveness for 3-6-12 months (probably without awards), only for members from this forum.
25  Games Center / Showcase / Re: Izalys World (Java 2D run and jump game) on: 2015-06-13 19:34:32
Great game!

The game is running properly for me. The last stage is really good, remember Donkey Kong for SNES.
26  Game Development / Game Play & Game Design / Re: Game armor/weapons: random attributes or predefined attributes? on: 2015-06-12 00:16:00
Random attributes, because every single iten can be interesting.
If you use predefinid, you need a lot of different itens.

This is one reason that I love action RPG, I have thouns~ hours of Diablo series, PoE, Torchlight I-II, Van Helsing I-II and other similiar games.

But if your game has a beginning > end very linear (without many repetitions (farms)), so I think predefinid is better.

FYI: There is an excelent game in development, a platform action RPG with predefinid itens: http://heroesofumbra.com/
27  Discussions / Miscellaneous Topics / Re: How well does this work? on: 2015-06-10 03:05:22
200-220 FPS, Chrome last version, Win7 Ultimate 64b, 8GB 1666MHz, FX-8350 Octacore, R9 270.

Mouse is moving perfectly.
28  Java Game APIs & Engines / Android / Re: Android - Assets vs res folder on: 2015-06-06 14:39:32
In the res folder you can use images with different sizes, strings (.xml), special layouts for activities, dimens.xml for dimensions and all the content is automatically selected depending on the resolution of the device.

If you have an image.png in the drawable-ldpi and an image.png in the drawable-hdpi, your app will use the image from the current device without coding anything, same with the values-small/large.

In libGDX you have only one acitivity, so you are a bit more limited with layouts or other features, but you can still use (you can't share the res folder and other specific platform features with desktop/ios/html5, I think). I can be wrong, if you are using libGDX you don't need worry about the res folder for your assets from the game, especially if you are using some types of viewport, but for some Android features you need to use (e.g: icon launcher, androidmanifest.xml, implement some code for advertising banners, leaderboards, etc..).

For the res folder strategy (select different sizes automatically), libGDX has an interesting class called ResolutionFileResolver:
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/resolvers/ResolutionFileResolver.html
29  Games Center / WIP games, tools & toy projects / Re: RGB (Red Green Blue) on: 2015-06-02 14:46:33
Tried it (OS X). For me, the green squares are moving repeatedly right to left (wrapping at the left edge), and not back and forth. Also, they're moving in noticeably discrete steps (looks like about 5 frames per second) rather than smoothly.

Does that sound right? Just wondering if maybe I'm seeing some bugs on my system.

Yeah, that is all supposed to be happening.
Very low FPS here, win7 64x, but the game is running properly (I realized that sometimes I do not even die in collision with green squares).

Why should it low FPS happen? it is on purpose?
30  Discussions / General Discussions / Re: Programmer jokes on: 2015-05-30 02:33:32
I don't know if this works in your language.

In my language, "make a program" has the same meaning of "what prostitutes do".
So, we usually call each other like "program guys".

Here a picture of us searching a java/c++ job.

Pages: [1] 2 3 4
 
Riven (847 views)
2019-09-04 15:33:17

hadezbladez (5795 views)
2018-11-16 13:46:03

hadezbladez (2603 views)
2018-11-16 13:41:33

hadezbladez (6211 views)
2018-11-16 13:35:35

hadezbladez (1499 views)
2018-11-16 13:32:03

EgonOlsen (4734 views)
2018-06-10 19:43:48

EgonOlsen (5793 views)
2018-06-10 19:43:44

EgonOlsen (3276 views)
2018-06-10 19:43:20

DesertCoockie (4175 views)
2018-05-13 18:23:11

nelsongames (5501 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
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!