• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tile based maps

 
Bryce Heath
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys

I'm looking for a good tutorial on how to make a simple tile based map in java. I have been searching google for 2 days now trying to find something that I can work with and still am coming up short. What I have now is a text file map.txt with 1s and 0s, 1s being a gray tile that is passable by the user sprite and 2 being a brown tile that is not. I made 2 png files for the tiles that are 80x80 px each. example of text follows
000000000000
011111111110
011111111110
011111111110
000000000000
I understand that I need a 2d array that will hold the values of the map.text and can figure out the text file reader and delimiters ect, but I do not understand the paint part of the array at what point am I pointing the array values to the png images and after that how would I take the 0 0 index in the array that being a brown tile and paint it having to use an X/Y pos due to the fact that the x/y pos x = 0 / y=0 is a single pixel in the top left corner yet the image it self is 80x80px would I have to skip +80 X to the right then repaint and move down at the end of the row? I hope this all makes sense thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic