[Slick2d] Design concepts for encapsulation - Opinion needed.

Hey all, I am working on rewriting my MapController class, it’s basically the class that loads/unloads my maps and handles all the getters/setters related to the map and coordinates system in the game. There will usually only ever be one MapController object that handles everything. When a map changes it runs a class internally that dumps the old map and rebuilds a new one whenever the player transitions into a new map.

There are certain situations where I need to pass the TiledMap class from MapController into other classes. For example, I build my lighting map based on property flags directly on each TiledMap file. It runs through a for loop, finds all the tiles that have a "lightSource = " flag, and applies a light over top of that tile that matches . Currently, to do that MapController creates the LightController object and passes TiledMap to it, then LightingController takes TiledMap and runs a for loop and starts the search under init().

My long-winded question is; would it be better to make Getter/Setters inside the MapController that interact with the TiledMap class, so LightingController has to run something like “.getTileId()” that will basically just go into and run “.getTileId()” and return the value to LightingController . . . or is it acceptable to go ahead and pass TiledMap to LightingController directly so it can just run TiledMap methods out of that class?

I guess the TL:DR version is, should LightingController run through MapController to access TiledMap, or should it be allowed direct access to the object that MapController created, by having MapController pass the current TiledMap Object to the LightingController?

Sorry if this all sounds confusing, it’s a bit hard to explain. :slight_smile:

EDIT: Basically, what I am asking is, since MapController pretty much controls all aspects of TiledMap, should I only allow MapController direct access to TiledMap and force all the other classes that need to interact with the instance of TiledMap to do it through MapController?

Sorry if my answer is irrelevant, I really don’t know what your trying to say

If I were you I’d make three different instances of the map, Rendered in this order:

Background - For paths, and floors
Middle - (Renders light) For items, characters, and moving things.
Upper - For walls, and things player can collide into.

So that in the loop, it would be:
Background map render
Middle Map render
Player render
Light render
Upper layer render

This way, it will look like the light does’t go through the walls.
(Expecting its a topographical map.)

Edit: A better look:

See how the light is underneath the top layer?