last day (15 days later) » 

7:18 PM
0
Q: Map rendering Libgdx Java

user3165683Ok, so I am trying to create a 2D non-movable random tiled map. This is what I have so far: private void generateTile(){ System.out.print("tiletry1"); while(loadedTiles != 8100){ System.out.print("tiletry"); Texture currentTile = null; int tileX = 0; int tileY = 0; ...

 
What have you tried to fix it? Try disabling the glClear or moving that line around before some of the other drawing methods.
 
@AttackingHobo i've tried that but i still can't getting it to work
 
What happens when you do that?
 
@AttackingHobo sometimes it stays green, sometimes it flashes from the previous screen to green, etc...
@AttackingHobo Where do you think would be the best place to put it???
 
If you entirely remove the clear, it shouldn't flash green to anything. Everything should be drawn and kind of stay there.
 
7:18 PM
@AttackingHobo yeah that happens it leaves like a shadow of the sprites
 
Move the GlClear before anything else is ever drawn. That way it clears the entire screen, and then draws on top of that.
 
@AttackingHobo it still shows a block background colour
 
Hello. I can help you a bit faster here.
 
Brilliant thank you for your help
 
Can you take a screenshot of what you are seeing?
 
7:22 PM
How can i share images on the chat?
 
@user3165683 upload them to imgur.com or some other image host is one way
 
I edited my question with it in.
 
@user3165683 where is the glclear for that shot?
 
At the very top of the render method:
public void render(float delta) {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
 
And all the tiles are rendered after that?
If you take off the glClear can you see the tiles?
 
7:33 PM
Yes
 
Yes to which question?
 
All the tiles are rendered after that
if i remove it then i get the previous screen with the sprites and there shadows like graphics being left behind them
 
You see the tiles when you remove it right?
 
No i see the old option screen and the sprites on top, know tiles
 
Your tiles are not being rendered then.
at all
 
7:38 PM
No, i can't see any of them
In any of the situations
 
You seem to be generating and rendering your tiles at the same time
and you might only be doing that once
You should have the tiles being drawn every frame
 
Ok...
How can i do this, i think i understand what you are saying
 
generateTile() Where is that being called?
 
At the very start in the first method, but i recently removed the generateTile() method and tried putting the code in the render() method with know change.
 
Generate the tiles in the first method. Store them in a 2dArray(look that up) and draw them later using the data from the 2d array
just store what type they are in the array, and then use the correct graphic in your drawing method
Work backwards. Make a function that can draw a tile at a given X Y and Graphic options
drawTile(X,Y,Graphic)
 
7:49 PM
Something like this:
int w = 16;
int h = 16;
int[][] tiles = new int [w][h];
16 - height and width of the tiles
 
then this etc...
case 0:
// currentTile = tile1;
// tiles.add(tile1);
// break;
 
4
Q: How to make a tile based map from an array in java?

DerekI've seen it done like this: int[] map = { 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...

Some of the answers might be helpful
 
So can i do somethign like this:
intro = getAudioClip(getCodeBase(), "intro.wav");
int[][] map = {
{ 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, 0, 0, 0, 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, },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
 
You could. But check out those answers. You can fill them out using loops and then modify them later. or you have that in there manually
 
7:58 PM
But then change leve.add(newWall(y,x)); to my random generation code with it adding the correct tile to the array.
But how do i get them in there as textures and how can i then render them???
 
a simple way is to use another array with the textures
and choose the texture from the tile type stored in the 2d array
 
Texture[] tileOptions;
like that?
 
yeah, that should work. Generally just search what you are looking for and you can see if you are on the right track.
 
Ok thank you just one last bit, what would the render batch.draw look like for an array
 
Im not sure what you need to do with your batches
 
8:09 PM
Thank you
 
@user3165683 check that out before you go. You might be some built in stuff to help you out
 

last day (15 days later) »