Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (292)
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
1  Game Development / Newbie & Debugging Questions / Re: Tween functions? on: 2013-05-16 22:27:48
Thank You!
2  Game Development / Newbie & Debugging Questions / Re: Tween functions? on: 2013-05-16 16:52:30
OK. I will try to use Universal Tween Engine.

I tried that before. But I was not happy of that engine. No great tutorials etc.

Now... after many hours trying.. it's ok.
3  Game Development / Newbie & Debugging Questions / Re: Tween functions? on: 2013-05-16 15:10:49
I always look at the license.

I'm searching for codes that are written and all can use it in the game.

I do not know how to say this.

E.g. when somebody wants to make a website, he looks for written Layouts. And of course to the license.
And then the programmer downloads or copy & pastes that layout in the file.

And that's, what I'm searching for. Written tweens. (Why reinvent the wheel)
4  Game Development / Newbie & Debugging Questions / Re: Tween functions? on: 2013-05-16 13:12:00
@Danny02 Yes, that's correct but I wanted to speed up my programming. I mean, copy & paste and use the function.

Of course I can look at the code. But this takes time.
5  Game Development / Newbie & Debugging Questions / Re: Tween functions? on: 2013-05-16 11:36:37
Yes, I know that.

But I'm searching only for the algorithm or functions.

6  Game Development / Newbie & Debugging Questions / Re: Tween functions? on: 2013-05-16 10:21:54
LibGDX

7  Game Development / Newbie & Debugging Questions / Tween functions? on: 2013-05-16 09:28:36
Hi,

I want to make tween animations in a game.

E.g. when the player gets a coin, I want to show on the position of the coin the score
and then the score is moving up and is going transparent. (Floating score)

I know, there are tween libraries. But I'm searching only for the algorithm.
Not only for the floating score.

All the functions the are useful for games.

Another example: The text "Game over" is coming from up to the center of the screen and waiting for
3 seconds and then is moving to the bottom screen.

I can make tween animations myself. But it takes time.
8  Game Development / Newbie & Debugging Questions / Re: LibGDX - StillModel mesh - dispose? on: 2013-05-15 16:24:29
Thank you! That helped me.
9  Game Development / Newbie & Debugging Questions / LibGDX - StillModel mesh - dispose? on: 2013-05-14 09:05:55
Hi,

I have 16 Levels. In each level, I have a different 3d environment (mountains, buildings, volcano etc.).

Now When I go to Level 2, I don't need anymore the environment of Level 1.

How can I now free the memory of this meshes?
For example:
1  
2  
   StillModel mountain;   
   StillModel buildings;  
10  Game Development / Newbie & Debugging Questions / Re: LibGDX - Gradient looks weird? on: 2013-04-27 08:45:56
Thanks!
11  Game Development / Newbie & Debugging Questions / Re: LibGDX - Gradient looks weird? on: 2013-04-26 08:09:52
Yes. I added the RGBA8888 to the texture. Not working.
12  Game Development / Newbie & Debugging Questions / LibGDX - Gradient looks weird? on: 2013-04-25 17:55:03
Hi,

I added a 3D cube. On this 3D cube is a gradient texture. When I start my app,
the gradient looks like this here:

(second image)
http://stackoverflow.com/questions/13478116/android-gradient-weirdness

I added this code to my main activity. Code is not working!
1  
2  
3  
4  
5  
6  
7  
8  
9  
        AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
        cfg.useGL20 = false;

        cfg.r = 8;
        cfg.g = 8;
        cfg.b = 8;
        cfg.a = 8;

        initialize(new Game(), cfg);
13  Game Development / Newbie & Debugging Questions / Re: Time based movement / deltaTime / Event Timing ? on: 2013-04-13 13:16:55
I solved it now. Thanks to everybody.

This two lines solved my problem:
1  
2  
      float addDelta = 100*Gdx.graphics.getDeltaTime();
      speed = addDelta;


I tried that before. But without success.

Now it's working. It's unbelievable. Smiley
14  Game Development / Newbie & Debugging Questions / Re: Time based movement / deltaTime / Event Timing ? on: 2013-04-12 16:32:07
Here is an example.

In my app, there is a red box. It's moving from left to right. The app starts, when you touch the screen.
Now, I installed this on my big and small smartphone. I touch the both devices at the same time.
And now I see, that the red box on my smaller smartphone touches the right side of the screen first.

In my app, there is a ease function from Robert Penner and I added Aspect ratio.

So, first the images:
(This is my libgdx.png file)


(this is, where the red box starts)


(and this is, where the red box touches the right side)


And this is the 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  
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  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
package com.me.mygdxgame;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class MyGdxGame implements ApplicationListener {
   
    private static final int VIRTUAL_WIDTH = 800;
    private static final int VIRTUAL_HEIGHT = 480;
    private static final float ASPECT_RATIO = (float)VIRTUAL_WIDTH/(float)VIRTUAL_HEIGHT;
   
    private Rectangle viewport;
   
   private OrthographicCamera camera;
   private SpriteBatch batch;
   private Texture texture;
   private Sprite sprite;
   
   private float x = 0f;
   private float y = 0f;  
   
   private boolean start = false;
   
    private float diff = 200f;

    private float minTime = 0;
    private float maxTime = 770f;
   
    private float iEaseOut = 0;
    private float zTime = 0;
       
   @Override
   public void create() {      

      camera = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
      batch = new SpriteBatch();
     
      texture = new Texture(Gdx.files.internal("data/libgdx.png"));
      texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
     
      TextureRegion region = new TextureRegion(texture, 2, 2, 32, 32);
     
      sprite = new Sprite(region);
   }

   @Override
   public void dispose() {
      batch.dispose();
      texture.dispose();
   }

   @Override
   public void render() {      
     
      float deltaTime = Gdx.graphics.getDeltaTime();
     
      if (Gdx.input.isTouched()) {
         start = true;
      }      
     
      if (start) {

         if (iEaseOut < diff) {
            zTime = expoEaseOut(iEaseOut, minTime, maxTime, diff);

            float deltaAdd = zTime*deltaTime;            
            zTime += deltaAdd;              
           
            x = zTime;        

            iEaseOut++;      
         } else {
            start = false;
         }
         
      }
     
      System.out.println(Gdx.graphics.getDeltaTime());
     
     
      Gdx.gl.glClearColor(1, 1, 1, 1);
      Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
     
      camera.update();
     
        Gdx.gl.glViewport((int) viewport.x, (int) viewport.y, (int) viewport.width, (int) viewport.height);  
     
      batch.setProjectionMatrix(camera.combined);
      batch.begin();
      sprite.setPosition(x-VIRTUAL_WIDTH/2, y);
      sprite.draw(batch);
      batch.end();
   }
     
   public static float expoEaseOut(float t,float b , float c, float d) {
      return (t==d) ? b+c : c * (-(float)Math.pow(2, -10 * t/d) + 1) + b;  
   }

   @Override
   public void resize(int width, int height) {
       // calculate new viewport
       float aspectRatio = (float)width/(float)height;
        float scale = 1f;
        Vector2 crop = new Vector2(0f, 0f);
       
        if(aspectRatio > ASPECT_RATIO)
        {
            scale = (float)height/(float)VIRTUAL_HEIGHT;
            crop.x = (width - VIRTUAL_WIDTH*scale)/2f;
        }
        else if(aspectRatio < ASPECT_RATIO)
        {
            scale = (float)width/(float)VIRTUAL_WIDTH;
            crop.y = (height - VIRTUAL_HEIGHT*scale)/2f;
        }
        else
        {
            scale = (float)width/(float)VIRTUAL_WIDTH;
        }

        float w = (float)VIRTUAL_WIDTH*scale;
        float h = (float)VIRTUAL_HEIGHT*scale;
        viewport = new Rectangle(crop.x, crop.y, w, h);
   }

   @Override
   public void pause() {
   }

   @Override
   public void resume() {
   }
}
15  Game Development / Newbie & Debugging Questions / Re: Time based movement / deltaTime / Event Timing ? on: 2013-04-12 15:27:32
I'm not calculating deltaTime. I generated a standard LibGDX Project. I get it from LibDX.

When I output deltatime on my bigger smartphone I get this:
0.016456..., or 0.152546... etc.

On my smaller smartphone I get this:
0.011254..., or 0.102546... etc.

16  Game Development / Newbie & Debugging Questions / Time based movement / deltaTime / Event Timing ? on: 2013-04-12 09:14:39
Hi,

I'm really confused. The app is faster or slower on some devices. I had some small problems with libgdx. BUT this is the biggest problem that I've had.

First I thought I understood deltaTime. But that is not so.

Why is that so hard. I made a small program, where is a 3d cube is moving from left to right.
And then the 3d cube is moving backwards.

I've tried so many things. NOTHING WORKS.
I also added the deltaTime (test += steps*deltaTime) to the movement. Nothing helps. On my smaller smartphone the movement is faster.

I don't know what to do. On my bigger smartphone is it slower.

I have read all of this. (some things I did not understand):
http://gafferongames.com/game-physics/fix-your-timestep/

http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=1845&p=10046&hilit=step+deltatime#p10046

http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=4185&p=20139&hilit=deltaTime#p20139

Has somebody not a great solution for this. How can I do it, that the render() renders at the same speed on all devices?

I read about accumulate or something like that. Is this the answer?

Info: I'm not using box2d.

Has anybody solved this problem. It would be great, when somebody can post a working example code.

My program looks a little bit like this:
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 ObjectScreen implements Screen {
   Game game;


   public ObjectScreen (Game game) {
      this.game = game;
     
      cam = new PerspectiveCamera(45, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
      ...
   }
...

@Override
public void render (float delta) {
   update(delta);
   draw(delta);
}

public void update (float deltaTime) {
   // ...
}

public void draw (float deltaTime) {      

   GL10 gl = Gdx.graphics.getGL10();

   gl.glClearColor(0.0f, 0.0f, 0.0f, 1);

   gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
   ...
   
   // 3d Object moving
  ...
}
}



Thank You!
17  Game Development / Newbie & Debugging Questions / Re: LibGDX - deltatime? on: 2013-04-07 10:46:02
I understand deltaTime now better. Thanks.
18  Game Development / Newbie & Debugging Questions / Re: LibGDX - deltatime? on: 2013-04-06 20:45:05
Yes, I know this, but is it not possible to do this without to add the deltaTime to the movemet variable?

My project looks like this:

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  
public class ObjectScreen implements Screen {
   Game game;


   public ObjectScreen (Game game) {
      this.game = game;
     
      cam = new PerspectiveCamera(45, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
      ...
   }
...

@Override
public void render (float delta) {
   update(delta);
   draw(delta);
}

public void update (float deltaTime) {
   // ...
}

public void draw (float deltaTime) {      
   if (deltaTime > 0.1f) deltaTime = 0.1f;

   GL10 gl = Gdx.graphics.getGL10();

   gl.glClearColor(0.0f, 0.0f, 0.0f, 1);

   gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
   ...
   
   // 3d Object moving
  ...
}
}
19  Game Development / Newbie & Debugging Questions / Re: Opengl - Light looks different? on: 2013-04-06 20:29:55
Oh... OK.

I also first thought the same but then I thought, maybe I programmed it wrong.
20  Game Development / Newbie & Debugging Questions / LibGDX - deltatime? on: 2013-04-06 20:28:27
3d Object moving on my second phone is faster.

I tried this here:

1  
    if (deltaTime > 0.1f) deltaTime = 0.1f;


But this don't works.

How can I do it, that the render() has the same speed on all phones?

I thought, that LibGDX regulates the deltatime self.

21  Game Development / Newbie & Debugging Questions / Opengl - Light looks different? on: 2013-04-06 15:31:06
Hi,

I'm programming with LibGDX.

I added this code:
1  
2  
3  
4  
       float lightColor1[] = {1.0f, 1.0f, 1.0f, 1.0f}; //Color (0.5, 0.2, 0.2)
      float lightPos1[] = {-1.0f, 0.5f, 0.5f, 0.0f};
       gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_DIFFUSE, lightColor1, 0);
       gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_POSITION, lightPos1, 0);


I have two different smartphones. The Light looks different on this two smartphones. I don't know why?

On the first smartphone the light is weak and  on the second smartphone the light is bright.

EDIT:

OK. Now I programmed this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      // Create light components
     float ambientLight[] = { 1f, 1f, 1f, 1.0f };
      float diffuseLight[] = { 1f, 1f, 1f, 1.0f };
      float specularLight[] = { 1f, 1f, 1f, 1.0f };
      float position[] = { 0f,0f, 5.0f, 1.0f };

      // Assign created components to GL_LIGHT0
     gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, ambientLight, 0);
      gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, diffuseLight, 0);
      gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_SPECULAR, specularLight, 0);
      gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, position, 0);


It's now a little bit better, but on the small smartphone the texture looks brighter.
22  Game Development / Newbie & Debugging Questions / Re: LibGDX - Camera Coordinate To Screen Coordinate? on: 2013-03-29 14:49:58
I added the perspective camera like this:
1  
      camera = new PerspectiveCamera(67, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);

gluPerspective is the same, right?

OK. I try to explain. e.g.

The sprite is moving from left to right. When I now
1  
System.out.println(sprite.x+" | "+sprite.y) 

I get this e.g. x:50, y:100 or x:55, y100 or x:500, y:100 etc.
The (0,0) is left bottom!

Now I don't know how move the 3d object at this positions? This is not working:
1  
Gdx.gl10.glTranslatef(sprite.x, srite.y, -35.0f);


For e.g. When I do this,
1  
Gdx.gl10.glTranslatef(100f, 0.0f, -35.0f);

I don't see the 3d object on the screen:


23  Game Development / Newbie & Debugging Questions / LibGDX - Camera Coordinate To Screen Coordinate? on: 2013-03-29 13:52:24
Hi,

I made a sprite, that is moving on the screen. The sprite moves from left screen to the right screen.

Now, I will hide the sprite and I will add a 3d Object on the sprites position.

The problem is now: The width and height of the screen is 800x480.

And now I don't know how to move the 3d object? e.g.
1  
Gdx.gl10.glTranslatef(sprite.x, srite.y, -35.0f);


Must I now cam.project or cam.unproject this? Or what is the right keyword?


24  Game Development / Newbie & Debugging Questions / Re: LibGDX - Get TouchPoint X and Y in Perspective? on: 2013-03-27 19:25:25
Hi,

I solved it now so:
1  
2  
3  
float X = MathUtils.round(Gdx.input.getX()*(480f/1196f));

float Y = MathUtils.round(Gdx.input.getY()*(320f/720f));


If there is a better solution, then please post it.
25  Game Development / Newbie & Debugging Questions / LibGDX - Get TouchPoint X and Y in Perspective? on: 2013-03-27 17:22:52
Hi,

I add a perspective camera.

1  
    cam = new PerspectiveCamera(45, 480, 320);


When I try to get the touchpoints with

1  
    (Gdx.input.getX(), Gdx.input.getY())


I get wrong numbers. My Perspective width is 480.

When I touch with my finger the screen (rightmost), I get 1196.

This is my screen resolution of my device.

EDIT: I also get wrong numbers when I try:
 
1  
2  
3  
4  
5  
      private Vector3 touchPoint;

       cam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

       System.out.println(touchPoint.x+" | "+touchPoint.y);

    I get something like this with touchpoint.x: -6 to 0.75
26  Game Development / Newbie & Debugging Questions / Re: LibGDX - How change the standard LibGX Project to Perspective Camera? on: 2013-03-27 15:35:48
I solved it with the help of ProjectTest.java

It's an example in GDX Tests.
27  Game Development / Newbie & Debugging Questions / LibGDX - How change the standard LibGX Project to Perspective Camera? on: 2013-03-27 12:01:40
Hi,

I generated the simple LibGDX project where you see a LibGDX image.

The example is made with

1  
       private OrthographicCamera camera;


How can I change this to Perpective Camera?

I want it in Perspective Camera with the same look like in Orthographic Camera.

I will add some 3d objects on this image. Like this:
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  
         StillModel mesh;

    ... create()

          mesh =  ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/testObject.obj"));

    ... render()

          gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

          camera.update();

          batch.setProjectionMatrix(camera.combined);
          batch.begin();
          sprite.draw(batch);
          batch.end();

          gl.glEnable(GL10.GL_DEPTH_TEST);
          gl.glEnable(GL10.GL_LIGHTING);
          gl.glEnable(GL10.GL_COLOR_MATERIAL);
          gl.glEnable(GL10.GL_TEXTURE_2D);

          camera.update();
          gl.glMatrixMode(GL10.GL_PROJECTION);
          gl.glLoadIdentity();

          gl.glLoadMatrixf(cam.projection.val, 0);
          gl.glMatrixMode(GL10.GL_MODELVIEW);
          gl.glLoadMatrixf(cam.view.val, 0);

          gl.glEnable(GL10.GL_LIGHT0);
          gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0);
          gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0);

          gl.glRotatef(angleY, 0, 1, 0);
          gl.glRotatef(angleX, 1, 0, 0);
          mesh.render();
    ...


Has someone an Idea?
28  Discussions / General Discussions / Re: In-App Purchase on: 2013-03-23 17:44:57
Wow! Thanks!

About the game. I only made one level and the train movements.

Before I write the whole game I wanted to inform me what I can do.

I played Subway Surfers. Is well done.

Now I will take a pencil and a sheet of paper and make a game concept. Smiley
29  Discussions / General Discussions / Re: In-App Purchase on: 2013-03-23 16:20:39
Hi. Ok.

I played Subway Surfers. They don't only sell "Double Coins". There are more things you can buy.
30  Discussions / General Discussions / Re: In-App Purchase on: 2013-03-23 15:00:08
Thanks.  Smiley

Good examples and helpful tips.
Pages: [1] 2
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (66 views)
2013-05-17 21:29:12

alaslipknot (75 views)
2013-05-16 21:24:48

gouessej (107 views)
2013-05-16 00:53:38

gouessej (103 views)
2013-05-16 00:17:58

theagentd (114 views)
2013-05-15 15:01:13

theagentd (103 views)
2013-05-15 15:00:54

StreetDoggy (148 views)
2013-05-14 15:56:26

kutucuk (171 views)
2013-05-12 17:10:36

kutucuk (169 views)
2013-05-12 15:36:09

UnluckyDevil (178 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.463 seconds with 20 queries.