Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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 241 times)
0 Members and 1 Guest are viewing this topic.
Offline Rayvolution

JGO Kernel


Medals: 208
Projects: 2
Exp: 1 year


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 - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (39 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!