I made a workaround on the hardcoded
render function render(int x, int y, int sx, int sy, int width, int height).
Why?
Well I wanted to make a "smooth map", where the character stands still while the map moves. And had to come up with my own solution (to lazy to use search on something I don't know the name off).
Code:
TiledMap map = null;
Vector2f pos = null;
... what ever
public void init(...) ...
{
pos = new Vector2f(0,0)
map = new TiledMap(...);
}
public void render(...) ...
{
map.render(
-1*(int)pos.x % map.getTileWidth(),
-1*(int)pos.y % map.getTileHeight(),
(int)(pos.x / map.getTileWidth()),
(int)(pos.y / map.getTileHeight())
,15
,15);
}
Solution
Just gonna cover the x, since the y is the same, diffrence is width/height.
x is where the map is drawn, if we were to move this one(-1) pixel to the left, it would make a illusion the center moved to the right, this is where we multiply pos.x with negative one(*-1). Also this is to simplify the input of pos.x, increasing pos.x is going left, and vice versa. To be honest, I didn't put much thought into this, it just worked on the first try.
Now we also need it to not move into infinity to the left or right, so we use posr.x mod map.getTileWidth. Now we got a moving map that jumps back after it's moved equal pixels to getTileWidth. Now to decide what sx should be, we devide pos.x with getTileWidth(), and we get how many squares we've moved.
Kinda new to this, so if feedback would be nice.
Fin.