Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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: Make 2D Map without tiles? on: 2014-03-28 19:04:55
So the program Tiled will be good to create something like it?
2  Game Development / Newbie & Debugging Questions / Make 2D Map without tiles? on: 2014-03-28 18:47:39
Hello how can i make a 2D map but without tiles?

Something like this -


Ignore everything, just look at the ground structure. its not tiles i suppose. actually i don't even know how its called.
How can i make something like this?

The character can go only left and right.
3  Game Development / Newbie & Debugging Questions / Re: Scene2D UI - make grid on: 2014-02-07 17:20:07
Why don't you just make your own grid? Cheesy

I bet Notch made those "grids" himself.
I forgot to update you guys, but i used his idea to create my grid for the inventory. and it goes pretty nice.
the only downside is that the code is really dirty, and there are too much data to calculate, but its nothing that some "clean ups" won't fix.

Thanks Wink
4  Game Development / Newbie & Debugging Questions / Re: Scene2D UI - make grid on: 2014-02-05 12:23:50
Funny enough this is actually already done, when you create a table it has empty cells. All you would need to do is set a fixed table size, say 200x200px, you could fit 10 actors in each row if they are 20px each, once it gets to the end it starts on a new collumn.

All you would need to do is occupy the table with xx amount of placeholder actor, like have a class called EmptySlot.
There is a way to fill the table without using loop or to hardcode everything?
Just something like this -
1  
table.fill(howManyCells, cellSize)
5  Game Development / Newbie & Debugging Questions / Scene2D UI - make grid on: 2014-02-04 18:11:51
Hello, i am trying to make an inventory for my game, and for that i need to make a grid.
I am trying to get this done with the table -

1  
2  
3  
table = new Table();
table.setFillParent(true);
stage.addActor(table);


Where should i go from here?
I want my grid / inventory to look similar to this -
6  Game Development / Newbie & Debugging Questions / Re: LibGDX - how to create a button? on: 2014-02-01 13:44:24
OK, I did it. here i will write what i did to help others -

A button is simply an actor in LibGDX.
To render an actor you use a stage that contains all the actors of the screen, renders them and updates them.
I assume most of you want a button with text, so you should use the class TextButton and add it to a stage. A TextButton takes a string to render and a ButtonStyle, in this case a TextButtonStyle, which is basically a class that contains all the information about the button (font, drawable to render while not pressed, drawable to render while pressed etc).

 
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  
       public class ButtonExample extends Game{
       
        Stage stage;
        TextButton button;
        TextButtonStyle textButtonStyle;
        BitmapFont font;
        Skin skin;
        TextureAtlas buttonAtlas;
   
        @Override
       public void create() {      
          stage = new Stage();
          Gdx.input.setInputProcessor(stage);
          font = new BitmapFont();
          skin = new Skin();
          buttonAtlas = new TextureAtlas(Gdx.files.internal("buttons/buttons.pack"));
          skin.addRegions(buttonAtlas);
          textButtonStyle = new TextButtonStyle();
          textButtonStyle.font = font;
          textButtonStyle.up = skin.getDrawable("up-button");
          textButtonStyle.down = skin.getDrawable("down-button");
            textButtonStyle.checked = skin.getDrawable("checked-button");
          button = new TextButton("Button1", textButtonStyle);
          stage.addActor(button);
       }

        @Override
       public void render() {      
          super.render();
          stage.draw();
       }
    }


So whats happening here? I am creating a stage, a font and a textureatlas with all the textures for the buttons in "buttons.pack"). Then i initialize an empty TextButtonStyle and
and i add the font and the textures for the up, down and checked states. font, up, down and checked are all static variables of type Drawable so you can really pass it any kind of Drawable (texture, 9-patch etc). Then simply add the button to the Stage.

Now in order to do something when the button is actually clicked, you have to add a listener to the button, a ChangeListener.

  
1  
2  
3  
4  
5  
 button.addListener(new ChangeListener() {
        public void changed (ChangeEvent event, Actor actor) {
            Sytstem.out.println("Button Pressed");
        }
    });


Of course instead of adding the button directly to the Stage you should add it to a Table and add the Table to the Stage but I didn't want to make this post too confusing. is a good tutorial on tables in libgdx.

https://github.com/EsotericSoftware/tablelayout
7  Game Development / Newbie & Debugging Questions / LibGDX - how to create a button? on: 2014-01-31 20:15:22
I want to create a button that changes when the user hovers it, or clicking it.
I created the following variable -

   
1  
 Button buttonPlay = new Button();

I don't know what to do now, how to load the images? how to write text into the button? how to implement the events / effects (hover, click)?

It will be very helpful if someone will just write me an example button.
Thanks in advance
8  Game Development / Newbie & Debugging Questions / Re: LibGDX - change the brightness of a texture on: 2014-01-25 12:20:31
In my game I just use
1  
2  
3  
4  
batch.setColor(brightness,brightness,brightness,alpha);
//render texture and/or overlay
batch.setColor(1f,1f,1f,1f);//reset the color
//

I have a tile based lighting system though. If you want better lighting, I would use shaders
Thanks, i have block based map, and i used GLSL but it bugs my textures.. nobody could find the problem so i decided to do light with libGDX.
9  Game Development / Newbie & Debugging Questions / Re: LibGDX - change the brightness of a texture on: 2014-01-24 14:18:27
It's not impossible.
I myself have not needed that effect but here are 2 links after searching "opengl texture brightness"
http://stackoverflow.com/questions/1325088/altering-brigthness-on-opengl-texture
http://stackoverflow.com/questions/1506299/applying-brightness-and-contrast-with-opengl-es

Note that LibGDX uses GLES so the second link might be more relevant.

Ohhh i searched - " LibGDX texture brightness"  Smiley
thanks for the links
10  Game Development / Newbie & Debugging Questions / Re: LibGDX - change the brightness of a texture on: 2014-01-24 13:35:15
It's impossible? no answers and google cant find answers..
11  Game Development / Newbie & Debugging Questions / LibGDX - change the brightness of a texture on: 2014-01-23 16:47:07
Hello folks,
I am trying to achieve a lighting effect, and for that i need to change the brightness of my textures / blocks.

However, everything works except the last part, how can i change the brightness of a texture in libGDX? and it must be performance friendly.

I searched this with my friend google, but he couldn't find anything useful.. or maybe i just a bad searcher..

Any ideas folks?
Thanks in advance and see you later programmers.
12  Games Center / Showcase / Re: Desktop Bob on: 2014-01-23 15:49:38
Java but its mac only.. f**k* logic huh?
13  Game Development / Newbie & Debugging Questions / Re: GLSL - add effect to all screen instead to a specific texture on: 2014-01-23 00:14:53
I made a video about that:
<a href="http://www.youtube.com/v/caQZKeAYgD8?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/caQZKeAYgD8?version=3&amp;hl=en_US&amp;start=</a>
Here are its vertex and fragment shaders.

I f**king love your videos, i subscribed long time ago.
I fixed my problem by using your video + adding transparent vignette image.

Thank you all people Smiley
14  Game Development / Newbie & Debugging Questions / Re: GLSL - add effect to all screen instead to a specific texture on: 2014-01-22 15:22:08
The ShapeRenderer of LibGDX, doesnt work with GLSL..
This is what i wrote :
1  
2  
3  
4  
5  
6  
7  
8  
Gdx.gl.glEnable(GL10.GL_BLEND);
batch.setShader(Shaders.vignette);
sr.setProjectionMatrix(fixedCamera.combined);
sr.begin(ShapeType.Filled);
sr.setColor(1,1,1,0);
sr.rect(0, 0, GameScreen.ResX, GameScreen.ResY);
sr.end();
Gdx.gl.glDisable(GL10.GL_BLEND);


It doesn't work with my shader.. the shader is the one i posted above.

Just for your information, if i will set the alpha channel to 1 it will make the shape completely white.
15  Game Development / Newbie & Debugging Questions / GLSL - add effect to all screen instead to a specific texture on: 2014-01-21 23:30:51
Hello programmers,
I wish to add a vignette effect to the screen.

My fragment 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  
varying vec4 vColor;
varying vec2 vTexCoord;

uniform vec2 screenSize;

uniform sampler2D u_texture;
uniform vec4 gameTime;

const float RADIUS = 0.75;

const float SOFTNESS = 0.6;

void main() {

   vec4 texColor = texture2D(u_texture, vTexCoord);

    vec4 timedColor = (vColor + gameTime);

   vec2 position = (gl_FragCoord.xy / screenSize.xy) - vec2(0.5);
   float len = length(position);

   float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);

   texColor.rgb = mix(texColor.rgb, texColor.rgb * vignette, 0.5);
     
   gl_FragColor = vec4(texColor.rgb * timedColor.rgb, texColor.a);
}


the code above, adds the vignette effect only to a texture.
but i want it to add the vignette effect to the whole screen.
I thought may be i should add a transparent background image with the vignette effect on top of everything.

What do you think? what is the best way to implement this in GLSL?
Thanks bros Smiley
16  Game Development / Newbie & Debugging Questions / Re: GLSL - setting uniform problem on: 2014-01-21 15:07:05
if it is "wierd" it is your shader. not my fixed code, i just re arranged your draw call.

how shaders should be used:

1  
2  
3  
4  
5  
shader.begin(); //Begin the shader we want to use

spriteBatcher.draw(...); //put EVERYTHING we want to draw between "begin()" and "end()"

shader.end(); //Our draw call is over, lets stop the shader


To add to this: It's technically not the shader that's in use, but instead the program object. The shader(s) are compiled and then attached to the program object, which is then linked to the pipeline. When you're calling
glUseProgram()
you are allowing for all subsequent calls to affect or to be affected by the program object, however when the program is not in use nothing will affect or be affected by it.

I don't use .begin() and the .end() functions everytime i render, i just use
1  
batch.setShader(ShaderProgram);

I use this before i render stuff, and if i need to switch to another ShaderProgram, i just set the shader program i wish to use to the SpriteBatcher.
Is it the right way to use shaders?

Thanks
17  Game Development / Newbie & Debugging Questions / Re: GLSL - setting uniform problem on: 2014-01-21 14:45:43
Now it works, but its really weird, wow.. it doesn't work right but i guess its a problem with my code.
Is it? Smiley

Thanks anyways Smiley
18  Game Development / Newbie & Debugging Questions / Re: LibGDX - make motion blur for 2D game on: 2014-01-21 14:38:19
I gonna answer my own question

I changed only the fragment 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  
 varying vec4 vColor;
    varying vec2 vTexCoord;

    uniform vec2 screenSize;

    uniform sampler2D u_texture;
    uniform vec4 v_time;

    const float RADIUS = 0.75;

    const float SOFTNESS = 0.6;

    const float blurSize = 1.0/1000.0;

    void main() {

       vec4 texColor = vec4(0.0); // texture2D(u_texture, vTexCoord)
      texColor += texture2D(u_texture, vTexCoord - 4.0*blurSize) * 0.05;
          texColor += texture2D(u_texture, vTexCoord - 3.0*blurSize) * 0.09;
         texColor += texture2D(u_texture, vTexCoord - 2.0*blurSize) * 0.12;
          texColor += texture2D(u_texture, vTexCoord - blurSize) * 0.15;
          texColor += texture2D(u_texture, vTexCoord) * 0.16;
          texColor += texture2D(u_texture, vTexCoord + blurSize) * 0.15;
          texColor += texture2D(u_texture, vTexCoord + 2.0*blurSize) * 0.12;
          texColor += texture2D(u_texture, vTexCoord + 3.0*blurSize) * 0.09;
          texColor += texture2D(u_texture, vTexCoord + 4.0*blurSize) * 0.05;

        vec4 timedColor = (vColor + v_time);

       vec2 position = (gl_FragCoord.xy / screenSize.xy) - vec2(0.5);
       float len = length(position);

       float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);

       texColor.rgb = mix(texColor.rgb, texColor.rgb * vignette, 0.5);
     
       gl_FragColor = vec4(texColor.rgb * timedColor.rgb, texColor.a);
    }


The actual blur effect is written here -

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
       vec4 texColor = vec4(0.0); // texture2D(u_texture, vTexCoord)
      texColor += texture2D(u_texture, vTexCoord - 4.0*blurSize) * 0.05;
          texColor += texture2D(u_texture, vTexCoord - 3.0*blurSize) * 0.09;
         texColor += texture2D(u_texture, vTexCoord - 2.0*blurSize) * 0.12;
          texColor += texture2D(u_texture, vTexCoord - blurSize) * 0.15;
          texColor += texture2D(u_texture, vTexCoord) * 0.16;
          texColor += texture2D(u_texture, vTexCoord + blurSize) * 0.15;
          texColor += texture2D(u_texture, vTexCoord + 2.0*blurSize) * 0.12;
          texColor += texture2D(u_texture, vTexCoord + 3.0*blurSize) * 0.09;
          texColor += texture2D(u_texture, vTexCoord + 4.0*blurSize) * 0.05;


For more information - http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/

see ya out there programmers Smiley
19  Game Development / Newbie & Debugging Questions / GLSL - setting uniform problem on: 2014-01-21 14:30:44
Whats up programmers,
I went into a little problem here, My render loop doesn't render my world because of GLSL issues.

The program updates the uniform in the render loop :

1  
2  
3  
4  
5  
map[mapPos].light = Lighting.checkSunLight(mapPosY, mapPosX, this); // It works good.. returns float
Shaders.blockS.begin();
Shaders.blockS.setUniformf("lightBlock", map[mapPos].light); // Problem is here!!!
Shaders.blockS.end();
batch.draw(map[mapPos].getBlockTexture(), (mapPosX * Block.WIDTH), (mapPosY * Block.HEIGHT), Block.WIDTH, Block.HEIGHT); // Doesn't draw the block.



Just if you curious about the fragment 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  
varying vec4 vColor;
varying vec2 vTexCoord;

uniform vec2 screenSize;

uniform sampler2D u_texture;
uniform vec4 gameTime;
uniform float lightBlock;

const float RADIUS = 0.75;

const float SOFTNESS = 0.6;

void main() {

   vec4 texColor = texture2D(u_texture, vTexCoord);

    vec4 timedColor = (vColor + gameTime);

   vec2 position = (gl_FragCoord.xy / screenSize.xy) - vec2(0.5);
   float len = length(position);

   float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);

   texColor.rgb = mix(texColor.rgb, texColor.rgb * vignette, 0.5);
     
   gl_FragColor = vec4(texColor.rgb * timedColor.rgb * lightBlock, texColor.a);
}


Pedantic is
1  
ShaderProgram.pedantic= false;


Thanks for helping buddies Cheesy
20  Game Development / Newbie & Debugging Questions / Re: GLSL - make effect only on one texture on: 2014-01-18 03:34:06
Changing the current shader program isn't something you want to do 10,000 times per frame, but a few times is fine  Grin
Thanks for pointing this out Cheesy
21  Game Development / Newbie & Debugging Questions / Re: GLSL - make effect only on one texture on: 2014-01-18 01:33:18
You will have to bind this when you draw your background, and then bind another shader that doesn't blur when you draw everything else.
I didn't even think about unbinding and binding shader programs while rendering the game.. correct me if i understood you wrong.
It won't hurt the performance or something? i mean unbinding and binding different shader programs while rendering 60 times a sec won't hurt performance?

But I will absolutely try it out, thanks Smiley
22  Game Development / Newbie & Debugging Questions / GLSL - make effect only on one texture on: 2014-01-17 23:58:43
I wish to blur my background, with the following fragment 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  
 varying vec4 vColor;
    varying vec2 vTexCoord;

    uniform vec2 screenSize;

    uniform sampler2D u_texture;
    uniform vec4 v_time;

    const float RADIUS = 0.75;

    const float SOFTNESS = 0.6;

    const float blurSize = 1.0/1000.0;

    void main() {

       vec4 texColor = vec4(0.0); // texture2D(u_texture, vTexCoord)
      texColor += texture2D(u_texture, vTexCoord - 4.0*blurSize) * 0.05;
          texColor += texture2D(u_texture, vTexCoord - 3.0*blurSize) * 0.09;
         texColor += texture2D(u_texture, vTexCoord - 2.0*blurSize) * 0.12;
          texColor += texture2D(u_texture, vTexCoord - blurSize) * 0.15;
          texColor += texture2D(u_texture, vTexCoord) * 0.16;
          texColor += texture2D(u_texture, vTexCoord + blurSize) * 0.15;
          texColor += texture2D(u_texture, vTexCoord + 2.0*blurSize) * 0.12;
          texColor += texture2D(u_texture, vTexCoord + 3.0*blurSize) * 0.09;
          texColor += texture2D(u_texture, vTexCoord + 4.0*blurSize) * 0.05;

        vec4 timedColor = (vColor + v_time);

       vec2 position = (gl_FragCoord.xy / screenSize.xy) - vec2(0.5);
       float len = length(position);

       float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);

       texColor.rgb = mix(texColor.rgb, texColor.rgb * vignette, 0.5);
     
       gl_FragColor = vec4(texColor.rgb * timedColor.rgb, texColor.a);
    }

But the problem being is that the shader blurs all screen.. and i want it to blur only the background texture.. what should i write to make it focus on my background texture instead of all the screen?
23  Game Development / Newbie & Debugging Questions / LibGDX - make motion blur for 2D game on: 2014-01-17 09:01:30
I made a 2D game, with basic shaders and now i wish to add motion blur, i am beginner with shaders so i have hard time to implement it.

My shaders -
Vertex shader :
   
   
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
attribute vec4 a_color;
    attribute vec2 a_position;
    attribute vec2 a_texCoord0;

    uniform mat4 u_projTrans;

    varying vec4 v_color;
    varying vec2 v_texCoord0;

    void main() {
       v_color = a_color;
       v_texCoord0 = a_texCoord0;
       gl_Position =  u_projTrans * vec4(a_position, 0.0f, 1.0f);  
    }


Fragment 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  
 varying vec4 v_color;
    varying vec2 v_texCoord0;

    uniform vec2 screenSize;

    uniform sampler2D u_texture;
    uniform vec4 v_time;

    const float RADIUS = 0.75;

    const float SOFTNESS = 0.6;

    void main() {
       vec4 texColor = texture2D(u_texture, v_texCoord0);
        vec4 timedColor = (v_color + v_time);

       vec2 position = (gl_FragCoord.xy / screenSize.xy) - vec2(0.5);
       float len = length(position);

       float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);

       texColor.rgb = mix(texColor.rgb, texColor.rgb * vignette, 0.5);

       gl_FragColor = vec4(texColor.rgb * timedColor.rgb, texColor.a);
    }


What should I add to the shaders to create the motion blur effect?
Or maybe I can create the motion blur effect in libgdx without the shaders?

Any ideas?
Thanks in advance
24  Game Development / Newbie & Debugging Questions / libGDX - make border around an image on: 2013-12-26 16:23:16
Whats up programmers, well i have a question, can i make a border around an image? I have lots of blocks in 2D, and when the player hovers with the mouse on one of them i want to display the border around the texture / image.

Is it possible with code or should I make a separated image with the texture and border around it? Any ideas?

Thanks in advance Cheesy
25  Game Development / Newbie & Debugging Questions / Re: Make simple 2D block world - LibGDX on: 2013-12-13 16:19:06
Ok, I did it, I figured out and learnt how it works and now i can render the world awesomely great!!

I mean look at this piece of code :DDD
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public void RenderMap() {
      for(int y = 0; y < chunk / 2; y++) {
         for(int x = 0; x < chunk / 2; x++) {
            int mapPosY = (y + PosHandle.getBlockY(player.posy));
            int mapPosX = (x + PosHandle.getBlockX(player.posx));
            int mapPos = (mapPosY) * Assets.map.width + (mapPosX);
            if(Assets.map.map[mapPos].TEXTURE != null && mapPosX < Assets.map.width && mapPosY < Assets.map.height && mapPosX > 0 && mapPosY > 0) {
               batch.draw(Assets.map.map[mapPos].TEXTURE, (mapPosX * Block.WIDTH), (mapPosY * Block.HEIGHT), Block.WIDTH, Block.HEIGHT);
            }
           
            int mapPosXA = (PosHandle.getBlockX(player.posx) - x);
            int mapPosA = (mapPosY) * Assets.map.width + (mapPosXA);
            if(Assets.map.map[mapPosA].TEXTURE != null && mapPosXA < Assets.map.width && mapPosY < Assets.map.height && mapPosXA > 0 && mapPosY > 0) {
               batch.draw(Assets.map.map[mapPosA].TEXTURE, (mapPosXA * Block.WIDTH), (mapPosY * Block.HEIGHT), Block.WIDTH, Block.HEIGHT);
            }
         }
      }
   }


Any improvements? I assume you don't want to read it, but maybe you will learn something, or help me if i did something wrong.

* Actually the code will be too hard to understand so leave it, just wanted to share
Thanks for help folks!
26  Game Development / Newbie & Debugging Questions / Re: Make simple 2D block world - LibGDX on: 2013-12-13 09:33:39
Allright.. I will start to work slow and easy, I am starting to realize how this stuff works so.. I think i am in a good path.

Thanks anyways folks.
Smiley
27  Game Development / Newbie & Debugging Questions / Re: Make simple 2D block world - LibGDX on: 2013-12-12 23:38:44
Holy Shit, I am starting to realize it... So LibGDX have already a build-in game space?!?!
I figured this out as i move my camera (ortho camera), I couldn't figure out how the heck i can move in game space without creating one.
So LibGDX have a build-in game space its the answer!

Am I right? any ideas? help? something to feed me will be very appreciated!

Thank you @HeroesGraveDev, for helping.  Smiley
Do you have any upvotes here so you get points or shiit like that maybe?
28  Game Development / Newbie & Debugging Questions / Re: Make simple 2D block world - LibGDX on: 2013-12-12 23:12:02
What it does actually, it draws the map on some location ( chunk = 20 and blocksize is = 100, so the location is = 0 - 2000) in the game space (?),
Now when i move my character and my camera moves as well, i can get off that map, because it draws it always at the same location.
you understand? it doesnt expand the map as i move.. kinda..

ohhh i am soo aweful at this, am i?

I saw your projects and as I see you use tiled for the map right? well I don't i make the tile class myself with id and images hahah.
29  Game Development / Newbie & Debugging Questions / Re: Make simple 2D block world - LibGDX on: 2013-12-12 22:49:16
...Uhhh I didn't mention I am programming for more than 2 years now? I just starting out with game development, which was my dream for long.
Now let me explain the problem..

The idea of rendering a world is just to loop through an array of blocks, like this:
1  
2  
3  
4  
5  
for(int y = 0; y < chunk; y++) {
     for(int x = 0; x < chunk; x++) {
          batch.draw(map[y * width + x].TEXTURE, (x * Block.WIDTH), (y * Block.HEIGHT), Block.WIDTH, Block.HEIGHT);
     }
}


That's how it should be done, of course not exactly like this, but this is the prototype, the core of map rendering.
As I am starting out, I can't get this to work, mostly because the camera is moving and the map is rendering always at the same position, am i right?

I hope you get what is my problem and what I need is a way of thinking about it, maybe my prototype is wrong? maybe there is another way of doing this..

Thanks for helping! I am kinda of confused myself so yeah..  Roll Eyes
30  Game Development / Newbie & Debugging Questions / Make simple 2D block world - LibGDX on: 2013-12-12 19:59:31
Hello everybody, whats up?
So.. I am learning LibGDX right now, and its really really good, I love all the camera stuff and such..
But here I went into a little trouble, I CAN'T, CAN'T manage to make a simple 2D Block world..

First of all this is how I created the `world` variable -
1  
Block[] map = new Block[100 * 100];


So this is my world Cheesy
Now the block class is really simple, it just have some variables, size = 100 and texture image = some image.

Simple enough right? NOW HOW THE f**kK CAN I RENDER IT?!?!!?!?!

I tried.. for a week, I am telling you bros it looks impossible for me right now.
I can post what I've tried.. but its too not working to post haha

So how can I render a map like this, so when i move the player it moves too or something?
at least give me a way or a hint please.. i am tired for trying this for a whole week.
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (64 views)
2014-04-15 18:08:23

BurntPizza (62 views)
2014-04-15 03:46:01

UprightPath (75 views)
2014-04-14 17:39:50

UprightPath (58 views)
2014-04-14 17:35:47

Porlus (76 views)
2014-04-14 15:48:38

tom_mai78101 (101 views)
2014-04-10 04:04:31

BurntPizza (161 views)
2014-04-08 23:06:04

tom_mai78101 (256 views)
2014-04-05 13:34:39

trollwarrior1 (209 views)
2014-04-04 12:06:45

CJLetsGame (216 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!