Currently making an 2d game as a project for school, I make maps by going to text and inputting numbers that specifiy the tile like = [1] grass [2] walls. So it goes like this 0 0 0 1 1 1 0 0 0 something like that. It feels so bothersome and decided to try tiled but I dont know how can I import my file into the java. Our professor prohibited us from using game engines so Iam stuck with java only. Need help badly thankss
There are a couple of Tiled map readers in Java listed in Tiled’s documentation: Libraries and Frameworks — Tiled 1.10.2 documentation
These are libraries you’d use with your code, and they read the files and give you Java objects to work with. You would still need to interpret the data for display, similar to how you’re interpreting your existing data.
You can also try any generic XML or JSON library. The Tiled documentation provides a good description of the contents and structure of these files, so once you’ve parsed them, you can navigate their structure to extract the data you need.
Another option is to bypass using Tiled’s native formats entirely. If your maps are as simple as your description suggests, you can use the CSV exporter, which will write out CSV files with the tile IDs, one per tile layer. That’s probably very similar to your current format, and should be very simple to parse, at the cost of not supporting all of Tiled’s features.
If CSV isn’t enough for your needs, you can implement a custom exporter in JavaScript, which will enable Tiled to write maps in your desired format. this will require learning about Tiled’s API, but there are some export map format examples available if you’re willing to search. For example, here’s a CSV-style export I wrote a while back, which shows the basics of exporting tile layers via the Tiled scripting API.
Thank you will try to go with your suggestions.