Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create my first game with java. I need a top view map of a city and i am stuck. Randomly there will be happening events in that city and the player should click on it.

Now is my first problem how to create the map in java. I designed a small map with tiled but not sure how to use it now:


I want to use this in the java game. I am stuck. I want to let the events happen on the streets. How do i do this? I am looking for some good tutorials but i am not sure what i am looking for so i could use some help in that direction.

Sorry for my english :(

share|improve this question

closed as too broad by msell, Anko, bummzack, Trevor Powell, Sean Middleditch Sep 17 '13 at 16:47

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

Could you be slightly clearer as to exactly what you want. Do you want to overlay dynamic graphics of street events over the top of the static city graphics? – Richard Tingle Sep 16 '13 at 9:00
Also, requests for tutorials is off topic. Focus on the problem you want to solve rather than resources you want to receive – Richard Tingle Sep 16 '13 at 9:01
Your question needs to be more specific. You're essentially asking how to make an entire game, a question of that scope is outside the scope of this site. – Byte56 Sep 16 '13 at 15:27

Note: it's clear from this question that you understand the reasoning behind using data files, but I will leave my preamble here for the benefit of others who come across this question in the future

Now is my first problem how to create the map in java. I designed a small map with tiled but not sure how to use it now:

I can't comment yet but you seem to be asking:

How can I export this map from tiled so I can actually use it in my game?

Why Data Files?

To answer this I should make a few things clear:

  1. Since every game needs different information about what the world looks like, the types and statuses of the objects in your game, etc... there is no ideal way for that data to be stored that will be perfect for every single game.
  2. At the same time it is of great importance that map editors like tiled make it as easy as possible for people to use the map data in their game. See this question. It would be great if there were some standardized way that maps from these editors could be stored so that they could be read easily by machines and (optionally) by humans. Enter data file formats like json and TMX (there are many others). Data files that follow these and other specifications store data in a structure that can be easily parsed by computer programs (such as your game). Tiled exports TMX files.
  3. Q. Oh fiddlesticks, are you telling me I have to write and debug a bunch of code to read these convoluted text files in order to get the map into my game? A. Not necessarily. To this end there are many helper libraries available that will do much of this work for you. see this page.

Main Answer

According to the Tiled wiki Support for TMX page:

A library for loading TMX files is included with Tiled at util/java/libtiled-java.

You shouldn't even have to download anything :) You will still have to figure out how to use the loader yourself; playing with the tests would be a good start.

I hope this helps!

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.