ok now i just started using datafiles. working on a tile based snake.
im storing all my bitmaps (items, tiles, etc..) in a single .dat datafile.
through my loadmap function, i stored all my tiles id in
<code> map.layer[0].cell[j]<i>.id [/code ]
i tried drawing the map using this function, but it didn't work :
1 | void drawMap(){ |
2 | |
3 | int i,j; |
4 | char t_name[64]; |
5 | |
6 | for(j=0; j < MAP_HEIGHT; j++){ |
7 | for(i=0; i < MAP_WIDTH; i++){ |
8 | |
9 | sprintf(t_name, "TILE%d", map.layer[0].cell[j]<i>.id); |
10 | blit( (BITMAP*)data[t_name].dat, |
11 | DoubleBuffer, 0, 0, |
12 | i * TILE_SIZE, j * TILE_SIZE, |
13 | TILE_SIZE, TILE_SIZE |
14 | ); |
15 | |
16 | } |
17 | } |
18 | |
19 | } |
now im out of ideas. is there a way of solving this?
or am i totally wrong and have to redo all this again (hope not..) ?
This doesn't work because the "name" of the dat file content is a define for an index.
Try:
int first_tile = TILE0; /* or TILE1, no idea if you start at 0 or 1 */ for(j=0; j < MAP_HEIGHT; j++){ for(i=0; i < MAP_WIDTH; i++){ /* This assumes that all tiles are listed one after another in the correct order */ blit( (BITMAP*)data[first_tile+map.layer[0].cell[j]<i>.id].dat, DoubleBuffer, 0, 0, i * TILE_SIZE, j * TILE_SIZE, TILE_SIZE, TILE_SIZE ); } }
If this doesn't work, you can also create an array of BITMAP* and load the bitmaps using the "filename#obj_name" syntax during start-up. So have no fear, we'll find a way to get this up and running
weeee, it solved the problem! thanks a lot spellcaster, and thanks for replying real fast too
No problem. Oh, and if you select "a problem with a specific answer" when you create a thread, you can actually mark the problem as solved and give those who helped you a virtual cookie
Coders like cookies.
hmm...i think i didn't select "a problem with a specific answer", coz i cant see any checkbox saying "the problem has been asnwered to my satisfication". selected the wrong one
No problem at all. I'll compensate by making fun of julian_boolean.. um.. I mean.. um.. never mind.
Love you too.