Slick2d TileMap on Server

Hello guys,

at the moment i am programming a 2d online racing game with a client/server architecture. I use Kryonet for the network stuff and slick2d on the client for rendering and use the geometry part of slick2d on the server for collision detection etc.
For my Tracks i use the free tilemap-Editor “Tiled”.
Now to my problem:
my Server is a plain java Application, but i have to load my tilemap on the server so i can perform collisions with my cars and “blocking” objects like walls or so.
But i cant load the Tilemap because i dont have a slick2d Application and therefore not a openglcontext which i need to load my tileMap.

How can i solve this?

TiledMaps are just huge XML files, so read up on XML file parsing. :wink:

You’ll probably have to write your own XML parser to read TMX files and convert the data to what you need that matches what the client’s use it for.

NOTE: Keep in mind that by default TiledMaps compress the data, so you’ll have to read up on how to uncompressed it as well, or save it uncompressed(not recommended).

I’m sorry, I can’t help but I’m interested too. Is this the only way?

This is my question too. If there is no other way i will try to program it in the next days and post my results here.

you can just rip the XML parsing part from the slick source and use it on the server.
The reason it doesnt work out of the box is because slick of course wants an opengl context, but your server has no graphic output like this normally
so you wanna do data structure stuff but no graphics

Try libtiled-java. If you’ve already got Tiled installed, you can find it in a subfolder of the main installation directory. You’ll have to spend some time with the source to figure it all out, but it’s fairly simple to get a handle on. It also has no sort of OpenGL, Slick2D, or other framework dependencies, so it integrates easily on the server side. No real need to roll your own or to copy/paste snippets out of Slick.

^ Try this. Because Slick2d’s TiledMap class even handles the data decompression as well, and will offer you the ability to make sure you keep all the data collected in the same kind of data format. It will just make things easier all around for you. :wink:

It’ll also give you some insight on how XML parsing works, and if you’re like me, you’ll find that XML parsing is annoyingly confusing at first.

Import slick on the server.
???
Profit.

That’s how I did it back during my Tiled-Map days.