Question about creating tile maps
Posted: Thu Jun 04, 2009 2:28 am
Hi all,
I'm having difficulty figuring out how to do tile maps on the DS. I've looked at examples, and I see how the code, works, but there are a few main topics which elude me still:
1) How do you generate a tile map from a BMP, PNG, or other format? I know you're supposed to use grit, with the -m options, but how would grit know how "big" a single tile is on the PNG? Is it a fixed, unchangeable size all the time (ie grit always divides every picture into 16pixel x 16pixel tiles and throws away whatever doesn't divide evenly), or is there an option to change how "big" a tile is?
2) I've been trying to dissect the sample code I've found on the net as to how to specify tile mapping, but I see a lot of magic numbers like the following:
.section .rodata
.align 2
.global Layer512x256Map @ 4096 bytes
Layer512x256Map:
.hword 0x0024,0x0025,0x0026,0x0027,0x0024,0x0025,0x0026,0x0027
.hword 0x0024,0x0025,0x0026,0x0027,0x0024,0x0025,0x0026,0x0027
.hword 0x0024,0x0025,0x0026,0x0027,0x0024,0x0025,0x0026,0x0027
I was thinking a tile map would be an index to the specific tile in the processed PNG from step one....aka if I wanted to display the first tile, I would say "0", and the second tile, I would say "1", etc... am I missing something? Why is everything in hex?
3) How would one go about actually create the PNG for the tile map? I'm assuming you can lay out a 16x16 grid and start drawing in the little squares, but I'm not entirely certain this is how tile maps are produced. Would someone please enlighten me?
Anyway, if anyone can answer these "n00b" questions of mine, I would greatly appreciate it. Thanks in advance for any help.
I'm having difficulty figuring out how to do tile maps on the DS. I've looked at examples, and I see how the code, works, but there are a few main topics which elude me still:
1) How do you generate a tile map from a BMP, PNG, or other format? I know you're supposed to use grit, with the -m options, but how would grit know how "big" a single tile is on the PNG? Is it a fixed, unchangeable size all the time (ie grit always divides every picture into 16pixel x 16pixel tiles and throws away whatever doesn't divide evenly), or is there an option to change how "big" a tile is?
2) I've been trying to dissect the sample code I've found on the net as to how to specify tile mapping, but I see a lot of magic numbers like the following:
.section .rodata
.align 2
.global Layer512x256Map @ 4096 bytes
Layer512x256Map:
.hword 0x0024,0x0025,0x0026,0x0027,0x0024,0x0025,0x0026,0x0027
.hword 0x0024,0x0025,0x0026,0x0027,0x0024,0x0025,0x0026,0x0027
.hword 0x0024,0x0025,0x0026,0x0027,0x0024,0x0025,0x0026,0x0027
I was thinking a tile map would be an index to the specific tile in the processed PNG from step one....aka if I wanted to display the first tile, I would say "0", and the second tile, I would say "1", etc... am I missing something? Why is everything in hex?
3) How would one go about actually create the PNG for the tile map? I'm assuming you can lay out a 16x16 grid and start drawing in the little squares, but I'm not entirely certain this is how tile maps are produced. Would someone please enlighten me?
Anyway, if anyone can answer these "n00b" questions of mine, I would greatly appreciate it. Thanks in advance for any help.