I have set up and got a tiledmap rendering successfully from tmx file. My game is a top down 2D maze game. I want to move to randomly generating the tiles, and I have the algorithm. The only problem is that I'm not sure how I can :
1) Dynamically create tiledmap 2) I will somehow need to set the rotation correctly in the algorithm of each tile. 3) Not only that, but I will need to determine which sprites to be drawn on each tile I generate. For instance, I have corner pieces, straight pieces, etc...
Thanks!
2
, determine what tile needs to be drawn yourself. What I usually do is give each type of floor a unique number and if you have multiple floors for variation give these a unique number too. Then your alghorithm needs to fill a map with types, then you can randomly insert unique floors of that type.
When your alghorithm is finished you can calculate corners in a 2nd pass. If you have a wall where only W, NW, and N is open then its a wall corner going from S to E. If you have a single image for all corners that is going from S to W then you just need to flip it horizontally or turn it 270 / -90 degrees. You need to calculate all these things yourself, and yes it's tedious work with a lot of if statements or switches.
I suggest you start small, just have a square block for a wall type and continue from there. So just create a map with booleans first, 0 = floow and 1 = wall. Later you can extend it further. You can add a lot of variations, I have been working on a tileset with 56 different tile types and these all needed to have 1 or more variations as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.