How do you structure a 2D level format with collisions etc. in Java (Slick 2D)?

I am developing a game in Java. 2D Fighter, Kind of like the 2d flash game Raze(http://armorgames.com/play/5395/raze). I currently am using the Slick 2D game library and am researching how to structure my levels. I am currently stuck on the problem of the level format(e.g. file format). How do you structure a 2d level with collisions etc.?

Level Notes: Will go up down left right

NOTE: New to gamedev

There are many ways of structuring 2D levels.

One way would be to create a Level class which contains all the GameObjects and their physics-related information. It would know of where each GameObject and its rotation, along with each GameObjects physics bounding shape its orientation. Then, you could create an editor for the Levels and let it save/load Levels using serialization or some other method.

The file format doesn't really matter, as long as it suits your needs. If you don't need to be able to edit it from outside an editor, you could just use serialization. If you do, then you can use a text file that describes all of the GameObjects that your Level contains. For example, your file format could be like this:

<Level name="Tutorial">
<GameObject name="Floor1">
<Physics type="static" shape="Box(1000, 10)"/>
<Orientation position="0, 800" rotation="0"/>
</GameObject>
<GameObject name="Bob the Unicorn" class="com.stackexchange.game.Unicorn">
<Physics type="dynamic" shape="Polygon({10, 20},{40, 30},{-10, 500})" mass="99"/>
<Orientation position="50, 30" rotation="50"/>
</GameObject>
...
</Level>

• Check out mrohlf's answer. Using Tiled Map Editor's format is probably better than creating your own format. Sep 12 '11 at 20:17

Check out the Tiled Map Editor. It's a fairly flexible and user-friendly program, and Slick natively supports its file format, which makes it very easy to use.

You will want to have at least two layers in your map: one with the map graphics, and one collision layer (which won't be displayed in the game). When the player tries to move into a new tile, check the collision layer to see if a tile exists there, and if so, block the player from moving into the tile.

If you want to use arbitrary terrain shapes, you'll have to use something more like skyuzo suggested. Tile maps are less flexible, but they can still allow for a large variety of levels, and they're easier to work with as a beginner.