Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
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   
Pages: 1 ... 8 9 [10]
 91 
 on: 2018-05-13 17:08:48 
Started by DesertCoockie - Last post by DesertCoockie
I have implemented a HashMap in the following way:
1  
2  
HashMap<Long,ArrayList<MouseEnterListener>> map = new HashMap<>();
map.put( id,new ArrayList<MouseEnterListener>());

When trying to access the map, I get a NullPointerException:
1  
2  
for( MouseEnterListener mouseEnterListener: map.get( id ) ) // Exception here
   mouseEnterListener.invoke( entered );

What I've debugged sofar:
 - "id" is correct and the HashMap contains an entry for this id
 - the size of the "map" is 1, while the ArrayList is empty

What's going wrong here?

 92 
 on: 2018-05-13 12:56:53 
Started by ohyeahx10 - Last post by ohyeahx10
I'm rendering a grid of isometric tiles with each tile being 64x32 in size. Some of the structures I'm rendering span over multiple tiles graphically and I'm wondering how these would be stored in a data structure, or even which data structure I should use. Currently I've got a 2D array where all tiles are floor-level, although I'm now trying to render a building and it's presented a few questions:
1. Are larger structures stored on multiple or single tiles?
2. If they're stored on single tiles how would collision detection work, as you could collide with a tile that's not represented in the tile data for the collided tile?
3. If they're stored on multiple tiles and each tile just renders it's piece of the structure, how would you render the upper parts of the structure (e.g. the upper floors of a building)?
If every floor also has to be represented in the tile data, wouldn't this make a really tall impassible column on your level, when in reality you should be able to walk behind the building once the character is above the base level?

Any guidance would be helpful. Smiley Thanks

 93 
 on: 2018-05-13 07:47:28 
Started by Ask_Reply - Last post by Ask_Reply
Hey it's Summer holiday here!!!  and having some free time,  I am open to INTERESTING  [Android]  Game projects!!

Have a cool idea but not much coding skills?

I would be glad to collaborate with you in the Project as the lead (or may be, the only) Programmer.

May be we can work together for fun on  Profit Sharing basis. Feel free to contact me at my below mail address :

chocolategamesdev@gmail.com

Looking forward for your words :-)

(Mail me with the Subject : "Game Collaboration -> Pixelation.org",  as soon as possible, before I get involved into new Projects.)

Cheers!!!

____________________________

Screenshot of a recent project :


 94 
 on: 2018-05-13 00:35:04 
Started by nelsongames - Last post by nelsongames
I'm writing a game that will support multiplayer using LibGDX. HTML is a priority, so I'm forced into using WebSockets (Socket.io library).

My question is, will using Socket.io be a performance problem compared to a framework like Netty?

 95 
 on: 2018-05-12 17:53:52 
Started by FabulousFellini - Last post by FabulousFellini
Am I anywhere close with this?  How it is now will kind of just cut off the bottom of the viewport and flips the y axis over.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
private void initializeCamera() {
      camera                   = new OrthographicCamera(cameraWidth, cameraHeight);
      camera.position.x        = myGame.gameObjectLoader.player.getX();
      camera.position.y        = myGame.gameObjectLoader.player.getY();
      camera.setToOrtho(true, cameraWidth, cameraHeight);
     
      float ex = 10f; // <- 4 units in each direction
      float ar = (float) cameraWidth / cameraHeight;
      matrixO.setToOrtho(-ar*ex, ar*ex, -ex, ex, 0, 10);
      matrixR.setToRotation(new Vector3(1, 0, 0), 45);
      matrixR.translate(0, -1, -1);
      matrixT = matrixO.mul(matrixR);
      camera.rotate(matrixT);
   }


One thing I'm confused about is ar:  is that the cameraWidth/cameraHeight?  Or is it supposed to be Gdx.graphics.getWidth()/height (I tried both).   CameraWidth = 10 at the moment and I don't specifiy a size for the window in the desktop launcher so it's size is whatever the default is.  So that code above is camera init().  Here is the camera update method:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
@Override
   protected void updateCamera() {
      myGame.renderer.batch.setProjectionMatrix(camera.combined);
      myGame.renderer.shapeRenderer.setProjectionMatrix(camera.combined);
     
      if (!ScreenShake.screenIsShaking) {
         camera.position.x = myGame.gameObjectLoader.player.getX();
         camera.position.y = myGame.gameObjectLoader.player.getY();
      }
      camera.update();
   }


Sorry this is so confusing, and thanks again.

 96 
 on: 2018-05-11 18:53:02 
Started by pavul - Last post by FabulousFellini
I have set up tiles in my new 'game' and here's how I do it.  It seems to work well.  I'm just going to give you the github link, and in the package 'maps', there are three classes, one which just has the map layout, one which loads it upon instantiation, and one which draws it in game.  The tiles are 1 x 1 because that is left over from zooming the camera view in.  Otherwise the actual tile sizes are 32 x 32.   With all that being said, I have no idea if these are best practices or not, and would like some advice too.  Also maybe I should say, in the mapEditor, "0" = non solid tile, "1" = solid tile.

https://github.com/IanFell/GameTemplate/tree/master/MyGame-core/src/maps

 97 
 on: 2018-05-11 17:10:12 
Started by pavul - Last post by pavul
hello guys, i was wondering what is thebest way to cerate a tiled level, for example i have:
 
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  
int [] tileMap = {
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,2,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   
     0,0,0,0,0,0,0,2,0,0,1,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,2,0,0,1,1,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,2,0,0,1,1,1,0,0,0,3,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
     };


where 1 & 2 are diferent platforms, 0 are blank spaces, i have an image strip with 3 tiles.

the way im creating my tiled level is iterating above array and draw each image in the correct position, however im wondering if this is the correct way to do it i dont know if tiles work in the same way at this behind the curtain, can some one give some tips of how can i improve this, thanks in advance.
the method im using to draw those tiles is 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  
39  
40  
41  
42  
43  
44  
45  
46  
47  
public void drawBgTile(Graphics2D g2,Image[] img, int[] map,int cols, int rows, 
            int tileWidth, int tileHeight)
    {
        if( cols <=0 || rows <= 0 )
        {return;}
       
        int mapIndex = 0;
        int totalTiles = cols*rows;
       
        int width = tileWidth;   //img[0].getWidth(this);
       
        int height = tileHeight; //img[0].getHeight(this);
       
        int offsetx = cam.getOffsetX();
        int offsety = cam.getOffsetY();
//        int tilewidth=Config.TILE_WIDTH;
//        int nodib=0;
       
        //renglones
        //rows
        for(int i=0;i < rows;i++)
                {
                        //columnas
                        //columns
                        for(int j=0;j < cols;j++)
                        {
                         //checamos si el tile esta dentro de los limites de la camara
                         //si no lo esta, entonces no lo dibujamos
                           
                         //if tile is inside camera limits then is rendered otherwise
                         //not , this save a lot of process
                         if( j * tileWidth  > offsetx - tileWidth
                           && (j * tileWidth) + tileWidth < offsetx + cam.getViewWidth() + tileWidth
                           && i * tileHeight > offsety - tileHeight
                           && (i * tileHeight) + tileHeight < offsety + cam.getViewHeigth() + tileHeight)
                         {
                         if( map[ mapIndex ] != -1 )
                            g2.drawImage( img[ map[ mapIndex ] ], width * j, height * i, null );
                         }//if validacion si se dibuja
                             
                          if(mapIndex < totalTiles)
                             mapIndex++;
                        }//for cols
                }//for rows

       
    }//


PD: im only drawing tiles that are inside cammera offsets

 98 
 on: 2018-05-11 14:35:16 
Started by mudlee - Last post by mudlee
I do the exact same stuff that is on the page I linked. After the SSAO texture is generated, I pass it to the last shader where it affects the final color. As I saw it has no effect on the fragment's color, I started to debug if something is wrong with the SSAO texture.

First, I checked the GBuffer textures, all are good. Second, I checked the SSAO texture if its wrong and it is. No matter what I set to the OUT_Color, the texture will be completely red.

I tried what if I expect RGBA and output a vec4 from the shader with a fixed value. In that case, the texture turned to white and no matter what I set for the OUT_Color, it remains white. Now I think the problem is around the framebuffer code, but went 10 times through it and looks good. Maybe I have to sleep and retry tomorrow Smiley

BTW, when I write I checked the texture I mean I draw it onto the upper right using nanovg.

Here is the render logic:
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  
    public void onRender() {
        GL11.glClearColor(1f, 1f, 1f, 1f);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);

        batches.values().forEach(RenderBatch::initGPUDataStores); // it sets up VAO, VBO, etc

        computeSSAOGeometryData(() -> {
            ssaoGeometryShader.bind();
            batches.values().forEach(renderBatch -> {
                // TODO: what if it does not have texture?
                ssaoGeometryShader.updateMaterialDiffuseTexture(renderBatch);
                renderBatch.render();
            });
            ssaoGeometryShader.unbind();
        });

        computeSSAOTexture(() -> {
            ssaoShader.bind();
            batches.values().forEach(renderBatch -> {
                renderBatch.render();
            });
            ssaoShader.unbind();
        });

        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        batches.values().forEach(renderBatch -> {
            renderBatch.getMaterial().getShader().bind();

            ((StandardShader)renderBatch.getMaterial().getShader()).ssao(ssaoBuffer);

            renderBatch.render();
            renderBatch.getMaterial().getShader().unbind();
        });
    }

    private void computeSSAOGeometryData(Runnable batchRendering) {
        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, gBuffer.getGFBO());
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT);

        batchRendering.run();

        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    }

    private void computeSSAOTexture(Runnable batchRendering) {
        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, ssaoBuffer.getFBO());
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

        batchRendering.run();

        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    }

 99 
 on: 2018-05-11 14:23:52 
Started by mudlee - Last post by orange451
Well, you've assigned your texture to:
1  
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED...)

So, it only has the red channel of color.


--
But if I understand correctly... even if you output something like:
1  
OUT_Color = 0.0f;

It is still red?


--
Are you drawing a fullscreen quad on your screen with that shader bound? Otherwise nothing will change, because there's nothing being sent to the fragment shader.


Also... a lot of this code looks like it was lazily taken from John Chapman's blog...

 100 
 on: 2018-05-11 08:03:28 
Started by mudlee - Last post by mudlee
Hi guys.

I need some help regarding to SSAO. I've followed this popular tutorial: https://learnopengl.com/Advanced-Lighting/SSAO.
Somehow, the occlusion factor is always 1, so no changes can be observed.

I debugged through the code and:
  • The GBuffer textures are correct
  • The problem is might be the SSAO texture itself.

So... when I generate the ssao texture onto the screen, it's totally red and if I change the ssao shader output value to any float, it remains red. That's why I think, the problem is somewhere over there.

The code is the same as in the tutorial, but here it is the ssao buffer:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
FBO = glGenFramebuffers();
blurFBO = glGenFramebuffers();

glBindFramebuffer(GL_FRAMEBUFFER, FBO);

LOGGER.debug("> Creating color texture...");
int ssaoColorTexture = glGenTextures();
glBindTexture(GL_TEXTURE_2D, ssaoColorTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, Engine.properties.getWindowWidth(), Engine.properties.getWindowHeight(), 0, GL_RGB, GL_FLOAT, (ByteBuffer) null);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ssaoColorTexture, 0);

if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
     throw new RuntimeException("SSAO buffer is not completed");
}


In the fragment shader I just use
1  
layout (location = 0) out float OUT_Color;


And assign it:
1  
OUT_Color =1.0f

And the value above does not affect the texture in the FBO.

What can be the problem, where should I continue debugging?

Pages: 1 ... 8 9 [10]
 
DesertCoockie (20 views)
2018-05-13 18:23:11

nelsongames (68 views)
2018-04-24 18:15:36

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

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

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

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

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

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

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

buddyBro (1006 views)
2018-02-28 16:59:18
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!