0

Hello I am making a 2D RPG in slick2D and I made a small class for creating new maps

public class Map {
    TiledMap tiledmap = null;

    public Map(String location, int x, int y) {
        try {
            tiledmap = new TiledMap(location);
        } catch (SlickException e) {
            e.printStackTrace();
        }

        tiledmap.render(x, y);

}
}

But it drops the FPS from 60 (Targeted FPS) to like 30 i do not know what happend and I've been looking for some time and can't find any results and that is why I'm here to ask the community, if you can help great and oh here's how I'm calling it

Map map = new Map("res/gametileset.tmx", 0, 0);

and that's from my play update loop

Neel Kumar
  • 180
  • 1
  • 9
Genthorn
  • 21
  • 8

1 Answers1

0

Judging by your code you are loading and then rendering the map repeatedly in your update loop. This is bound to be rather slow. Instead, I would suggest you create your Map instance once, and introduce a method to this class that just calls the render(x, y) function and call that from your update loop.

Thorbjørn Lindeijer
  • 2,022
  • 1
  • 17
  • 22