TileMap Array and only drawing whats on screen?

BlitzMax Forums/BlitzMax Beginners Area/TileMap Array and only drawing whats on screen?

Hmm.. you're going to need to know the current viewing coordinates, the size of each array tile and use some maths to work out which array[x][y] are visable on screen.

If pixel = index * tilesize, then index = pixel / tilesize.

So if each tile is 10x10
and the screen is at coordinates (100,100)
and is of size (200, 200)
(numbers for convenience)

Then the minimum index is 100/10 = 10 and the maximum index is 300/10 = 30. Same for both x and y in this case.

So draw array[10][10] to array[30][30].

I hope this helps.