So I just started a new game again, it's gonna be a top-down view with bow and arrow, monsters and quests.The Camera class is doing really fine.For the map I'm using tiledmap, where I got in problems.It renders the map fine, but the problem is: it renders the whole map.Now there is this method TiledMap.render(x, y, sx, sy, width, height); where sx and sy stands for start x and y.This method looked really fine until I read that the sx, sy, width and height were in tiledmap blocks. This results having full tiles rendered and not the smooth scrolling idea.Does someone have any idea how to fix this?

There used to be a great example by kevglass on this exact topic, but maybe it was lost when slick was taken over by other developers.

The basic idea is that you use Graphics.translate(float x, float y) to move everything so that the player (or wahtever your camera is following) stays at the center of the screen. The key to this is to find the offset of the player from the center and translate everything by that much.

You can just check how close your offset is to being a multiple of your tilesize and use that difference to move the map slightly so for example if your xoffset is 100 and your tilesize is 30 then your code would look like

That usual is the way to do this, yes.But, because all the coordinates besides x, y are in tiles, it will only render full tiles, so that means an ugly scrolling in a block-by-block way.I wish I could make a video of this..

That usual is the way to do this, yes.But, because all the coordinates besides x, y are in tiles, it will only render full tiles, so that means an ugly scrolling in a block-by-block way.I wish I could make a video of this..

Yes, I understand what you mean and the video was very clear. I had thought that the code I posted would fix that because it takes into account the block issue by using the remainders. I can't test anythign becuase I am at work right now. So the code I gave you produced the same results as you had before?

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