Tilemap drawing/loading/dividing

I need a seamless transition from one room to another room. I have 2 approaches in my mind for now:

  1. Level consist of several rooms and each tilemap is a room.
    Player touch certain zone on active room (room where player is now). As result new neighbor room is drawn next to the current room so player can see both rooms at the same time. Personally I see this approach too abrupt and edgy for the player’s perception. Am I wrong?
    For now I’ve just tried similar approach but with modification: For each room I added object (spawn for player) near transitions between rooms. So when player step on the boarder of the room, next room will be drawn and the player will appear at the object position near this transition but already in the neighbor room. To sum up I’ve just drawn new room instead of previous one and placed player at the appropriate position. In this case I can say with certainty It’s really too absurd and sudden appearance of the new map. Disappearance of the previous one has the same problem. So I crossed this choice.

  2. Unite rooms into one level. So level is a single large tilemap ( e.g. 128 x128 ) and I think this should be enough for me.
    Here go some questions:
    2.1. Is there any way to draw only choosen tiles (e.g. square 8 x 8 with player at the center)?
    2.2. Are tiles being drawn outside the visible part of map? Maybe they are being culled and I don’t even need to worry about the question 2.1?
    2.3. What about performance? will be any issues with such huge map?

Also any actual tutorials? I’ll be glad to see some info about the subject above.

Do you have any advice?

Thanks for reading this.

PS: cocos2dx 3.17; Tiled 1.2;

I am not sure about the 1) but I will try to give some answers to 2.

2.1 Yes. You can show/hide any tile you want. Maybe instead of showing/hiding tiles you could create a layer “with a hole” above your map?

2.2 If you are using “normal” TMX layer then tiles won’t be culled. Try to use FastTMXLayer (experimental at least in v3.15). Tiles are culled and it is pretty fast (the first one is also fast ;). In my current project I am using FastTMXLayer, but I remember that I had to fix something inside it. I think there was a problem with “empty lines” while rendering the map.

2.3 I would suggest to divide your map into smaller pieces. Maybe you will need rooms with different sizes, like long dungeons, small cells etc. This way you will be able to create any map size. You will be able to re-use lots of rooms and build levels dynamically.

Do you have any advice?

Build your logic first.

kds

Thank you very much for your answer. I’ll try FastTMXLayer). I’d like to make things clear about approach with some rooms:

  1. Is every room a new tmx map?
  2. When did you draw it? Is it drawn when player come close to the transition between rooms? in the way to avoid player seeing it’s appearence?( Actually I want to try this approach).
  3. I also interested about performance with tilemaps with size around 128 x 32 tiles because If It’s enough to use map of such size, will be usefull to break the map on smaller ones? It’s not something hard but still takes some time. (I mean when It’s acceptable for the choosen game)

Best wishes!

  1. If you want to split your map into smaller pieces then yes (all pieces may share the same tileset).
  2. Sounds good.
  3. It should be fine. I am using ~100x20 maps and it runs well. It really depends on what do you want to achieve. For sure it will be easier at the beginning to use single maps.

Thank you.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.