-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.

| improve this question | | | | |
\$\endgroup\$
  • 4
    \$\begingroup\$ Do you know how to draw lines? Where are you stuck? \$\endgroup\$ – AturSams 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
    }
}
| improve this answer | | | | |
\$\endgroup\$

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