Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Thomas Cashman
@tomcashman
Very strange. Can you paste the code where you create the map?
Mateus Bandeira
@mateusbandeiraa

I made some changes since my last message, but the issue persists. Actually, my code is very simple yet.

The main screen:

public class IndoorScreen extends BasicGameScreen {
    private GameMap tiledMap;

    // ...
    @Override
    public void initialise(GameContainer gc) {
        try {
            tiledMap = new GameMap(Gdx.files.internal("Maps/sample_indoor.tmx"));
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    @Override
    public void render(GameContainer gc, Graphics g) {
        g.drawCircle(0, 0, 5); // tiledMap won't render if this line is not present.
        tiledMap.render(gc, g);
    }
}

The GameMap class:

public class GameMap extends TiledMap {
    private int positionX = 0;
    private int positionY = 0;
    private float renderScale = 1.2f;

    // ...
    public void render(GameContainer gc, Graphics g) {
        g.scale(renderScale, renderScale);

        this.draw(g, positionX, positionY);

        g.scale(1, 1);
    }
}

Later I discovered that rendering something after tiledMap.draw() will make it work on the next render() call. In other words:

    // IndoorScreen class
    private int renderCalls = 0;
    @Override
    public void render(GameContainer gc, Graphics g) {
        tiledMap.render(gc, g);
        g.drawCircle(0, 0, 5); 
        System.out.println("renderCall: " + ++renderCalls);
    }
renderCall: 1 -> Just the circle.
renderCall: 2 -> Both circle and map.

This is not a huge problem for me, as I indeed need to render other objects. But It gave me a headache when the first thing I was trying to do was make the map show up on the screen.

Thomas Cashman
@tomcashman
hmm there must be a bug in the graphics flushing. I will investigate. Sorry for the issue, I'll let you know when fixed!
also, you can manually force a flush using g.flush() if needed though in general it's best not to do this since we try to batch everything
Mateus Bandeira
@mateusbandeiraa

I forgot to mention: I tried to flush() before and after the tiledMap.draw() call. Still no luck.

Sorry for the issue, I'll let you know when fixed!

No need to apologize. Your work is already amazing.

Thomas Cashman
@tomcashman
that's very bizarre! I'll investigate and try fix in a 1.9.1 update :)
Tor (torbuntu)
@Torbuntu
If it helps at all, I can in draw a map right after viewport.apply(g);
Not sure if useful, but I was curious. And my maps draw without having to actually draw something else.
acuilab
@acuilab
:)
@tomcashman n When 2.0 will be released?
Thomas Cashman
@tomcashman
First beta will be in August
Final release probably in September or October
acuilab
@acuilab
In mini2Dx you redesigned the ui, why not use scene 2d ui directly?
Thomas Cashman
@tomcashman
2.0 will de-couple from LibGDX so UI needed to be independent to allow for portability to consoles
I’m not 100% happy with current UI implementation, want to try simplify it in 2.0
acuilab
@acuilab
But what is the consoles?
Thomas Cashman
@tomcashman
First console being targeted is Nintendo Switch
acuilab
@acuilab
Got it!
Tor (torbuntu)
@Torbuntu
Will Pixmap from libgdx be supported going into Mini2Dx 2.0? With the separation from libgdx will there be something similar anyway? Using Graphics to draw raw shapes is pretty poor performance on lower devices. I managed to get some pretty decent performance using a texture and pixmap to do the same thing (drawing line and hit box outlines or just doodle shapes with maths).
Thomas Cashman
@tomcashman
I’m not 100% sure yet
Tor (torbuntu)
@Torbuntu
I saw a while ago an issue on github about poor rect performance and had a similar trouble. Would you imagine that drawing with graphics would improve in the future version to where I wouldn't need the pixmap? (Though I do like drawing individual pixels)
Oh wait what the heck. Mini2Dx
Has a pixmap already 😂 I'll try switching my libgdx one to that.
Tor (torbuntu)
@Torbuntu
or is that not in the most recent version
nope, that isn't in the newest version. Never mind then xD
Tor (torbuntu)
@Torbuntu
Not sure how beneficial it would be to the majority of users. But I find using a pixmap to be an extremely nice feature for performant custom drawing during runtime.
But I think the system I'm building is targeting a pretty niche crowd as it is.
HerrDerb
@HerrDerb
HI, i have a question to hex tile map rendering
I'm not sure if I forgott something or if this might be an actuall bug.
I have hex tiles with 64x72 pixels. When I load the map they get rendered this way:
grafik.png
They start to overlap each other sideways
Inspecting the TiledMap object of mini2Dx i found the following
grafik.png
It seems that the TiledLayerRender has wrong information about the tile sizes
Thomas Cashman
@tomcashman
Hmm I’ll check the code
Thomas Cashman
@tomcashman
@HerrDerb would you be able to send me the map + tileset somehow?
That's a basic runnable project with the issue
HerrDerb
@HerrDerb
I'm just kind of stuck. How do I use the camera in mini2dx?
Thomas Cashman
@tomcashman
I'm trying to figure out the correct way to render the hex when the side length doesn't match the width/height
in terms of the camera, there is no Camera class as such in mini2Dx (this will probably come in 2.x) so you need to manually use g.translate to move the camera around
Thomas Cashman
@tomcashman
@HerrDerb I found the issue with rendering. Will upload 1.9.1 to Maven Central this evening :)
Thomas Cashman
@tomcashman
@HerrDerb 1.9.1 is now available :)
HerrDerb
@HerrDerb
Cheers :) I've just been checking it. I'm afraid it's not quite right yet. I still have a small shift with the example project I've posted. What is exactly the reason that you calculate the with with hexWidth = (tiledMap.getSideLength() * 2) + sideOffsetX;? and not simply tilemap.getTileWidth()? With the first approach, you'd need to know the angles, don't you?
Thomas Cashman
@tomcashman
if you zoom in your map in tiled you'll see you tiles are off by 1 pixel
*your tiles
I think your tileset configuration is wrong?
HerrDerb
@HerrDerb
Oh, well this is possible I guess :)
Oh, gimp does start with 0 for the x coordinate....