Tiled Map Editor - Tilesets and the JSON Format

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome indie game developers in my last video i gave my initial impressions of the tiled map editor which i'll be using to build the maps for my next game titled the colon case i mentioned possibly making a video on using weighing sets however keeping an eye on the discussions in discord it looks like the merger of weighing sets and terrain editing are actively being worked on for the next version with those improvements pending i figured i'd instead discuss some more basic tidbits about tile sets and the json format when creating a tileset based on a single image you have the option of defining margins and spacing between tiles i wasn't exactly sure how tiled was going to interpret these parameters so i made myself some sample images to prove it out it turns out that the margin is essentially like a border around the entire image not individual tiles spacing is exactly what i had imagined space in between every tile in this example image of an 8 pixel by 8 pixel tile set the 2 pixel purple represents the pixels that will be hidden by the margin and the 1 pixel yellow represents the pixels hidden by the spacing this is what this looks like importing this image in tiled setting the margin and spacing as appropriate while there are several c plus plus support libraries available for loading tiled maps and tile sets the majority of them are meant for parsing the xml focus tmx and tsx files there is one json focus parser called tilesum that looks promising however i wanted to make use of the general json cpp library as i'll have a number of other types of game data files that i'll be authoring in json so i spent the past few weeks building my own json format parser for maps and tile sets most of the explanation found in the json map format section of the tiled documentation is straightforward but here are a few tidbits you'll need to know if you plan on writing your own parser in order to ensure the tile ids in your maps tile data are unique across all the tile sets used on a map there are two separate properties you have to know about you have to sum together the first gid property from your map files tilesets array and the id property from your tileset file's tiles array for tile sets that are based on a single image the id values are computed based on their column and row in the grid tile set files based on a single image do not always have an explicit tiles array this array will only contain entries if you have set the type property or created custom properties for at least one individual tile you can see what happens here when i change the type property and then look at the resulting json file in the text editor it's also worth noting that all file paths are stored as relative paths compared to the containing file this is the case even if you choose to use the project feature entitled this has several potential consequences the first is that your game's loading code will have to continuously keep track of the relative paths as you open files the second is that you may want to add some kind of basic security check to ensure that a file isn't maliciously trying to access something outside your game's resource path even if you don't plan on allowing players the ability to mod your game directly this is probably a good validation or sanity check to make sure you didn't accidentally reference an errant image file while designing your maps now that i'm able to load tiled map data i'll be able to start working on the graphical rendering of the maps using sfml i'm also considering making a short video series on the cross platform cmake build system cmake is new to me so i'm hoping i might be able to bring a newbie's perspective on it that can help other newbies out there overcome those daunting first few steps so stay tuned to the riley entertainment games channel
Info
Channel: Riley Entertainment Games
Views: 465
Rating: undefined out of 5
Keywords: tiled tutorial, game development
Id: lq_50wdf1Pw
Channel Id: undefined
Length: 3min 58sec (238 seconds)
Published: Sat Jan 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.