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:


My code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| for (int x = 0; x < tmap.getWidth(); x++) { for (int y = 0; y < tmap.getHeight(); y++) { Image tImg = tmap.getTileImage(x, y, layerIndex); int tid = map.getTileId(x, y, layerIndex); if (tImg != null) { if (property.equalsIgnoreCase("background")) { StaticActor bg = new StaticActor(x * tImg.getWidth(), y * tImg.getHeight(), tImg.getWidth(), tImg.getHeight(), tImg); bg.depth = -100; add(bg); } 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); } else if (property.equalsIgnoreCase("victims")) { Man m = new Man(x * tImg.getWidth(), y * tImg.getHeight(), "man"); Man m2 = new Man(77, 79, "man"); add(m); add(m2); Log.debug("Man added"); } 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