#19931 - CyberSlag5k - Wed Apr 28, 2004 5:04 am
Ok, I"m picking up making maps from tiles. It's going kind of slowly. Out of sprites, animation, drawing a bitmap to the screen, and the DMA, this is turning out to be the most difficult thing I've faced yet. Sound reasonable?
Anyway, I've gone through the gbajunkie and pern tutorials (they're quite similar because gbajunkie kinda modeled his off of pern) twice and am still not entirely sure what's going on, but I'm sure the more I play with it the more I'll understand (I'm a hands on learning kinda guy). So anyway, I've set up a background struct as the tutorials suggest and went through the setup procedures, but my program is acting a little funny. Rather than post a huge bit of code and ask you guys to comb through it (I hate doing that), I've decided to break it into chunks and ask specific questions.
So! Question #1: What I gather from my tutorials, loading tile and map data are a little different from each other. My loop for loading tile data looks like this:
I would just assume that this is for each pixel on the screen (divided by 2 of course due to the double horizontal thing). Where the tutorial and I differ a little bit (and the bulk of my question lies) is right here:
gbajunkie has variables (exptiles_WIDTH and exptiles_HEIGHT) in place of my 30 and 20. I'm not sure where they've come from, but I believe they are just the number of tiles across and down the map. In my case, since my map was 240 * 160 and each tile is 8 pixels, I surmised that my loop should run 30 * 20 and then divided by 2 (a quick quesiton, I'm not sure why I'm dividing by 2 here. Isn't this creating the map based on tiles?). Is this the correct way to do this? A bit of clarity, bgMap and bgTiles are both created by my map editor (Nessie's MapEd) and mapData and tileData are definied in my struct (arrays of type u16*).
Anyway, does what I have here look sort of kosher? I haven't included most of the code for as I said, I'm not terribly clear on what's going on here and would like to take it section by section to get a better feeling for it. If, however, further information is required to answer the quesitons I've asked, I would be happy to supply it.
Thanks as always!
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Anyway, I've gone through the gbajunkie and pern tutorials (they're quite similar because gbajunkie kinda modeled his off of pern) twice and am still not entirely sure what's going on, but I'm sure the more I play with it the more I'll understand (I'm a hands on learning kinda guy). So anyway, I've set up a background struct as the tutorials suggest and went through the setup procedures, but my program is acting a little funny. Rather than post a huge bit of code and ask you guys to comb through it (I hate doing that), I've decided to break it into chunks and ask specific questions.
So! Question #1: What I gather from my tutorials, loading tile and map data are a little different from each other. My loop for loading tile data looks like this:
Code: |
for(int i = 0; i < 240 * 160 / 2; i++) { back2.tileData[i] = bgTiles[i]; } |
I would just assume that this is for each pixel on the screen (divided by 2 of course due to the double horizontal thing). Where the tutorial and I differ a little bit (and the bulk of my question lies) is right here:
Code: |
for(int i = 0; i < 30 * 20 /2; i++) { back2.mapData[i] = bgMap[i]; } |
gbajunkie has variables (exptiles_WIDTH and exptiles_HEIGHT) in place of my 30 and 20. I'm not sure where they've come from, but I believe they are just the number of tiles across and down the map. In my case, since my map was 240 * 160 and each tile is 8 pixels, I surmised that my loop should run 30 * 20 and then divided by 2 (a quick quesiton, I'm not sure why I'm dividing by 2 here. Isn't this creating the map based on tiles?). Is this the correct way to do this? A bit of clarity, bgMap and bgTiles are both created by my map editor (Nessie's MapEd) and mapData and tileData are definied in my struct (arrays of type u16*).
Anyway, does what I have here look sort of kosher? I haven't included most of the code for as I said, I'm not terribly clear on what's going on here and would like to take it section by section to get a better feeling for it. If, however, further information is required to answer the quesitons I've asked, I would be happy to supply it.
Thanks as always!
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...