Disch, I had already tried there and it didn't work, BUT you are correct that it is supposed to go there. I figured out *why* it wasn't working even though it is supposed to be there.
It was in my render() method for the World:
Changed to:
The min and max methods were restricting everything because it was never allowing anything beyond the bounds of the map to render.
And here's what I added to getTile() just for reference:
It appears the formula used in that stackoverflow method above works fine.
It was in my render() method for the World:
Code Select
int xStart = (int) Math.max(0, handler.getGameCamera().getxOffset() / Constants.DEFAULT_WIDTH);
int xEnd = (int) Math.min(width, (handler.getGameCamera().getxOffset() + handler.getWidth()) / Constants.DEFAULT_WIDTH + 1);
int yStart = (int) Math.max(0, handler.getGameCamera().getyOffset() / Constants.DEFAULT_HEIGHT);
int yEnd = (int) Math.min(height, (handler.getGameCamera().getyOffset() + handler.getHeight()) / Constants.DEFAULT_HEIGHT + 1);
Changed to:
Code Select
int xStart = (int) handler.getGameCamera().getxOffset() / Constants.DEFAULT_WIDTH - 1;
int xEnd = (int) (handler.getGameCamera().getxOffset() + handler.getWidth()) / Constants.DEFAULT_WIDTH + 1;
int yStart = (int) handler.getGameCamera().getyOffset() / Constants.DEFAULT_HEIGHT - 1;
int yEnd = (int) (handler.getGameCamera().getyOffset() + handler.getHeight()) / Constants.DEFAULT_HEIGHT + 1;
The min and max methods were restricting everything because it was never allowing anything beyond the bounds of the map to render.
And here's what I added to getTile() just for reference:
Code Select
public Tile getTile(int x, int y){
x = (x % width + width) % width;
y = (y % height + height) % height;
Tile t = Tile.tiles[ tiles[x][y] ];
if(t == null)
return Tile.tiles[0];
else
return t;
}
It appears the formula used in that stackoverflow method above works fine.