Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Slick2d] Design concepts for encapsulation - Opinion needed.  (Read 1051 times)
0 Members and 1 Guest are viewing this topic.
Offline Rayvolution

« JGO Spiffy Duke »

Medals: 379
Projects: 2
Exp: 2 years

Resident Crazyman

« Posted 2014-02-22 21:25:04 »

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 = <lightType>" flag, and applies a light over top of that tile that matches <lightType>. 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 "<MapControllerObject>.getTileId()" that will basically just go into <MapControllerObject> and run "<TiledMapObject>.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. Smiley

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?

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Now on Steam!
Offline Spacebeans
« Reply #1 - Posted 2014-03-02 22:33:39 »

*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?
Pages: [1]
  ignore  |  Print  

EgonOlsen (76 views)
2018-06-10 19:43:48

EgonOlsen (56 views)
2018-06-10 19:43:44

EgonOlsen (76 views)
2018-06-10 19:43:20

DesertCoockie (258 views)
2018-05-13 18:23:11

nelsongames (156 views)
2018-04-24 18:15:36

nelsongames (155 views)
2018-04-24 18:14:32

ivj94 (896 views)
2018-03-24 14:47:39

ivj94 (160 views)
2018-03-24 14:46:31

ivj94 (809 views)
2018-03-24 14:43:53

Solater (173 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!