Composite and Node structure


I’m building a simple map for the first game.

I want to use the composite pattern for parts of this Map.

A Map could consist of tiles only, or larger structures like rooms, buildings (which then would consist of tiles or rooms)

So I wrote a nice interface MapParts that Tile, Room and Building implement.

Now I want to work with jme3.

So my Map (has a List of MapParts) is now a MapNode with some Data and functionality added with a MapControl class.

I’d like to add the mapParts to the mapNode but these are no Spatials.

So should I make my MapParts Spatials or save a spatial in the MapParts and use this to connect the scene graph?

Thanks a lot


@Mod: should I post questions on Game Design in the General Forum not the Troubleshooting General Forum?

If so please feel free to move this thread!

Thanks and sorry

I suggest you first look into jME3 and check whats there, you might want to change the pattern you laid out as most of these structures exist already in jme3.

I’ve read all the documentation there is available on, so I’m not to low on information.

But the doc is mostly technical and does not help me a lot on design issues.

Use of controls is encouraged so I might create a node/spatial for every MapPart and add three different kinds of controls that all are subclassed from a MapPartControl class.

Hope that will work!

Thanks for the reply!

Subclassing is bad practice as a programming pattern really, rather have controls that know each other than extending base controls. The TerrainGrid as it is in svn ( the changes should go to stable soon though ) can easily stream tiles of any kind really.

Do you know of any implementation using it for a hexagonal grid or any other non rectangular tiled grid?

Whould really like to see this done.

For now I’ve managed to get a Map with TileControl controlles Tiles running.

Happy to see some results :slight_smile:


A grid is a logical construct, you do not necessarily need to (and actually should not) have the single tiles be represented by single objects.