Home > categories > Construction & Real Estate > Tile > Creating a tile based map in java?
Question:

Creating a tile based map in java?

I want to know how to make tile based map in java. Retro games used tiled maps (to ease programming and memory management) but those games were created in assembly language. I know basic java. Now I want to make a 2d game in java, starting with a pretty basic 2d platformer type or top-down type. To do this, i need to know the technique required to make a map, a tile map.I have already searched in google and youtube and stack overflow, but none helped much. What I learnt is that I have to make some tile object and make a 2 dimensional matrix to store position of particular tiles. But this does not helped much. Thank you.P.S. there are many programs available on the internet for making tile maps, and also there are game making softwares and also libraries. i do not want to use any of those since i want to make my game with whatever java provides. Thank you. Also forgive my poor english.

Answer:

first of all, you need to build different densities of 2D tile arrays according to how much of the map will be in the viewport at any given time. For example, a map at neighborhood level will need a gazillion more tiles than a map at the county level. Then, you need a way of converting the geographic reference at the center of the viewport to the tile that is covered at that zoom level, and for finding the adjacent tiles as well. Then, you'll need to calculate what parts of which tiles you are using will need to be clipped and by how much. Build a canvas using this information. As the map moves, you'll need to add on more adjacent tiles, and discard others, update the clipping, etc.

Share to: