File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Tile based maps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Tile based maps" Watch "Tile based maps" New topic

Tile based maps

Bryce Heath

Joined: Sep 16, 2011
Posts: 19
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
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
I agree. Here's the link:
subject: Tile based maps
It's not a secret anymore!