I posted the same thing on Slick forums - posting here as well because slick forums aren’t very active.
So I created a map using Tiled. I loaded into my game world.
I went through each tile and layer and added the objects I needed such as the entities and the collision objects.
It renders them all correctly and all works dandy except when I move my camera around it doesn’t do it anywhere else other than the width of the frame. It is missing 3/4s of the map.
I use map.render(0,0) and it renders the rest of the map, but the entities aren’t there, no hit box, etc. Look below at images:
http://img830.imageshack.us/img830/8541/85912447.png
http://img706.imageshack.us/img706/37/55021676.png
My code:
for (int x = 0; x < tmap.getWidth(); x++) {
for (int y = 0; y < tmap.getHeight(); y++) {
//creats an image of the tile
Image tImg = tmap.getTileImage(x, y, layerIndex);
int tid = map.getTileId(x, y, layerIndex);
if (tImg != null) {
//load background as an image
if (property.equalsIgnoreCase("background")) {
StaticActor bg = new StaticActor(x * tImg.getWidth(), y * tImg.getHeight(), tImg.getWidth(), tImg.getHeight(), tImg);
bg.depth = -100;
add(bg);
//load the trees/benches etc as an image too
} else if (property.equalsIgnoreCase("entities")) {
StaticActor ents = new StaticActor(x * tImg.getWidth(), y * tImg.getHeight(), tImg.getWidth(), tImg.getHeight(), tImg);
ents.depth = -50;
add(ents);
//load all the victims/people
} else if (property.equalsIgnoreCase("victims")) {
// String victim = map.getTileProperty(tid, "victim", null);
Man m = new Man(x * tImg.getWidth(), y * tImg.getHeight(), "man");
Man m2 = new Man(77, 79, "man"); //test man
add(m);
add(m2);
Log.debug("Man added");
//load the collision blocks
} else if (property.equalsIgnoreCase("collision")) {
CollisionEntity ce = new CollisionEntity(x * tImg.getWidth(), y * tImg.getHeight(), tmap.getTileWidth(), tmap.getTileHeight());
add(ce);
}
}
}
}
Even if I don’t add the background as an image and the trees and stuff as an image, and just use map.render(0,0) it does the same thing. If I use this code and not the map.render(0,0) does the same thing. Not sure what is wrong? Any way to get this working? Thanks