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.

  • 4
    \$\begingroup\$ Do you know how to draw lines? Where are you stuck? \$\endgroup\$
    – AturSams
    Commented Feb 4, 2014 at 9:00
  • 1
    \$\begingroup\$ What did you try? \$\endgroup\$ Commented Feb 4, 2014 at 10:42

1 Answer 1


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

Not the answer you're looking for? Browse other questions tagged .