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 (293)
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  Java Game APIs & Engines / Engines, Libraries and Tools / Re: libGDX Scene2D.ui ScrollPane doesn't move on: 2013-04-05 09:27:23
thx stage.act() was missing  Grin
2  Java Game APIs & Engines / Engines, Libraries and Tools / libgdx mipmap render-problems [solved] on: 2013-03-27 01:59:57
Hi, because it seems that I have to write it on my own: http://code.google.com/p/libgdx/issues/detail?id=1257&thanks=1257&ts=1360713176
I would like to know, if the error (lines between tiles and the color of the ray):
could be caused by the missing of the edge-padding.
In addition I have now clue how to add this/write that pull request.

atlas-code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
PixmapPacker packer = new PixmapPacker(2048, 2048, Format.RGBA8888, 5,
            true);
      Pixmap pixmap;
      for (int i = 0; i < levelTextures.length; i++) {
         pixmap = new Pixmap(Gdx.files.external(levelTextures[i]));
         packer.pack(levelTextures[i], pixmap);
      }
      RessourceManager.atlas = packer.generateTextureAtlas(
            TextureFilter.MipMapLinearNearest, TextureFilter.Nearest, true);


for rendering I am using spritebatch + sprites (sprite(Textureregion from the atlas)).

edit:
if I don't use mipmaps:
1  
2  
RessourceManager.atlas = packer.generateTextureAtlas(
            TextureFilter.Nearest, TextureFilter.Nearest, false);

the error doesn't appear, but I would like to use mipmaps -> how to fix it?

edit2:
thx to ocirne Smiley

changed:
1  
2  
3  
4  
5  
new PixmapPacker(2048, 2048, Format.RGBA8888,0,
            false);

packer.generateTextureAtlas(
            TextureFilter.Nearest, TextureFilter.Nearest, true);


best reg.
3  Java Game APIs & Engines / OpenGL Development / Re: libgdx - TileMap-rendering- Huge performance problems on: 2013-01-23 00:16:41
I am using a mesh with indices + atlas, don't bind every single texture, for creating the atlas, I use the pixmappacker.
-> render 400 tiles with 56 fps, 25.000 at 12 fps, it's worth using it.
If you are using a mesh, you have to think of the length of the short[] of the indices -> create chunks.
My tilemap (psydo-code):
world.class
Chunk[][] tileMap;

Chunk.cass
int[][] chunkMap;

the spritebatcher isn't that bad, but normally I prefere geometry mesh.

best regards
4  Java Game APIs & Engines / OpenGL Development / Re: (OpenGL or own)Matrix functions, Render a Mesh many times (Geometry Instancing?) on: 2013-01-23 00:09:06
1. After I did every tut I could find, I just started programming on my own.
One huge and well written blog: http://fgiesen.wordpress.com/2011/07/01/a-trip-through-the-graphics-pipeline-2011-part-1/

3.I don't know if it's the most effective way, but for rendering my tilemap, I collect all the vertices and texture-coords (from the texture-atlas, think of caching it, because the find("name") is quite slow) in a huge float[], in addition I add the indices. I think, that Triangles are rendered much faster.
You should call the draw() and bind() method as little as possible.
One problem about "geometric-mesh-rendering" is, that you have to thing of the size of the indices-array, it's a short[]. Therefore I create for each chunk a own mesh and render it. I pass 18 mb per second, but that's no problem, if you think for example about smartphones, the cpu + gpu are on the same chip -> you don't really have to care about it bottleneck.

One great lib is libgdx, it has a lot of great features and offers you full opengl-"action".
best regards
5  Game Development / Newbie & Debugging Questions / Re: Java - Smooth tiles movement on: 2013-01-22 23:49:34
A great gameloop tut: http://www.java-gaming.org/topics/game-loops/24220/view

That's maybe a little bit offtopic, but you could have a look at libgdx. It offers you great features. I would prefere it to java2d, because opengl is fun, if you have time to learn it.
If you just started programming, you might wanna stick a little bit to java2d but later on libgdx would be a great opportunity.
best regards
6  Java Game APIs & Engines / OpenGL Development / libgdx - TileMap-rendering- Huge performance problems on: 2013-01-13 10:18:33
Hi, I am trying to render my tilemap with meshes + shader + textureAtlas:
My problem:
if I got 60x60 Tiles -> 60 fps.
if I use a map of 100x100 Tiles -> 12 fps.

edit:
Thx to kalle__h from the irc channel  Grin
I have to batch the vertices.

best regards
7  Games Center / Showcase / Re: Jackal on: 2013-01-08 21:51:30
yes but that doesn't work during the boss-wave, you can't drive on the bottom because the enemies sometimes leave your screen on the bottom -> get shot. In addition I died because a random tank spawn out of my viewport and moved up into my field of view -> collision.

maybe you could add a "attach machine-gun to velocity-direction button"
best regards
8  Games Center / Showcase / Re: MAGNET on: 2013-01-08 21:36:47
Is there already a tut?
I don't wanna spend my time trying how your game might work.
9  Games Center / Showcase / Re: Jackal on: 2013-01-08 21:29:12
I like it, but I don't get how to control the "normal" shot, sometimes it works shooting in another direction but most of the time it just shoot north.
10  Game Development / Newbie & Debugging Questions / Re: Specify What To Paint On? (Java2D) on: 2013-01-07 22:32:28
In got several Panels:
MainPanel (@gamestart),
GamePanel,
option-panel,
loading-panel,
singleplayerpanel,
multiplayerpanel,
debugger-panel,
etc. I don't like to switch components off and on, I pefere creating new panels, if it's worth it Smiley
best regards
11  Java Game APIs & Engines / OpenGL Development / Re: Questions about Shaders and 2D sprites on: 2013-01-06 13:05:37
Best tuts I used to learn es 2.0:

http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/                    //A lot of great tuts

http://www.youtube.com/watch?v=q3turHmOWq4

https://github.com/mattdesl/lwjgl-basics/wiki/

http://www.opengl.org/archives/resources/faq/technical/transparency.htm

http://meatcat.info/wordpress/?p=24                                                                //I really like the idea of the Helper.class


best regards
12  Java Game APIs & Engines / OpenGL Development / Re: libdgx - Mesh -> Matrix math curious result on: 2013-01-04 03:14:16
Got the mistake, thx to bach in the libgdx irc.
I will edit my post, as soon as I wake up.
best regards and good night  Grin
13  Java Game APIs & Engines / OpenGL Development / Re: libdgx - Mesh -> Matrix math curious result on: 2013-01-04 01:49:38
thx, but one of these is an identity matrix so it shouldn't have any effect.
14  Java Game APIs & Engines / OpenGL Development / Re: libdgx - Mesh -> Matrix math curious result on: 2013-01-04 01:30:17
1  
gl_Position = uModelMatrix*vec4(aVertex,0,1);

don't work either, it would be strange because the order souldn't have any effect on it.
15  Java Game APIs & Engines / OpenGL Development / [Solved]libdgx - Mesh -> Matrix math curious result on: 2013-01-04 01:18:21
Hi, after I am now able to create fragshaders, they don't even look that bad, thx for help Smiley

But now I have been wondering about the vertexshader for about 13 hours  Roll Eyes
I just don't get why vec4(aVertex,0,1)* uModelMatrix != vec4(aVertex,0,1)
In my opinion uModelMatrix is an identity matrix so it should work.
I expected a red field, the mesh coords are set weird because I just would like to see a red pixel.

What I get:
Nothing, absolutely nothing is rendered  Undecided

There's the code, you could compile and test it yourself if you want Smiley
+ downloadlink if you don't wanna grab the libs yourself: http://www.file-upload.net/download-7008284/ErrorShader.rar.html
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  
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Matrix4;

public class ErrorShader implements ApplicationListener {
    MeshHelper meshHelper;

    public static void main(String[] args) {
      LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
      cfg.title = "Error";
      cfg.useGL20 = true;
      cfg.width = 500;
      cfg.height = 500;
      cfg.resizable = false;
      new LwjglApplication(new ErrorShader(), cfg);
   }
   
   
    @Override
    public void create() {
        meshHelper = new MeshHelper();
        meshHelper.createMesh(new float[] { -100.0f, -100.0f,
                230.0f, 100.0f,
                100f, 156.0f });
        }
   
   

    @Override
    public void resize(int width, int height) {
    }

    @Override
    public void render() {
        Gdx.graphics.getGL20().glClearColor(0.2f, 0.2f, 0.2f, 1);
        Gdx.graphics.getGL20().glClear(GL10.GL_COLOR_BUFFER_BIT);
        Gdx.graphics.getGL20().glEnable(GL20.GL_BLEND);
        //Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
       meshHelper.drawMesh();
    }

    @Override
    public void pause() {
    }

    @Override
    public void resume() {
    }

    @Override
    public void dispose() {
        meshHelper.dispose();
    }
}

class MeshHelper {
    private Mesh mesh;
    private ShaderProgram redShader;
   
    private OrthographicCamera cam;
    private Matrix4 modelMatrix;

    public MeshHelper() {
        createShader();
        modelMatrix = new Matrix4();
        cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
for(int i =0; i<  modelMatrix.getValues().length; i++){
           System.out.println("values "+ i+": " +  modelMatrix.getValues()[i]);
        }
    }

    public void createMesh(float[] vertices) {
       //modelMatrix.translate(translation)
      //modelMatrix.rotate(rotation)
      mesh = new Mesh(true, vertices.length, 0,
               new VertexAttribute(Usage.Position, 2, "aVertex"));
        mesh.setVertices(vertices);
    }

    public void drawMesh() {
        if (mesh == null)
            throw new IllegalStateException("drawMesh called before a mesh has been created.");
       
      //modelMatrix.translate(translation)
    // modelMatrix.rotate(250f,250f,0f, 0.5f);
     //  redShader.setUniformMatrix("uViewProjMatrix", cam.combined);
//redShader.setUniformMatrix("uModelMatrix", modelMatrix); //Error call it inside glbegin/end
       redShader.begin();
redShader.setUniformMatrix("uModelMatrix", modelMatrix);
        mesh.render(redShader, GL20.GL_TRIANGLES);
        redShader.end();
    }

    private void createShader() {
       String vertexShader =
               "attribute vec2 aVertex;       \n"
             + "uniform mat4 uViewProjMatrix;       \n"
             + "uniform mat4 uModelMatrix;       \n"
                + "void main()                   \n"
                + "{                             \n"
               // + "  gl_Position = vec4(aVertex,0.0,1.0) * uModelMatrix* uViewProjMatrix;  \n"
               + "  gl_Position = vec4(aVertex,0,1)* uModelMatrix; \n"// * uViewProjMatrix;
               + "}                             \n";          
       
        String fragmentREDShader =
                "#ifdef GL_ES\n" //
               + "#define LOWP lowp\n" //
               + "precision mediump float;\n" //
               + "#else\n" //
               + "#define LOWP \n" //
               + "#endif\n" + //
               "\n" +
                "void main() {\n" +
                "   gl_FragColor = vec4(1.0,0.0,0.0, 1.0);\n" +
                "}";
        redShader = new ShaderProgram(vertexShader, fragmentREDShader);
        if (redShader.isCompiled() == false)
            throw new IllegalStateException(redShader.getLog());
    }
    public void dispose() {
        mesh.dispose();
        redShader.dispose();
    }
}


thx for help,
best regards
16  Java Game APIs & Engines / OpenGL Development / Re: libdgx - Mesh Shader Blending Errors on: 2013-01-03 10:06:51
thx, got it  Smiley
best regards
17  Java Game APIs & Engines / OpenGL Development / libdgx - Mesh Shader Blending Errors on: 2013-01-02 23:37:06
Hi, I just don't get why the blue triangle is rendered, I think that Blend isn't enabled but I don't know what I could do to fix it.
You can just compile and test it on your own if you want to, the code is "working", the shaders not  Roll Eyes
What I got:

-a blue triangle
What I expected:
-a red triangle, because the opacity from the blue one is 0
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  
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;

public class ErrorShader implements ApplicationListener {
    MeshHelper meshHelper;

    public static void main(String[] args) {
      LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
      cfg.title = "Error";
      cfg.useGL20 = true;
      cfg.width = 500;
      cfg.height = 500;
      cfg.resizable = false;
      new LwjglApplication(new ErrorShader(), cfg);
   }
   
   
    @Override
    public void create() {
        meshHelper = new MeshHelper();
        meshHelper.createMesh(new float[] { -1.0f, -1.0f, Color.toFloatBits(0, 0, 255, 0),
            0.0f, 1f, Color.toFloatBits(0, 0, 255, 0),
            1f, -1.0f, Color.toFloatBits(0, 0, 255, 0) });
    }
   
   

    @Override
    public void resize(int width, int height) {
    }

    @Override
    public void render() {
        Gdx.graphics.getGL20().glClearColor(0.2f, 0.2f, 0.2f, 1);
        Gdx.graphics.getGL20().glClear(GL10.GL_COLOR_BUFFER_BIT);
        Gdx.graphics.getGL20().glEnable(GL20.GL_BLEND);
        Gdx.gl.glBlendFunc(GL10.GL_ONE_MINUS_SRC_ALPHA, GL10.GL_SRC_ALPHA);
        meshHelper.drawMesh();
    }

    @Override
    public void pause() {
    }

    @Override
    public void resume() {
    }

    @Override
    public void dispose() {
        meshHelper.dispose();
    }
}

class MeshHelper {
    private Mesh mesh;
    private ShaderProgram redShader;
    private ShaderProgram blueShader;

    public MeshHelper() {
        createShader();
    }

    public void createMesh(float[] vertices) {
       mesh = new Mesh(true, vertices.length, 0,
               new VertexAttribute(Usage.Position, 2, "a_position"),
               new VertexAttribute(Usage.ColorPacked, 4, "a_color"));
        mesh.setVertices(vertices);
    }

    public void drawMesh() {
        if (mesh == null)
            throw new IllegalStateException("drawMesh called before a mesh has been created.");
       
        redShader.begin();
        mesh.render(redShader, GL20.GL_TRIANGLES);
        redShader.end();
        blueShader.begin();
        mesh.render(blueShader, GL20.GL_TRIANGLES);
        blueShader.end();
    }

    private void createShader() {
       String vertexShader = "attribute vec4 a_position;    \n"
                + "attribute vec4 a_color;       \n"
                + "varying vec4 v_color;         \n"
                + "void main()                   \n"
                + "{                             \n"
                + "   v_color = a_color;         \n"
                + "   gl_Position = a_position;  \n"
                + "}                             \n";          
       

       String fragmentBLUEShader =
             //GL ES specific stuff
              "#ifdef GL_ES\n" //
            + "#define LOWP lowp\n" //
            + "precision mediump float;\n" //
            + "#else\n" //
            + "#define LOWP \n" //
            + "#endif\n" + //
            "\n" +
             "void main() {\n" +
             "   gl_FragColor = vec4(0.0,0.0,1.0, 0.0);\n" +  //Why is that rendered?
            "}";
        blueShader = new ShaderProgram(vertexShader, fragmentBLUEShader);
        if (blueShader.isCompiled() == false)
            throw new IllegalStateException(blueShader.getLog());
   
        String fragmentREDShader =
             //GL ES specific stuff
              "#ifdef GL_ES\n" //
            + "#define LOWP lowp\n" //
            + "precision mediump float;\n" //
            + "#else\n" //
            + "#define LOWP \n" //
            + "#endif\n" + //
            "\n" +
             "void main() {\n" +
             "   gl_FragColor = vec4(1,0,0,1);\n" +
             "}";
        redShader = new ShaderProgram(vertexShader, fragmentREDShader);
        if (redShader.isCompiled() == false)
            throw new IllegalStateException(redShader.getLog());
    }
    public void dispose() {
        mesh.dispose();
        blueShader.dispose();
        redShader.dispose();
    }

}


edit:
Got it, if I use
1  
Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
it works,
but I don't understand why the other one doesn't work. It would be great if someone could explain it
The text is german but the pictures are nice: http://wiki.delphigl.com/index.php/glBlendFunc#Beispiele


thx for help,
best regards
18  Game Development / Newbie & Debugging Questions / Re: Specify What To Paint On? (Java2D) on: 2013-01-02 11:25:00
Sry for code-block  Smiley
How I did it, I hope I haven't earsed to much of my code, if you have questions left, feel free to ask.
Main:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public class Main {
   
   public static String version = "V 0.1 - Alpha";
   public static int width = 1280;
   public static int height = 720;
   public static GameWindow gameWindow;
        public static boolean paused;
   
   public static void main(String[] args) throws IOException{
      gameWindow = new GameWindow("Game " + version, width, height);
   }
}

JFrame:
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  
public class GameWindow extends JFrame {
   private static final long serialVersionUID = 1308619767172296296L;
   private Dimension dim;
   private GamePanel gpanel;
   public static GameWindow gw;
   
   public GameWindow(String title, int width, int height) throws IOException {
     
      super(title);
      gw = this;
      dim = new Dimension(width, height);
           
      setMaximumSize(dim);
      setMinimumSize(dim);
      setPreferredSize(dim);
     
      gpanel = new GamePanel();
      add(gpanel);
     
      setLocationRelativeTo(null);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setResizable(false);
     
      setUndecorated(true);
      setVisible(true);
     
   }


JPanel attached on the Jframe
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
public class GamePanel extends JPanel{
public GamePanel() throws IOException {
      super();  
      this.setLayout(null);
      KeyOptionsPanel.loadKeys();

      moveThread = new MoveThread(this); //Gameloop
     start = new Thread(moveThread);
      start.start();
   }
   
   
   public void paint (Graphics g) {
      Render.map(g); //in my ressourcemanager.class is the current map, that will be rendered
  }
}


Gameloop:
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  
        public class MoveThread implements Runnable{
   private JComponent comp;
   private long duration, last = System.currentTimeMillis() - 20;
   
   public MoveThread(JComponent comp) {
      this.comp = comp;
   }
   
   @Override
   public void run() {
      while (Main.running) {
     
         duration = System.currentTimeMillis() - last;
         last = System.currentTimeMillis();
                 
         if (!Main.paused) CalculateMov.cm.run(duration); //Calculates playermov etc.
       
         comp.repaint();
         
         try {
            Thread.sleep(20);
         } catch (InterruptedException e) {
         }
      }
   }
}

I wouldn't use that gameloop anymore, that was my first one Cheesy
I would recomment that one: http://www.java-gaming.org/topics/game-loops/24220/view
If you use java2d, use the "double-buffered-renderer"
You don't have to render Tiles, that aren't shown. It's a little bit tricky but to save performance, you can create an "startTileX", "startTileY" and "stopTileX", "stopTileY".
You get the startTile[x/y] if you devide the cameraMovement by the size of one tile -> stopTile[x/y] = startTile[x/y] +[width/height] devided by size of one tile.
The "/" isn't an mathematical sign, I am just to lazy to write it for x and y Smiley
best regards
19  Game Development / Newbie & Debugging Questions / Re: Specify What To Paint On? (Java2D) on: 2013-01-02 10:53:32
I also have an [map].draw function but I did it like this:
Why does your gamepanel extend Jpanel?
pseudo-code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
GamePanel.class:
private Map map;
[...]
public void paint (Graphics g) {
      Render.map(map,g);
}

Map.class
private JComponent comp; //I wouldn't use it that way, I prefere independent mapobjects

public Map(JComponent comp) {
[...]
      this.comp = comp;
   }

render(){
[Here you could check if Jcomp has focus etc]
[set the map in the GamePanel.class (if you need to)]
comp.repaint();
}
I don't like that pseudo that much, but it works.

It should also be possible to use:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
GamePanel.class
public Graphics paint (Graphics g) {
      return g;
   }


Map.class
private JComponent comp;
public Map(JComponent comp) {
[...]
      this.comp = comp;
   }

render(){
Graphics g = comp.repaint();
[draw with g]
}



Edit:
Are you sure, that you don't want to use more .class files?

best regards
20  Games Center / Featured Games / Re: Torquing! on: 2013-01-01 14:32:19
Edited my post, sry I failed  Smiley
best regards
21  Discussions / General Discussions / Re: why are people trying to use Java2D to make games? on: 2013-01-01 13:01:02
Please use a proper 'you' instead of 'u', it's burning my eyes out right now. Take a look at TheCodingUniverse for some LWJGL tutorials.
The "you" is one of my new Year's pledges. I already watched most of the youtubetutorials, I think they are quite good explained.
-> Back to Topic,
In my opinion awt offers a lot of great stuff for java2d, especially because you can write your own components, it's highly customizable. Furthermore if you use the "double-buffered-layer-renderer" and active rendering it's fast and accurate enough for desktop-applications. If you just want to add a scroll-pane in jogl/lwjgl/libgdx it's not that easy as it would be in java2d.
best regards
22  Game Development / Newbie & Debugging Questions / timer vs polling vs thread.sleep on: 2012-12-31 18:42:26
Hi, I got another question  Grin
I got a lot of sparetime at the moment  Smiley
I've got some objects, after some time I have to execute a function (for example object.setAwake()). Would you use
1.timer
2. new thread + thread.sleep (I already read that I shouldn't use that)
3. a list with all objects and poll them

I don't need a break condition like it's already implemented in the timer.
best regards
23  Game Development / Newbie & Debugging Questions / Re: libdgx - Shaperenderer - Opacity on: 2012-12-31 18:27:44
thx for explanation Smiley
The shaperenderer is just for prealpha-test-debugging-version. In the future I am not sure if I will use spritebatches or shaders. Spritebatches are very easy to use Cheesy
I already did that tut, but I think I have to read more about shaders if I want to use them  Grin
Especially because from es 1.0 to 2.0 are some creepy changes and at the moment I often confuse the functions and wonder about the result Grin
I just started learning opengl and maybe I did to big steps so I might haven't understood everything I thought I understood  Roll Eyes
best regards
24  Game Development / Newbie & Debugging Questions / Re: libdgx - Shaperenderer - Opacity on: 2012-12-31 10:21:53
1  
2  
3  
4  
Gdx.gl.glClearColor(1, 1, 1, 1);
       Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
       Gdx.graphics.getGL10().glEnable(GL10.GL_BLEND);
            Gdx.graphics.getGL10().glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

I don't think that I am drawing sth at the moment or do I missunderstand it?
best regards

edit: Got it, although shaderrenderer uses gl10 I have to modify gl20  persecutioncomplex
Does someone know why?
25  Game Development / Newbie & Debugging Questions / Re: Thread sleeping not playing well with Java2D? on: 2012-12-31 09:43:48
Some time ago I had the same problem. Are you using passiv or activ rendering. passiv-rendering isnt appreciated for gamedev and leads to a lot of problems, especially if you are using java2d. Even if you force the immediate repaint, it's repainted after everything else is down.
best regards
26  Game Development / Newbie & Debugging Questions / libdgx - Shaperenderer - Opacity on: 2012-12-31 09:31:53
Hi, I am wondering about the Shaperenderer: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html
1  
2  
3  
4  
5  
6  
shapeRenderer.begin(ShapeType.FilledCircle);
          shapeRenderer.setColor(0, 0, 0.4f, 0.3f);
          shapeRenderer.filledCircle(100,100,20);
          shapeRenderer.setColor(1, 1, 0, 0.3f);
          shapeRenderer.filledCircle(100,100,10);
          shapeRenderer.end();


Normally I would use the spritebatch for drawing, but this time I just want to draw a circle that contains another circle with a different color. In addition the one on the bottom shouldshow through the other. I just don't get it who to enable the alpha-"function" / if you google it, it always shows articles about the spritebatcher.
I thought
1  
2  
Gdx.graphics.getGL10().glEnable(GL10.GL_BLEND);
           Gdx.graphics.getGL10().glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
would manage it, but "glEnable(GL10.GL_BLEND)" throws nullpointer..
I am new to opengl-fun and that's absolutely confusing me, I just don't get what I am doing wrong  Roll Eyes
thx for help and patience Smiley
27  Game Development / Newbie & Debugging Questions / Re: which is faster? on: 2012-12-31 09:13:29
How many sprites do you have?
I don't think, that you will recognise any "speedboost", for example there's no difference in the "running-time of one loop" of my game if I just have to check 1 or 500 collisions.
It might be worth it, if you got huge polygons and therefore a lot of verticles to check.
What you could do is creating a circle around each sprite and check before if they collide (circle vs circle collision is faster then rect vs rect), but I in my opinion that's not worth it, too.
best regards
28  Game Development / Newbie & Debugging Questions / Re: Random - Probability on: 2012-12-31 07:47:28
@Master thx, it was to late, my brain was already in bed  Grin
@ctomni231
Let me try to explain it with an example:
result should be between 10 and 100
if value is 0.01; the result probably is rather 10, 11, 12 (little results)
if value is 0.25; the result probably is rather 25, 26, 27 (bigger little results)
if value is 0.5; the result probably is rather 49, 50, 51 (medium results)
if value is 0.75; the result probably is rather 74, 75, 76 (bigger medium results)
if value is 0.99; the result probably is rather 98, 99, 100 (big results)

I would like to set the expectancy of the result with "value"

Hope it's now intelligible
best regards
29  Game Development / Newbie & Debugging Questions / Re: Best method for creating sprite sheets? on: 2012-12-31 00:52:11
If all of your other sprites are drawn I wouldn't use blender, 3D-Model-screens + drawn scenery look weird most of the time. But that's a matter of opinion/the game.
I used "paintings" because my tiles were also painted.
best regards
30  Game Development / Newbie & Debugging Questions / Random - Probability on: 2012-12-31 00:47:15
Hi, I am think about the probability of a number in a restricted area.
psydo-code:
1  
2  
3  
4  
5  
float result //in a certain range (maybe between 10 and 300 (doesn't matter)) the number that I want to produce
float value // between 0 1: It says, if the result is rather big oder little

//at the moment I using:
int x = rand.nextInt(maxX - minX + 1) + minX; //but that's completely random (yes I know that randoms aren't really random but we won't care about that)

I thought about multiplying it with another random but I don't know how I put the "value" in it, because I would like to have a linear change of the highest probability.
thx for help,

<edit name = "Wasn't able to explain it, so here we go with an example">
Let me try to explain it with an example:
result should be between 10 and 100
if value is 0.01; the result probably is rather 10, 11, 12 (little results)
if value is 0.25; the result probably is rather 25, 26, 27 (bigger little results)
if value is 0.5; the result probably is rather 49, 50, 51 (medium results)
if value is 0.75; the result probably is rather 74, 75, 76 (bigger medium results)
if value is 0.99; the result probably is rather 98, 99, 100 (big results)

I would like to set the expectancy of the result with "value"
</edit>
best regards

Pages: [1] 2 3 4
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 (84 views)
2013-05-17 21:29:12

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

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

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

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

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

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

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

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

UnluckyDevil (187 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.586 seconds with 20 queries.