-3
\$\begingroup\$

I have been reading alot on tile-based game programming but i could not find a satisfying answer to this question.

I want to know how i can divide the screen into tiles of a size like 32?

I am doing it in JAVA.

\$\endgroup\$

closed as too broad by Anko, MichaelHouse Feb 4 '14 at 15:15

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    \$\begingroup\$ Do you know how to draw lines? Where are you stuck? \$\endgroup\$ – wolfdawn Feb 4 '14 at 9:00
  • 1
    \$\begingroup\$ What did you try? \$\endgroup\$ – Timothy Groote Feb 4 '14 at 10:42
5
\$\begingroup\$

You do not divide a screen into tiles, you create a field that renders tiles in a grid sequence. Those are usually some sort of bitmaps that are stored in memory and are placed one after another to form a bigger picture - the tile grid. For a 2 dimensional grid, you'd use two for..loops (one inside another) to render rows and columns.

for(int i=0; i<rows; i++){
    for(int u=0; u<columns; u++){
        // render tile with the coordinates [i,u] at position [32*i,32*u]
        // that is assuming your tile size is 32x32
    }
}
\$\endgroup\$

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